• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to insert data into excel file using java code?

 
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 5
IBM DB2 Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey Swastik Dey !
Great !! It working after removing Read Only DSN !!
Thanks.!!
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic