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

Free Support Forum - aspose.com

Aspose.Cells for Java excel转html,有excel转换后几列列宽被拉宽(2)

excel转换后几列列宽被拉宽(2).zip (198.3 KB)

代码:
Workbook workbook = new Workbook(sourceFileName);

WorksheetCollection sheetCollection = workbook.getWorksheets();
int sheetCont = sheetCollection.getCount();
for(int i=0;i<sheetCont;i++){
    sheetCollection.get(i).autoFitColumns();
}

HtmlSaveOptions options = new HtmlSaveOptions();

options.setExportDocumentProperties(false);
options.setExportWorkbookProperties(false);
options.setExportWorksheetProperties(false);
options.setExportSimilarBorderStyle(true);
options.setExportImagesAsBase64(false);
options.setExcludeUnusedStyles(true);
options.setExportHiddenWorksheet(false);
options.setWidthScalable(false);
options.setPresentationPreference(true);

options.setHtmlCrossStringType(HtmlCrossType.CROSS_HIDE_RIGHT);
workbook.save(targetFileName, options);

@xiangma,
您可以在此处注释自动适应列的代码以避免此问题。

//for(int i=0;i<sheetCont;i++){
// sheetCollection.get(i).autoFitColumns();
//}