Hi
I am using Aspose Cells 17.8 to convert Excel files to HTML format.
Here is my code for test:
String fileName = “施工預定進度表及要逕圖.xls”;
Workbook book = new Workbook("custom/input/xlsx/" + fileName);
new File("custom/output/xlsx/" + fileName + "/").mkdirs();
for (int page = 0; page < book.getWorksheets().getCount(); page++) {
System.out.println(book.getWorksheets().get(page).getName());
//addHeader(book, page + 1, new ArrayList<Integer>());
ByteArrayOutputStream baos = new ByteArrayOutputStream();
for (int i = 0; i < book.getWorksheets().getCount(); i++) {
if (i == page) {
book.getWorksheets().get(i).setVisible(true);
}
}
for (int i = 0; i < book.getWorksheets().getCount(); i++) {
if (i != page) {
book.getWorksheets().get(i).setVisible(false);
}
}
HtmlSaveOptions saveOps = new HtmlSaveOptions();
saveOps.setClearData(false);
saveOps.setCreateDirectory(false);
saveOps.setExportActiveWorksheetOnly(false);
saveOps.setExportHiddenWorksheet(false);
saveOps.setParseHtmlTagInCell(true);
saveOps.setEncoding(Encoding.getUTF8());
saveOps.setHiddenRowDisplayType(HtmlHiddenRowDisplayType.REMOVE);
saveOps.setHiddenColDisplayType(HtmlHiddenColDisplayType.REMOVE);
saveOps.setExportImagesAsBase64(true);
saveOps.setStreamProvider(new IStreamProvider() {
@Override
public void initStream(StreamProviderOptions arg0) throws Exception {
arg0.setStream(new ByteArrayOutputStream());
}
@Override
public void closeStream(StreamProviderOptions arg0) throws Exception {
System.out.println(arg0.getDefaultPath());
OutputStream stream = arg0.getStream();
if (stream instanceof ByteArrayOutputStream) {
ByteArrayOutputStream bb = (ByteArrayOutputStream) stream;
IOUtils.write(bb.toByteArray(),
new FileOutputStream("custom/output/xlsx/" + arg0.getDefaultPath()));
}
}
});
book.save(baos, saveOps);
IOUtils.write(baos.toByteArray(),
new FileOutputStream("custom/output/xlsx/" + fileName + "/" + (page + 1) + ".html"));
}
In the result of this Excel file, the text in B4 should be splitted into 2 lines in the result just like the origin, but it was not.
result.zip (15.9 KB)
施工預定進度表及要逕圖.xls.zip (6.7 KB)
image.jpg (71.6 KB)
Please check the attachment, and this issue.
Thank you~
Craig