aspose file tools*
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


Win a copy of Java 8 in Action this week in the Java 8 forum!
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: 39578
    
  27
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 - updated with new look and Ping home screen widget
Swastik Dey
Rancher

Joined: Jan 08, 2009
Posts: 1400
    
    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.!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to insert data into excel file using java code?
 
Similar Threads
JSP
Readin excel files from Java & output
Reading an Excel file using Java
Calling the Excel file using Java
The specified DSN contains an architecture mismatch between the Driver and Application