I am looking for utility to convert Excel to PDF using iText API. Find many sources like this (Convert excel to pdf using iText) but not working out for huge data in Excel (around 15 MB excel file with 18 columns and 15,00,000 rows) as it is giving Out of memory exception. Need an utility to transform xlsx file and store it as PDF in local drive.
Related
I am using Java + Apache POI to generate an excel file (format xlsx/xls). Due to huge data the generated excel file (format xlsx/xls) takes more size (~50 MB).
So I am trying to convert xlsx/xls to xlsb to reduce the size of the excel file.
Here is the problem: Apache POI does not support writing to xlsb file. So what I am trying is:
Generate a xlsx/xls file using Apache POI.
After that convert generated xlsx/xls to xlsb. For this I am using
SmartXls Java library. But this library is not open source. You need to
buy license for this. Also I checked EasyXls Java library, but it also requires buying a license.
Below code is used to convert xlsx/xls to xlsb using SmartXls Java library:
WorkBook wb = new WorkBook();
wb.readXLSX(.../xlsxPath);
wb.writeXLSB(new java.io.FileOutputStream(.../xlsbPath));
wb.dispose();
Kindly someone help me whether any open source library is available for it or is there any other way to do this conversion in Java.
Thanks in advance.
Because I have used JXL api for excel but now I want to convert it to Pdf file so please tell me how to change my code to convert excel to pdf?
You could use iText to create a pdf file in java and use Apache POI to access the data in the MS-EXCEL file. If you combine both, you could convert your excel file.
A raw example is given here
Also, there is this new API:
You can try Aspose.Cells for Java which allows you to convert Excel file to PDF in Java applications. It doesn't require MS Office/OpenOffice etc to be installed on your development or deployment machine. It also works on both Windows and Linux platforms. The code is very simple as shown below:
//Instantiate a new workbook with excel file path
Workbook workbook = new Workbook("F:\\FileTemp\\Book1.xls");
//Save the document in Pdf format
workbook.save("F:\\FileTemp\\MyPdfFile.pdf", FileFormatType.PDF);
I am using POI library to deal with docx, pptx, xlsx and so on. It is strange that MS turn all the embedded files such as .wma, .vsd into .bin. Is there any way to extract them back to the original file with proper extension rather than .bin?
When saving an excel sheet (xls - 2330) in .xml form, the xmlss file will contain the respective xsl code. But in xlsx i can't save the file with .xml format.
Also is there any specific Apache POI API availabe to convert .xls (2003) to .xlsx(2007) format?
Since the POI creates the xmlss file to create the xlsx, is there any simpler option?
related links:
http://msdn.microsoft.com/en-us/library/aa140066%28office.10%29.aspx#odc_xmlss_x:header
Greetings in advance.
My application requires a reporting facility in excel/csv format. In case of large report, the generated CSV is corrupt. Though i am able to e-mail the generated CSV using smtp.
I tried changing the following with no lead, your help on this is appreciated
Change the library to POI
Changed the library to JXL
Monitored if there is a memory leakage
This is a web based application and the code is written in JSP.
POI is mainly for MS office formats like xls, xlsx, doc. JXL is also for xls files. You should use a framework which is for CSV like OpenCSV.