How to insert data in excel using asp.net? -


i trying insert record in excel using asp.net giving error this..

error [im002] [microsoft][odbc driver manager] data source name not found , no default driver specified

my code follows:

string connect = "provider=microsoft.jet.oledb.4.0;data source=c:\\student.xls;extended properties=excel 8.0;hdr=yes;"; con = new odbcconnection(connect);          string query = "insert [sheet1$](sid,sname,saddress) values('6','ravi','rajam')";  odbccommand objcmd = new odbccommand(query,con);  int i= objcmd.executenonquery(); if (i == 1) {    response.write("inserted"); } else {    response.write("not inserted"); } 

you getting error because have missing driver on web server.

there 5 basic ways insert data excel sheet:

  • via odbc connection, approach
  • 3rd party tool
  • start excel via code , interop it, yokos approach. has several problems: requires excel installed on server, uses lot of memory, not scale, licence cover it...
  • use sharepoint excel services, if have sharepoint enterprise, expensive this.
  • spreadsheetml

i go spreadsheetml http://blogs.msdn.com/b/brian_jones/archive/2008/11/10/reading-data-from-spreadsheetml.aspx

we had similar project generated ms word documents, switching interop wordml reduced generation time of document 40 seconds 2.


Comments

Popular posts from this blog

jQuery clickable div with working mailto link inside -

java - Getting corefrences with Standard corenlp package -

WPF: binding viewmodel property of type DateTime to Calendar inside ItemsControl -