I tested the following adjusted code and it works fine with our latest version/fix v7.0.0.3 (attached).
import java.io.File;
import com.aspose.cells.Cell;
import com.aspose.cells.Cells;
import com.aspose.cells.Chart;
import com.aspose.cells.ChartCollection;
import com.aspose.cells.ChartPoint;
import com.aspose.cells.ChartType;
import com.aspose.cells.Color;
import com.aspose.cells.FormattingType;
import com.aspose.cells.Series;
import com.aspose.cells.SeriesCollection;
import com.aspose.cells.Style;
import com.aspose.cells.Workbook;
import com.aspose.cells.Worksheet;
import com.aspose.cells.WorksheetCollection;
public class CreateChartTest
{
public static void main(String[] args) throws Exception
{
// Instantiating a Workbook object
Workbook workbook = new Workbook();
Chart chart = createChart(workbook);
SeriesCollection nSeries = chart.getNSeries();
nSeries.add(“B2:E4”, true);
nSeries.setCategoryData(“A2:A4”);
nSeries.get(0).setName("=B1");
nSeries.get(1).setName("=C1");
nSeries.get(2).setName("=D1");
Series series = nSeries.get(3);
series.setName("=E1");
series.getArea().setTransparency(1d);
ChartPoint chartPoint = series.getPoints().get(1);
chartPoint.getDataLabels().setShowValue(true);
chartPoint.getArea().setForegroundColor(Color.getCyan());
chartPoint.getBorder().setVisible(false);
chartPoint.getArea().setTransparency(1d);
chartPoint.getArea().setFormatting(FormattingType.NONE);
chart.getPlotArea().getArea().setForegroundColor(Color.getOrange());
chart.getChartArea().getArea().setForegroundColor(Color.getYellow());
System.out.println(“area transparency: " + series.getArea().getTransparency());
System.out.println(“chartpoint transparency: " + chartPoint.getArea().getTransparency());
chart.toImage(“outmytestingimg.jpg”);
saveFile(workbook);
}
private static void saveFile(final Workbook workbook) throws Exception
{
// Saving the Excel file
//File dir = new File(“target/test/others/”);
// dir.mkdirs();
// String absolutePath = new File(dir, “test.xls”).getAbsolutePath();
workbook.save(“outmytesting.xls”);
//return absolutePath;
}
private static Chart createChart(final Workbook workbook) throws Exception
{
// Obtaining the reference of the first worksheet
WorksheetCollection worksheets = workbook.getWorksheets();
Worksheet sheet = worksheets.get(0);
// Adding some sample value to cells
Cells cells = sheet.getCells();
cells.importArray(new double[][] {
//
{ 1, 2, 3, 4 },// 1
{ 2, 3, 4, 0.5 },// 2
{ 3, 4, 5, 6 }// 3
, }, 1,// row
1// col
);
// set category labels
cells.importArray(new String[][] { { “category 1” }, { “category 2” }, { “category 3” } }, 1, 0);
// set column labels
cells.importArray(new String[][] { { “hans”, “sepp”, “rupert”, “michl” } }, 0, 1);
ChartCollection charts = sheet.getCharts();
// Adding a chart to the worksheet
int chartIndex = charts.add(ChartType.COLUMN, 5, 0, 15, 5);
Chart chart = charts.get(chartIndex);
// TEST PERCENTAGE FORMATTING
addPercentageCell(workbook, cells);
return chart;
}
private static void addPercentageCell(final Workbook workbook, final Cells cells)
{
Cell e3 = cells.get(“E3”);
e3.setValue(0.05d);
Style style = workbook.createStyle();
style.setCustom(”#,##0.00%”);
e3.setStyle(style);
}
}
I have also attached the output Excel file and output image file for the chart.
Thank you.