Chart filled transparent color trun to black

Hi,


I use aspose cells latest version. During convertion of charts to images, some charts behaves defferently. the area etwwen chart and its border automatically turns black from transparent.

Code:
Workbook workbook = new Workbook(sourcePath);

ImageOrPrintOptions imgOptions = new ImageOrPrintOptions();
imgOptions.setImageFormat(ImageFormat.getJpeg());
imgOptions.setOnePagePerSheet(true);

WorksheetCollection worksheetCollection = workbook.getWorksheets();
for (int i = 0; i < worksheetCollection.getCount() && i < previewCount; i++) {
List charts = getAllCharts(worksheetCollection.get(i));
for (Chart chart : charts) {
String imageFilePath = “D:\test” + new Random().nextInt(500) + “.jpeg”;
chart.toImage((imageFilePath), imgOptions);
}
}

Sample xlsx file is attahced with the post.

Hi,

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

We were able to observe this issue. The second chart transparent area becomes black in the output image. We have tested this issue with the following code. We have logged it in our database. We will look into it and fix this issue. Once, there is some fix or update for you, we will let you know asap.

This issue has been logged as CELLSJAVA-40622.

Java


String sourcePath = “F:\Shak-Data-RW\Downloads\test+2.xlsx”;


Workbook workbook = new Workbook(sourcePath);


ImageOrPrintOptions imgOptions = new ImageOrPrintOptions();

imgOptions.setImageFormat(ImageFormat.getJpeg());

imgOptions.setOnePagePerSheet(true);


Worksheet worksheet = workbook.getWorksheets().get(0);

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


chart.toImage(sourcePath + “1.out.jpg”, imgOptions);



Hi,

Thanks for using Aspose.Cells for Java.

As the background of the chart is no fill(Empty color), JPG image will look black. For this case, you must generate other format image, e.g. PNG or or change the background of the chart.

Java


if(chart.getChartArea().getArea().getFormatting() == FormattingType.NONE)

chart.getChartArea().getArea().setForegroundColor(Color.getWhite());


Thank for the response.


But this turns my backgroud color to white but I want it to trasparent and transprancy option is not working in this case.

Hi,


As we requested earlier, please use PNG image format type, your background would be rendered accordingly in the output image. See the sample code below for your reference:

Sample code:

String sourcePath = “test+2.xlsx”;


Workbook workbook = new Workbook(sourcePath);
ImageOrPrintOptions imgOptions = new ImageOrPrintOptions();

imgOptions.setImageFormat(ImageFormat.getPng());

imgOptions.setOnePagePerSheet(true);


Worksheet worksheet = workbook.getWorksheets().get(0);

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


chart.toImage(sourcePath + “.out1.png”, imgOptions);


Moreover, we recommend you to kindly use our latest fix/version: Aspose.Cells for Java v7.6.0 that we have released now.

Thank you.