Draw stylish Charts in Excel

Currently Aspose provides of a bunch of different chartTypes, I have tried using most of them to draw my pie chart and a bar graph. However not getting a feel.

I would like to know if its possible to draw a custom image chart with custom colors. Or is there any other option where in I can use some stylish Charts.


If you want to create native Excel chart with customized colors, pattern fills or gradient fills, you may do it using Aspose.Cells for Java API, see the topics in the section/sub-sections for your reference:

I will also write an example here for your reference, in the example, I have set some gradient fills/styles for different slices of a PIE Chart.

Sample code:
String[] cellsName = new String[] { “B2”,“C2”,“D2”,“E2”,“F2”,“G2”,“H2”,“I2”,“J2”,

//Array of cell data
double[] cellsValue = new double[] {7.027279E7,1744253.0,1473.0,395085.7,7.019342E7,17.0,1111239.0,0.0,5.218978E7,

Workbook wb = new Workbook();

Worksheet dataSheet = wb.getWorksheets().getSheet(0);
String dataSheetName = “DataSheet”;

dataSheet.getCells().getCell(“A2”).setValue(“Unit Sales”);
dataSheet.getCells().getCell(“A3”).setValue(“Value Sales”);
dataSheet.getCells().getCell(“A4”).setValue(“Volume Sales”);
dataSheet.getCells().getCell(“B1”).setValue(“BrandA Rinse Conditioners”);
dataSheet.getCells().getCell(“C1”).setValue(“BrandB Ltd Rinse Conditioners”);
dataSheet.getCells().getCell(“D1”).setValue(“BrandC Rinse Conditioners”);
dataSheet.getCells().getCell(“E1”).setValue(“BrandD Rinse Conditioners”);
dataSheet.getCells().getCell(“F1”).setValue(“BrandE Rinse Conditioners”);
dataSheet.getCells().getCell(“G1”).setValue(“BrandF Rinse Conditioners”);
dataSheet.getCells().getCell(“H1”).setValue(“BrandG Rinse Conditioners”);
dataSheet.getCells().getCell(“I1”).setValue(“BrandH Rinse Conditioners”);
dataSheet.getCells().getCell(“J1”).setValue(“BrandJ Rinse Conditioners”);

//Populate DataSheet with data
int size = Array.getLength(cellsName);
for (int i = 0; i < size; i++) {
String cellName = cellsName[i];
double cellValue = cellsValue[i];

//Add a chart sheet
Worksheet chartSheet = wb.getWorksheets().addSheet();
int chartSheetIdx = chartSheet.getIndex();

//Add a chart in ChartSheet with data series from DataSheet
int chartWidth = 300;
int chartHeight = 300;

int chartHeightInRows = 0;
int chartWidthInCols = 0;
int cellWidth = dataSheet.getCells().getColumnWidthPixel(0);
int cellHeight = dataSheet.getCells().getRowHeightPixel(0);
chartWidthInCols = (int)(chartWidth / cellWidth);
chartHeightInRows = (int)(chartHeight / cellHeight);
chartWidth = chartWidthInCols * cellWidth;
chartHeight = chartHeightInRows * cellHeight;

int chartStartRow = 0;
int chartStartColumn = 0;
int chartLeft = 0;
int chartTop = 0;

Chart chart = chartSheet.getCharts().addChart(ChartType.PIE, chartStartRow, chartStartColumn, chartLeft, chartTop, chartWidth, chartHeight);
chart.getNSeries().add(dataSheetName + “!B2:J2”, false);

//String categoryAreaRef = dataSheet.getName() + “!A2:A4”;
String categoryAreaRef = dataSheet.getName() + “!B1:J1”;

String chartTitle = dataSheet.getCells().getCell(“A2”).getValue().toString();

for (int j = 0; j < chart.getNSeries().size(); j++) {
ASeries series = chart.getNSeries().get(j);
ChartPoints chartPoints = series.getChartPoints();
for (int k = 0; k < chartPoints.size(); k++) {
ChartPoint chartPoint = chartPoints.getChartPoint(k);
GradientFill gf = new GradientFill();
gf.setColor2(wb.getPalette().getColor(k +1 * 2));



wb.save(new FileOutputStream(“D:\files\pie_tst_chart.xls”));

And, if you need to take the image of the chart, see the document:

And, if you need to create non-Excel charts yet sophisticated stylish charts and you need to take the image for the chart, you may use Aspose.Report for Java product, see some demos e.g.:

Here is an article:
If you need further help or info regarding Aspose.Report for Java, please do post a query in their forum, they will help you soon.

Thank you.