// Create a new workbook Workbook workbook = new Workbook(); IWorksheet worksheet = workbook.getWorksheets().get(0); IShape shape = worksheet.getShapes().addChart(ChartType.ColumnClustered, 250, 20, 360, 230); worksheet.getRange("A1:D6").setValue(new Object[][]{ {null, "S1", "S2", "S3"}, {"Item1", 10, 25, 25}, {"Item2", -20, 36, 27}, {"Item3", 62, 70, -30}, {"Item4", 22, 65, 65}, {"Item5", 23, 50, 50} }); shape.getChart().getSeriesCollection().add(worksheet.getRange("A1:D6"), RowCol.Columns, true, true); //config chart title style with rich text shape.getChart().setHasTitle(true); shape.getChart().getChartTitle().getTextFrame().getTextRange().getParagraphs().add("ChartSubtitle"); shape.getChart().getChartTitle().getTextFrame().getTextRange().getParagraphs().add("ChartTitle", 0); shape.getChart().getChartTitle().getTextFrame().getTextRange().getParagraphs().get(0).getFont().getColor().setRGB(Color.GetCornflowerBlue()); shape.getChart().getChartTitle().getTextFrame().getTextRange().getParagraphs().get(0).getFont().setSize(15); shape.getChart().getChartTitle().getTextFrame().getTextRange().getParagraphs().get(1).getFont().getColor().setRGB(Color.GetOrange()); shape.getChart().getChartTitle().getTextFrame().getTextRange().getParagraphs().get(1).getFont().setSize(10); // Save to an excel file workbook.save("ConfigChartTitleRichText.xlsx");
// Create a new workbook var workbook = Workbook() val worksheet = workbook.worksheets.get(0) val shape = worksheet.shapes.addChart(ChartType.ColumnClustered, 250.0, 20.0, 360.0, 230.0) worksheet.getRange("A1:D6").value = arrayOf(arrayOf(null, "S1", "S2", "S3"), arrayOf("Item1", 10, 25, 25), arrayOf("Item2", -20, 36, 27), arrayOf("Item3", 62, 70, -30), arrayOf("Item4", 22, 65, 65), arrayOf("Item5", 23, 50, 50)) shape.chart.seriesCollection.add(worksheet.getRange("A1:D6"), RowCol.Columns, true, true) //config chart title style with rich text shape.chart.hasTitle = true shape.chart.chartTitle.textFrame.textRange.paragraphs.add("ChartSubtitle") shape.chart.chartTitle.textFrame.textRange.paragraphs.add("ChartTitle", 0) shape.chart.chartTitle.textFrame.textRange.paragraphs.get(0).font.color.rgb = Color.GetCornflowerBlue() shape.chart.chartTitle.textFrame.textRange.paragraphs.get(0).font.size = 15.0 shape.chart.chartTitle.textFrame.textRange.paragraphs.get(1).font.color.rgb = Color.GetOrange() shape.chart.chartTitle.textFrame.textRange.paragraphs.get(1).font.size = 10.0 // Save to an excel file workbook.save("ConfigChartTitleRichText.xlsx")