Free Support Forum - aspose.com

Problem with Excel conversion to PDF data is not rendered properly

Hi

thanks for the update.

i used the latest file given by you and i am finding one more issue with my templates.

following are my problems:

1)not able to see the charts in excel when converted to pdf.
2)year is not coming correctly (see the higlighted)
3)getting exception if i try to use the pivot table refresh.


please provide me the root cause and fix ASAP.



thanks

i am attaching my sample code:

i am getting exception at highlighted line.

for(int k =0;k<ws.getPivotTables().getCount();k++){
System.out.println(“in start…1111… 2222222222222222222222222”);
ws.getPivotTables().get(k).setRefreshDataOnOpeningFile(true);
ws.getPivotTables().get(k).setRefreshDataFlag(true);
if(excelFileName.contains(“Extract”)){


}else{
ws.getPivotTables().get(k).refreshData();
}
try{
ws.getPivotTables().get(k).calculateData();
}catch(Exception e){
e.printStackTrace();
}
ws.getPivotTables().get(k).setRefreshDataFlag(false);
}
}

PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();

if(excelFileName.contains(“Current_Plan”)){
pdfSaveOptions.setCalculateFormula(true);
pdfSaveOptions.setOnePagePerSheet(true);
}

workbook.save(getPdfFileName(excelFileName), pdfSaveOptions);

Hi,


Thanks for the template files.

I have created a new thread for your newly mentioned issues.

3) I got the exception by using the following code, i.e.,
“Exception in thread “main” java.lang.ClassCastException: com.aspose.cells.gf cannot be cast to java.lang.Integer”

Sample code:

Workbook workbook = new Workbook("_RCCP_Report.xlsx");
workbook.calculateFormula(true);
int sheetCount = workbook.getWorksheets().getCount();

for (int i = 1; i < sheetCount; i++) {
Worksheet ws = workbook.getWorksheets().get(i);
ws.autoFitRows();

ws.getPageSetup().setFitToPagesWide(10);
ws.getPageSetup().setFitToPagesTall(1);
ws.getPageSetup().setPaperSize(40);
ws.getPageSetup().setOrientation(1);
ws.getPageSetup().setZoom(20);
ws.setGridlinesVisible(true);

System.out.println(ws.getCells().getMaxDataColumn());
ArrayList colsFromExcel1 = new ArrayList();
// if(excelFileName.contains(“Extract”)){



Row row1 = ws.getCells()
.getRow(0);
Iterator im1 = row1.iterator();
while (im1.hasNext()) {
Cell cell = (Cell) im1.next();
colsFromExcel1.add(cell.getStringValue());
}
System.out.println(“cols size after formatting:”
+ colsFromExcel1.size());
// }

for(int k =0;k<ws.getPivotTables().getCount();k++){
System.out.println(“in start…1111… 2222222222222222222222222”);
//ws.getPivotTables().get(k).setRefreshDataOnOpeningFile(true);
ws.getPivotTables().get(k).setRefreshDataFlag(true);
//if(excelFileName.contains(“Extract”)){


//}
//else{
ws.getPivotTables().get(k).refreshData();
//}


ws.getPivotTables().get(k).calculateData();
ws.getPivotTables().get(k).setRefreshDataFlag(false);
}




// if(excelFileName.contains(“Extract”)){
for (int v = 0; v < colsFromExcel1.size(); v++) {
ws.autoFitColumn(v);
ws.autoFitRows();

//if(v==0) continue;
if(ws.getCells().getRows().getRowByIndex(1).get(v).getDisplayStringValue()!=""){
System.out.println(ws.getCells()
.getRows().getRowByIndex(1).getCellByIndex(v)
.getType());


// Style style = null;
StyleFlag flagin = null;
flagin = new StyleFlag();
Style style = workbook.getWorksheets().get(i)
.getCells().getRows().getRowByIndex(1)
.getStyle();
style.setCustom("@");
flagin.setNumberFormat(true);
// sheet.Cells.ApplyColumnStyle(dateCol.Column,
// style, flag);
ws.getCells()
.getColumns().getColumnByIndex(v)
.applyStyle(style, flagin);




}

}



}

// }
workbook.save(“out_RCCP_Report.xlsx”);


//save the workbook as pdf report. Save pdf with same name
PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();

workbook.save(“out_RCCP_Report.pdf”, pdfSaveOptions);

I have logged a ticket with an id “CELLSJAVA-40458” for the issue. We will look into your issue soon.

For 1) and 2), I could not find the issue, could you be more specific which file you are using and attach screen shots to highlight the problematic areas (encircling with red color) comparing original Excel charts/labels (datetime) with output PDF (by Aspose.Cells), it will help us to trace the issue accurately and consequently we can log it into our database.

Thank you.

hi amjad

thanks for quick reply.

issue#1 : regarding charts.

if you observe the file s&op executive report in some sheets you will find the charts these are not visible in generated PDF.

issue#2: regarding date formats.

if you observe the file rccp_report i have highlighted a table in yellow color and if you closely observe the header of that in excel and pdf its totally wrong.


thanks


Hi,


For "issue#2: regarding date formats."

I have tested with our latest fix/version: Aspose.Cells for Java v7.4.1.2 it works fine. I do not find the issue regarding datetime labels in the charts. I have attached my output file that is generated by the sample code shared in my previous post.


Hi,


For "issue#1 : regarding charts"

I can see some issues in the rendered pages for charts. Could you be more specific and provide us some screen shots to highlight the problematic charts, also paste your sample code (runnable), it will help us to trace the issue more precisely. We will check it soon.

Also, kindly use our latest version/fix: Aspose.Cells for Java v7.4.1.2

hi please find the attached files for excel to pdf generation issue.

i am not able to see the charts in generated pdf.

Hi,


Thanks for providing us the template files.

Please follow up your other new thread you posted in the forums:
<a href="https://forum.aspose.com/t/93685

Thank you.