Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've made a file browser in java that opens and read already been made excel files. (using Apache poi 3.9 library) program read those files perfectly but i want to update some of those files. how can i be able to update those files through my program. is there is any library or function/class that might be helpful, or also any other language that can support that feature (among c/c++, python)..???

share|improve this question

closed as off-topic by GlenH7, MichaelT, Corbin March, Dan Pichelman, Kilian Foth Aug 19 '13 at 14:37

  • This question does not appear to be about software development within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

AFAIK Apache POI supports changing Excel files as well as reading, so where is your problem? – Doc Brown Aug 19 '13 at 11:10
right now i've to first open a file then read cells then creat another workbook, copy data from first file to that workbook then write 2nd workbook into the first one.... (is this an efficient way..??? I don't think so) – Haseeb Akhtar Aug 19 '13 at 11:28
This question appears to be off-topic because it is about an implementation issue with Apache POI. – GlenH7 Aug 19 '13 at 12:28
up vote 2 down vote accepted

There are a bunch of examples on the Apachi POI library site on how to change and save Excel files. Here are a couple of pages to get you started:

E.g. workbook objects in the library have a write(…) method if you want to save the contents of it to a file using an appropriate OutputStream:

// Save a workbook (wb)
FileOutputStream out = new FileOutputStream("my_workbook.xls");

If you want to open the files in Excel you can, according to this answer, try using Desktop which is available in JDK6.

Desktop.getDesktop().open(new File("c:\\file.xls"));
share|improve this answer
Thanks for response Spoike but i don't want to creat extra workbooks i just want to open one show that one to the user and let the user to change it. just like we did in Ms Excel. – Haseeb Akhtar Aug 19 '13 at 11:30
@haseebAkhtar Wouldn't it be better to open the file in Excel from your Java program? – Spoike Aug 19 '13 at 11:34
could you explain please....? (Help me how) – Haseeb Akhtar Aug 19 '13 at 11:39
@haseebAkhtar You can use Desktop to open files with appropriate program. I.e. it assumes that Excel is installed in the user's computer and that the extension is correctly associated with Excel. – Spoike Aug 19 '13 at 11:54
Thats cool, thanks for giving me SucH a HelPfuL information.. :) – Haseeb Akhtar Aug 19 '13 at 12:00

If POI is not sufficient for any kind of reasons, you may have to utilize Excel by using COM Automation for such a task. Read this SO post for more information how to do this in Java. But beware, this will have some drawbacks:

  • platform-dependent (will only work on Windows)
  • won't work well for a server-side application
  • slow (compared to direct access by POI)
share|improve this answer
This is something \m/ – Haseeb Akhtar Aug 19 '13 at 11:44

Not the answer you're looking for? Browse other questions tagged or ask your own question.