Open Large Existing Excel Document in Java [duplicate] - java

This question already has answers here:
Error While Reading Large Excel Files (xlsx) Via Apache POI
(4 answers)
Closed 7 years ago.
I am attempting to open a fairly large excel document (about 150,000 rows of 6 columns) using Apache POI in Java to remove an entire worksheet. When I try
wb = new XSSFWorkbook("OUTPUT/BOSS.xlsx");
I get
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
I am really not sure what else to do. Unfortunately the server I am trying to do this on is running 1.5 so I am limited on what I can use/do. Also apparently SXSSF only works for writing, not reading, files.
Does anyone have some sort of suggestion as to what I might be able to use/try?
EDIT: The excel file is about 2.5mb if that matters

It seems the best way to parse the data from the excel document is to use POI SAX Parser. You can find more information on it here: http://poi.apache.org/spreadsheet/how-to.html#xssf_sax_api
The problem I have now is how to use this to then delete the worksheet that is being parsed. I will make a new question for this if I cannot figure it out.

Related

POI workbookfactory read big Excel [duplicate]

This question already has answers here:
How to load a large xlsx file with Apache POI?
(8 answers)
Closed 2 years ago.
Is there a way to use WorkbookFactory with big Excel file? (5,5 MB)
Workbook wb = WorkbookFactory.create(new FileInputStream(file));
when the file became big, by using background-colors."
I get the error: java.io.IOException: GC overhead limit exceeded.
Altering the excel is not an option.
Is it possible to ignore the styles when reading the excel?
side info: The background was changed for a lot of rows that don't contain text.
Here is the answer to your question:
Writing
For writing very huge files, there is SXSSFWorkbook which allows to do a streaming write of data out to files (with certain limitations
on what you can do as only parts of the file are held in memory).
Reading
For reading very huge files, take a look at the sample XLSX2CSV which shows how you can read a file in streaming fashion (again with
some limitations on what information you can read out of the file, but
there are ways to get at most of it if necessary).

how to read excel files datas and write into csv file using java? [duplicate]

This question already has answers here:
How to read and write excel file
(22 answers)
Closed 6 years ago.
could you please anyone assist me how to read excel files datas and write into csv file using java????
Please give Code for this scenario
Thanks in Advance
Regards
Kumar
One simple solution would be to convert your excel file into a .CSV file by saving it as such. Then you could, depending on the excel table structure, read the CSV file if the table successfully saved as one.
I think reading a simple CSV-file in Java won't require any sample-coding from me since it is fairly simple if one understands the I/O operations of the Java API.
If you actually need to do that converting manually I would not go for Java here. Use VBA which is used for macro programming in Excel.

java best way to create and write XML [duplicate]

This question already has answers here:
How to read and write XML files?
(6 answers)
Closed 7 years ago.
We need to write XML files to a zip file. This part of our code is 22%+ of the total processing time so optimizing this will be a big win. We're presently using dom4j to write out to a Document and then using XMLWriter to write the generated Document to the ZipOutputStream.
We need to run on Java 1.4.
The code is written so we do NOT need a DOM. We walk through writing the xml in order so if it can then write immediately to the zip stream, that would work well.
Update: We also use dom4j for XPath queries (where we do read the XML into a DOM). We can have 2 libraries but if there's an alternative that is better for both uses, that would be good too.
But for this specific need, it's pure write it out, in order (ie no DOM needed).
I think StAX produces streamed XML Output: http://stax.codehaus.org/. That would get you out of maintain a DOM in memory for the output XML.

How to make a single excel sheet as readable and writable with JXL in java? [duplicate]

This question already has an answer here:
Closed 11 years ago.
Possible Duplicate:
How to write to the SAME excel sheet using JXL API?
i am reading one excel file and validating the same. If validation is not success, i want to display some error on the same sheet. So how it can be possible? Can any one have any idea?
I guess the only way is to create a temporary file of the original file and read the temporary file. Do the validations. Open the original file for writing and display the error message. Finally delete the temporary file :-)

Doubt in jxl API?

While practicing the jxl API, i cant extract details from certain Excel sheet its throwing the following exception
Unable to recognize OLE stream
at jxl.read.biff.CompoundFile.(CompoundFile.java:116)
at jxl.read.biff.File.(File.java:127)
at jxl.Workbook.getWorkbook(Workbook.java:221)
at jxl.Workbook.getWorkbook(Workbook.java:198)
at Com.Parsing.ExcelFile.excel(Extract.java:13)
at Com.Parsing.Extract.main(Extract.java:35)
It sounds like there's something wrong with the Excel file.
You might have better luck posting the question on The JExcelApi Yahoo Group - the guy who created JExcelApi hangs out there and often answers questions.
If you are using maven and filters, check that your .xls file is not filtered.

Categories

Resources