We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

PDF conversion from Excel sheet is taking time

Hi

I am trying to convert excel to pdf. Below code snippet. Attached is excel file.

<?xml:namespace prefix = "o" ns = "urn:schemas-microsoft-com:office:office" />

Attached file conversion taking 3 min 7 sec on window 7 machine. Can this be improved further

public static void main(String[]
args)
throws Exception {<o:p></o:p>


<o:p></o:p>


log.info(“Before
loading file”
);<o:p></o:p>


Workbook wb =
new Workbook(“H:\TicketExcel.xlsx”);
<o:p></o:p>


log.info(“After
loading file”
);<o:p></o:p>


PdfSaveOptions optsPDF =
new PdfSaveOptions();<o:p></o:p>


optsPDF.setAllColumnsInOnePagePerSheet(
true);<o:p></o:p>


log.info(“Before
saving file”
);<o:p></o:p>


wb.save(
“H:\TicketPDF.pdf”, optsPDF);<o:p></o:p>


log.info(“After
saving file”
);<o:p></o:p>

}<o:p></o:p>

</o:p>

Hi Tauqeer,


Thank you for sharing the sample spreadsheet.

Please note, as you are setting the PdfSaveOptions.AllColumnsInOnePagePerSheet property to true, it will surely take more time for the conversion as compared to normal conversion process that renders the spreadsheet page by page. While setting the PdfSaveOptions.AllColumnsInOnePagePerSheet property to true you are actually overriding the rendering process by instructing the API to render all columns of the worksheet on one PDF page. This needs more memory to process and more time to flush the results.

That said, we have used the latest version of Aspose.Cells for Java 8.6.1 to check the execution time for your exact code. The time to load the spreadsheet is 2250 milliseconds and time to convert it to PDF format is 49624 milliseconds where the total execution time is 51874 milliseconds (0.86 minutes), that is much less than what you have reported. Please give the latest version a try on your side to feed us back with your results.

Environment Details

  • Windows 7 Home Premium x64
  • Oracle’s JDK 1.8.0_60
  • 6 GB RAM
  • Aspose.Cells for Java 8.6.1`


Java

long startTime = System.currentTimeMillis();
Workbook wb = new Workbook(“C:\temp\TicketExcel.xlsx”);
long endTime = System.currentTimeMillis();
System.out.println("Loading time: " + (endTime - startTime) );
PdfSaveOptions optsPDF = new PdfSaveOptions();
optsPDF.setAllColumnsInOnePagePerSheet(true);
startTime = System.currentTimeMillis();
wb.save(“C:\temp\TicketPDF.pdf”, optsPDF);
endTime = System.currentTimeMillis();
System.out.println("Conversion time: " + (endTime - startTime) );