Pdf conversiion throwing error-XMLStreamException: Unexpected end of input block in start tag

Hi

I analyzed the pivot issue a bit with latest version of aspose.

i am attaching the files:

1) Source excel file
2) PDF generated by manually saving the excel to pdf.
3) PDf generated by using ASPOSE.

i hope you can test the issue using these files. In the PDF generated by manually saving the excel to pdf every thing is good but in PDF generated using ASPOSE some data is missing (or wrongly generated).


Thanks

Hi,


Please find attached the output file using the code below with the latest version/fix v7.5.0.3.

Sample code:

String filePath=“Current_Plan_Report_WITHDATA.xlsx”;
Workbook workbook = new Workbook(filePath);
workbook.save(“outCurrent_Plan_Report_WITHDATA.pdf”,SaveFormat.PDF);



It looks like it works fine as per input Excel file.

Do you refresh the data and pivot table in your code, could you paste your code here, we will check it futher and precisely.


Thanks,

Thanks for the reply.

i am following below process to convert a excel file to PDF. I am refreshing the pivot tables in sheet because the data will come from another sheet (same workbook).

Step1: refresh the excel pivot tables and save the file with same name.
public static void refreshExcel(String excelFileName) {
try{
System.out.println(“11111”);
System.out.println(“before refresh call :” + excelFileName);

License license = new License();
String licenseFilePath =“D:\Aspose.Cells.lic”;
license.setLicense(licenseFilePath);



Workbook workbook = new Workbook(excelFileName);


workbook.calculateFormula(true);
int sheetCount = workbook.getWorksheets().getCount();
System.out.println(“sheet count…” + sheetCount);
for (int i = 0; i < sheetCount; i++) {
Worksheet ws = workbook.getWorksheets().get(i);
System.out.println(“worksheet name :”+ws.getName());
for (int k = 0; k < ws.getPivotTables().getCount(); k++) {
System.out.println(“in start…” + k);
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 el) {
el.printStackTrace();

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

}

}

workbook.getSettings().setEncoding(Encoding.getUTF8());
workbook.save(excelFileName);




}catch(Exception e){
e.printStackTrace();
}



System.out.println(“after refresh call :” + excelFileName);
}


Step2: Use the refreshed excel and generate the PDF.

