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,
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);
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,
Hi,
hi please find the attached files for excel to pdf generation issue.
i am not able to see the charts in generated pdf.
Hi,