Label incorrect on image export from chart

Hi

when i convert my chart to image the label is not displaying the data properly. in excel chart it is working properly. bellow is my code. and i have attached my excel file and image file as well.
when i set the pivotTable.setColumnGrand(true), it works fine.

I’m using the last version of aspose cells 8.4.0

Thanks.


final Workbook workbook = new Workbook();
final Worksheet sheet = workbook.getWorksheets().get(0);
sheet.setName(“Data”);
final Cells cells = sheet.getCells();
Cell cell = cells.get(“A1”);
cell.setValue(“Types “);
cell = cells.get(“A2”);
cell.setValue(“Type 1”);
cell = cells.get(“A3”);
cell.setValue(“Type 2”);
cell = cells.get(“A4”);
cell.setValue(“Type 3”);
cell = cells.get(“A5”);
cell.setValue(“Type 4”);
cell = cells.get(“A6”);
cell.setValue(“Type 5”);
int sheetIndex = workbook.getWorksheets().add();
final Worksheet sheet2 = workbook.getWorksheets().get(sheetIndex);
sheet2.setName(“PivotTable”);
final PivotTableCollection pivotTables = sheet2.getPivotTables();
final int index = pivotTables.add(”=Data!A1:A6”, “B3”, “PivotTable1”);
final PivotTable pivotTable = pivotTables.get(index);
pivotTable.setRowGrand(false);
pivotTable.setColumnGrand(false);
pivotTable.setAutoFormat(true);
pivotTable.setAutoFormatType(PivotTableAutoFormatType.REPORT_6);
pivotTable.addFieldToArea(PivotFieldType.ROW, 0);
pivotTable.addFieldToArea(PivotFieldType.DATA, 0);
pivotTable.getDataFields().get(0).setNumber(7);
sheetIndex = workbook.getWorksheets().add(SheetType.CHART);
final Worksheet sheet3 = workbook.getWorksheets().get(sheetIndex);
sheet3.setName(“PivotChart”);
final int chartIndex = sheet3.getCharts().add(ChartType.PIE, 0, 5, 28,
16);
final Chart chart = sheet3.getCharts().get(chartIndex);
chart.setPivotSource(“PivotTable!PivotTable1”);
chart.setHidePivotFieldButtons(true);
final ImageOrPrintOptions imageOptions = new ImageOrPrintOptions();
imageOptions.setImageFormat(ImageFormat.getPng());
chart.toImage(new FileOutputStream(“c:\2\pivotChartImage.png”),
imageOptions);
workbook.save(“c:\2\pivotTable.xls”);


Hi,

Thanks for your posting and using Aspose.Cells.

Please download and use the latest version: Aspose.Cells
for Java v8.4.0.7
.

Please call Chart.refreshPivotData() before taking the image of the chart.

We have tested this issue with the following sample code using the latest version and it generated the correct chart. I have attached the output chart image for your reference.

Java


String filePath = “F:\Shak-Data-RW\Downloads\pivotTable.xls”;


Workbook workbook = new Workbook(filePath);


Worksheet worksheet = workbook.getWorksheets().get(“PivotChart”);


Chart chart = worksheet.getCharts().get(0);

chart.refreshPivotData();


chart.toImage(“output.jpg”);


I downloaded Aspose.Cells for Java v8.4.0.7. and everything works fine.
But the legend of the chart, I wanna show “Type 1”, “Type 2”, “Type 3”, “Type 4” and “Type 5”, and not “Count of Types” like in the image, but like the chart in the pivotTable.xls

Hi,

Thanks for your feedback and using Aspose.Cells.

We were able to observe this issue after running your sample code with the latest version and found that pivot chart image is different than xls pivot chart.

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-41273 - Pivot Chart image shows Count of Types instead of Types

I have also attached the screenshot that highlights this issue for a reference.

Hi Shakeel! Any update on this issue?


Thanks

Hi,

Thanks for your posting and using Aspose.Cells.

We are afraid, there is no update for you at this moment regarding this issue. However, we have logged your comment in our database against this issue and requested the product team to provide some ETA or fix for this issue. Once, we will have some update for you, we will let you know asap.

Hi,

Thanks for your posting and using Aspose.Cells.

We are afraid your issue is yet unresolved. However, we have logged your comment in our database against this issue and requested the product team to provide some ETA for this issue. Once there is some news for you, we will let you know asap.

@camillo.rezende,
Please try our latest version/fix: Aspose.Cells for .NET v21.6.3 (attached)
Aspose.Cells21.6.3 For .Net2_AuthenticodeSigned.Zip (5.5 MB)
Aspose.Cells21.6.3 For .Net4.0.Zip (5.5 MB)
Aspose.Cells21.6.3 For .NetStandard20.Zip (5.5 MB)

Your issue should be fixed in it.
Let us know your feedback.