3

Is it possible to create and write to a (new) excel file using the event driven API from POI? I've found examples on how to read with that API, but not how to write.

thanks, Jeff

4 Answers 4

2

Here is one possibility, not very well written, though:

http://www.docjar.org/html/api/org/apache/poi/xssf/usermodel/examples/BigGridDemo.java.html

I'm using a modified version of that, which does not require temporary files and is overall more efficient

Sign up to request clarification or add additional context in comments.

3 Comments

thanks. do you have any samples you could provide of how you're doing it?
can't give you my code as I don't own it. For most cases the code from the above link works ok.
Since I was searching a lot about this topic I would like to note that as mentioned here: svn.apache.org/repos/asf/poi/trunk/src/examples/src/org/apache/…, Apache POI's SXSSF actually implements the BigGridDemo - so no need to write your own solution of using Apache POI!
0

Yes. Absolutely. Look at POI-XSSF and POI-HSSF

http://poi.apache.org/spreadsheet/how-to.html#user_api

1 Comment

this uses the user api. I am trying to use the event based API due to memory limitations when writing xlsx files.
0

You could use the SXSSF from Apache POI

https://poi.apache.org/spreadsheet/how-to.html#sxssf

1 Comment

Welcome to Stack Overflow! Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference.
0

I'vr worked with SXSSF from Apache POI. It is really good for writing huge files of data since it keeps only a small part of data in memory and flushes the remaining to disk, as opposed to HSSF or XSSF which keep all data in memory till finally writing at once. But unfortunately, SXSSF is that it is meant only for writing, not for reading.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.