How to convert ms-Excel file to Pdf in java? - java

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);

Related

convert excel to pdf using itext API programmatically in java

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.

Convert excel file from XLSX to XLSB in Java

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.

How to read an not in excel format or corrupted excel file using java

I need to download some data in webpage in the form of excel file for that webpage contains excel image button. When i click the button an excel file downloads with containing some data which i need. But when i tried to open the downloaded file it showing an error "The file you are trying to open , File is in different format then specified by the file extension or corrupted data. Because of this error i am unable to read the data by using java.
try to save it as xlsx as there are two kind of work book provided by poi that is for xls and another is for xlsx.

Is there any way to generate Xlsx (2007) using xmlss?

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.

Convert .txt file to .xls in java

I'm using mallet to do some topic modeling experiment and now I got the keys.txt and doc.txt which I can open using microsoft excel but when I used POI api to read the content it just didn't work and give me the result as invalid header.
I tried to open the files in excel and save them the second time in xls format and this time it worked. So I guess though I specified in mallet command that it should be saved as xls it didn't work.
Is there any way that I can convert a txt to xls format in java? Or I can use java to open call microsoft excel to open the .txt file and save them again?
Thanks.
Maybe mallet is generated CSV (comma separated value) or TSV (tab separated value) files. You could try a library like opencsv to read the file, create an XLS file from the data using POI. If my assumption is true, you may find more help in this thread.

Categories

Resources