wood burning stoves 2.0*
The moose likes JDBC and the fly likes How to insert data into excel file using java code? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "How to insert data into excel file using java code?" Watch "How to insert data into excel file using java code?" New topic
Author

How to insert data into excel file using java code?

minal silimkar
Ranch Hand

Joined: Nov 25, 2007
Posts: 133
I wrote below code to fetch data from excel work sheet. It is working file.


I want to transfer data from one sheet to another, so I wrote following code.

It is giving error at insert statement.
How to insert data into excel file using java code?


Minal Silimkar
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41621
    
  55
What is the error? Post the full error message.

I don' think that ODBC can be used to alter Excel files - it can only read them. Either find a different Excel JDBC driver that can do this (although I doubt such a driver exists), or use a library like jExcelApi or Apache POI to alter the file programmatically.


Ping & DNS - my free Android networking tools app
Swastik Dey
Rancher

Joined: Jan 08, 2009
Posts: 1474
    
    6

You are missing the single quotes in the query formation.

sql="insert into [Sheet2$] Values ("+columnValue+")";

should be

sql="insert into [Sheet2$] Values ('"+columnValue+"')";

and make sure the dsn has not been configured as readonly.


Swastik
Raj Java Raj
Greenhorn

Joined: May 14, 2012
Posts: 5

Hey Swastik Dey !
Great !! It working after removing Read Only DSN !!
Thanks.!!
 
 
subject: How to insert data into excel file using java code?