public static boolean generatePdfReport3(String excelFileName) {
try {

Workbook workbook = new Workbook(excelFileName);
int sheetCount = workbook.getWorksheets().getCount();

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


ArrayList colsFromExcel1 = new ArrayList();


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 v = 0; v < colsFromExcel1.size(); v++) {
ws.autoFitColumn(v);
// ws.autoFitRows();
// if(v==0) continue;
System.out.println(“total count of rows:”+ws.getCells().getRows().getCount());
if(ws.getCells().getRows().getCount()==1 || ws.getCells().getRows().getCount()==0){
if(ws.getCells().getRows().getRowByIndex(0).get(v).getDisplayStringValue()!=""){
System.out.println(ws.getCells()
.getRows().getRowByIndex(0).getCellByIndex(v)
.getType());


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




}

}else{

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(getPdfFileName(excelFileName));

} catch (Exception ex) {
System.out.println(“pdf exception:” + StackTraceUtil.getStackTrace(ex));
return false;
}
return true;
}

Hi,


Thanks for providing us your code snippets.

I have logged it against your issue id “CELLSJAVA-40555” into our database, it may help us to investigate your issue accurately. Our concerned developer will look into it soon.

Once we figure it out or we have any update on it, we will let you know here.

Thank you.

Hi

is there any ETA for this? Please provide if there is any ETA so that we can plan accordingly.


Thanks

Hi,

Please try the latest version/fix: Aspose.Cells for Java v7.5.0.5. It should fix your issue now.

Let us know your feedback.

Thank you.

The issues you have found earlier (filed as CELLSJAVA-40552;CELLSJAVA-40540;CELLSJAVA-40555) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.

Hi

Thanks for the update.

i used the latest version of jar and found one issue while generating the pdf.


i am not getting the charts in the sheet and highlighted portion(yellow color) in excel are not getting generated properly in pdf.

refresh the _current_plan_report_original.xlsx (current plan report) sheet manually by right clicking and click on refresh data command to see the actual data.

i am attaching the files for reference.


sample code:

public static void savePDF(String filename){

try {
Workbook workbook = new Workbook(filename);

workbook.calculateFormula(true);
int sheetCount = workbook.getWorksheets().getCount();
System.out.println(“sheet count…” + sheetCount);
for (int i = 0; i < sheetCount; i++) {
Worksheet ws = workbook.getWorksheets().get(i);
System.out.println(“worksheet name :”+ws.getName());
for (int k = 0; k < ws.getPivotTables().getCount(); k++) {
System.out.println(“in start…” + k);
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 el) {
el.printStackTrace();

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

}

}

workbook.save(getPdfFileName(filename)) ;
} catch (Exception e) {
// TODO Auto-generated catch block


}
}







thanks

Hi,


Thanks for the template files.

I have noticed the issue as the chart is not rendering fine in the generated PDF. For data I am not sure if it is properly refreshed in the pivot table or not because I cannot find any difference apparently. I have logged a ticket with an id “CELLSJAVA-40568” for your issue. We will look into your issue soon.

Once we have an update on it, we will let you know here.

Thank you.


thanks for the update.

please find the attached template . the values jan-00 (repeated in yellow color) is being generated after refreshing the pivot tables but in the actual excel there are different values (see the orginal file attached previously by refreshing it manually) .


if i save the excel file after refreshing pivot tables manually and generate pdf i am getting values properly.

Hi,


Thanks for providing us further details.

We have logged your details against your issue “CELLSJAVA-40568” into our database. Our concerned developer will also look into it.

Thank you.

Hi

Please provide the ETA for this defect. As i informed you earlier this is a critical issue from our client.



Thanks

Hi,


I have logged your comments against your issue “CELLSJAVA-40568”. I have also asked the concerned developer to provide an eta for it if possible. Once we have any update on it, we will let you know here.

Thank you.

Hi,

Thanks for using Aspose.Cells.

It is to update you that we will try to fix this issue in next java version about 2-3 working days
later. Once, the fix is available, we will share it with you asap.

Hi,

Thanks for your posting and using Aspose.Cells for Java.

Please download and try this fix: Aspose.Cells for Java v7.5.1.2.

Please add this sample code before saving:


Java
book.calculateFormula();


Thanks for the quick reply. I will test our app with latest fix and let you know if i face any issue.


Thanks

Hi

i tested my reports with latest fix adding code snipet given by you. charts are coming up now in excel after refreshing the pivot tables, But i have one problem

1) if i refresh my excel manually by right clicking on table >refresh option

i am able to see the data and period buckets correctly.

(apr-13,may-13…) see the template attached _Current_Plan_Report_venu_manual refresh.xslx

2)if i refresh the same report with aspose code i am not able to see the period bucket values and data correctly.

see the template attached _Current_Plan_Report_venu_afterrefreshpivot.xslx

(highlighted in purple color are wrong period buckets jan-00,jan-00…
highlighted data in yellow color is wrong…)

code:

Workbook workbook = new Workbook(excelFileName);


workbook.calculateFormula(true);
int sheetCount = workbook.getWorksheets().getCount();
System.out.println(“sheet count…” + sheetCount);
for (int i = 0; i < sheetCount; i++) {
Worksheet ws = workbook.getWorksheets().get(i);
System.out.println(“worksheet name :”+ws.getName());
for (int k = 0; k < ws.getPivotTables().getCount(); k++) {
System.out.println(“in start…” + k);

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 el) {
el.printStackTrace();

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

}
}


// workbook.getSettings().setEncoding(Encoding.getUTF8());
workbook.calculateFormula();
workbook.save(excelFileName);




please look into this issue as soon as possible.



Thanks



Hi

Any analysis on this issue?



Thanks

Hi,

Thanks for your posting and using Aspose.Cells for Java.

We were able to observe this issue using your sample code with the latest version. Results are different when pivot table is refreshed manually and with aspose.cells. We have logged this issue in our database for investigation. We will look into it and fix this issue. Once, the issue is resolved or we have some other update for you, we will let you know asap.

This issue has been logged as CELLSJAVA-40576.

If you face any other issue, please create new thread for your separate issues. It will help us sort out your issue easily.

Thanks for your update. If i get any new issue i will start a new thread.