Hi, I am converting an excel to pdf and observed that the data contained into excel cells not fully converted instead few letters. I have enclosed both the files and below is code snippet i used. Please help to resolve this issue.
// set aspose license
setAsposeExcelLicense();
Workbook excelWb = new Workbook(destExcelPath.toFile().getAbsolutePath());
addEmptyRowsForLogoAndFilters(excelWb,
OutputUtils.getColumnHeaders(submitHeader.getColumnProperties()).length, showFilters,
filtersSheetName);
StyleFlag flag = new StyleFlag();
flag.setWrapText(true);
PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();
if (pdfPageOrientation == PageOrientationType.LANDSCAPE)
pdfSaveOptions.setAllColumnsInOnePagePerSheet(true);
// prepare excel for pdf conversion
int visibleIndex = 1;
int filesIndex = 0;
if (null != additionalDetails && Boolean.FALSE.equals(additionalDetails.getShowDataSheet())) {
visibleIndex = 2;
filesIndex = 1;
}
int sheetCount = excelWb.getWorksheets().getCount();
for (; visibleIndex < sheetCount; visibleIndex++) {
excelWb.getWorksheets().get(visibleIndex).setVisible(false);
}
// generate pdf's of each sheet
List<String> pdfFiles = new ArrayList<>();
for (; filesIndex < sheetCount; filesIndex++) {
Worksheet sheet = excelWb.getWorksheets().get(filesIndex);
if (!sheet.getName().startsWith(filtersSheetName)) {
String pdfFileName = outputFolderPath + reportName + "-" + sheet.getName().replace(" ", "-")
+ ".pdf";
pdfFiles.add(pdfFileName);
if (!Files.exists(Paths.get(pdfFileName))) {
if (sheet.getPivotTables().getCount() > 0) {
sheet.refreshPivotTables();
for (int j = 0; j < sheet.getPivotTables().getCount(); j++) {
CellArea area = sheet.getPivotTables().get(j).getTableRange2();
Range range = sheet.getCells().createRange(area.StartRow, area.StartColumn,
area.EndRow - area.StartRow + 1, area.EndColumn - area.StartColumn + 1);
range.setOutlineBorders(CellBorderType.THIN, com.aspose.cells.Color.getBlack());
}
}
sheet.getPageSetup().setOrientation(pdfPageOrientation);
sheet.autoFitRows();
sheet.getPageSetup().setFitToPagesWide(filesIndex);
sheet.getPageSetup().setFitToPagesTall(0);
for (int colCount = 0; colCount < sheet.getCells().getColumns().getCount(); colCount++) {
Column col = sheet.getCells().getColumns().get(colCount);
Style columnStyle = col.getStyle();
columnStyle.setTextWrapped(true);
col.applyStyle(columnStyle, flag);
}
excelWb.calculateFormula(true);
excelWb.save(pdfFileName, pdfSaveOptions);
pdfOutputGeneratorHelper.addLogoAndFilters(pdfFileName, title, requestedDate, showFilters,
reportFilters, font);
}
if (filesIndex < sheetCount - 1) {
excelWb.getWorksheets().get(filesIndex + 1).setVisible(true);
excelWb.getWorksheets().get(filesIndex).setVisible(false);
}
}
}