Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2037
  • Last Modified:

using Java writing / to write on an excel file (column, row)

Using java (jdbc), can I write into an excel file under a column without a name (column name is always on row 1 right?) ?
and also can I add a new column (while java program is running) by writing something (column name ) in row 1, any column and then update the newly "created" column?  or can I indicate specifically on what cell number I could write into?
How do you do it if it's possible?  I can't find it on the net.

Thanks a lot!
2 Solutions
I think that you should import the spreadsheet into Access, MySQL, ... than use JDBC to manipulate the data,
or use Apache POI library to manipulate your Excel data, change layout, etc.
or use both of these to get what you want.
proxylaangAuthor Commented:
err I wouldn't like doing it all over again using POI or others besides the simple JDBC in java.  Unless there's a reason.
points increased if anyone can help me
I guess the poor documentation on it could  be a reason,

you cannot indicate the cell number you want to write into :
With JDBC you can only execute SQL queries, and they are limited :

"[...] According to Microsoft, the Microsoft Excel ODBC driver does have some limitations. Specifically, the driver does not support DELETE, UPDATE, or ALTER TABLE statements. CREATE and INSERT statements are supported; just be sure to set up your data source as write-able. [...]"

To add a column, you need an ALTER TABLE query, and as you can read, it is not supported by the ODBC driver.

Another reason ...

To read/write to excel files try using the xlSQL library which can be found at http://schmidt.devlib.org/java/libraries-excel.html

Hope this helps.
Forced accept.

EE Admin

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now