简体   繁体   English

Aspose-将Excel转换为PDF速度很慢

[英]Aspose - Convert Excel to PDF is Slow

Am using Aspose and it is very slow in converting Excel to PDF. 我正在使用Aspose,将Excel转换为PDF的速度非常慢。 I have generated XSSFWorkbook 我已经生成了XSSFWorkbook

ByteArrayOutputStream excelAsByteArrayOutStream = new ByteArrayOutputStream();
xssfWorkbook.write(out_excel);
excelAsByteArrayOutStream.close();

ByteArrayOutputStream pdfAsByteArrayOutStream = new ByteArrayOutputStream();
Workbook workbook = new Workbook(new ByteArrayInputStream(excelAsByteArrayOutStream.toByteArray()));
workbook.save(out, SaveFormat.PDF);

Any other faster way to achieve this. 任何其他更快的方法来实现这一目标。

Generally, Aspose.Cells for Java is fast and efficient to convert bigger MS Excel workbooks to PDF file format. 通常,Aspose.Cells for Java可以快速有效地将较大的MS Excel工作簿转换为PDF文件格式。 I guess the slowness issue might be on XSSFWorkbook part which is writing byte array. 我猜慢度问题可能在XSSFWorkbook部分,该部分正在编写字节数组。 Or the issue might be in the module for extracting/loading file from streams. 或者问题可能出在从流中提取/加载文件的模块中。 For confirmation, you may only use Aspose.Cells APIs (without involving XSSFWorkbook) to load the file from streams and then save to PDF file format. 为了进行确认,您只能使用Aspose.Cells API(不涉及XSSFWorkbook)从流中加载文件,然后保存为PDF文件格式。 eg Sample code: 例如示例代码:

Path fileLocation = Paths.get("your_file.xlsx");
byte[] bytes = Files.readAllBytes(fileLocation);

try (FileOutputStream simpleStream = new FileOutputStream("no_aspose_file.xlsx")) {
    simpleStream.write(bytes);
}
Workbook workbook = new Workbook(new ByteArrayInputStream(bytes));
ByteArrayOutputStream dstStream = new ByteArrayOutputStream();
PdfSaveOptions saveOptions = new PdfSaveOptions(SaveFormat.PDF);
// Save Workbook to PDF format by passing the object of PdfSaveOptions
workbook.save(dstStream, saveOptions);
..........

I would recommend you to try latest version/fix v19.8 which has more enhancements. 我建议您尝试使用具有更多增强功能的最新版本/修复程序v19.8。 PS. PS。 I am working as Support developer/ Evangelist at Aspose. 我在Aspose担任技术支持/开发人员。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM