Free Support Forum - aspose.com

ChartDataTable never displays

Hello,

I can’t display chart data table. Here is my code :

	//Instantiating a Workbook object
	Workbook workbook = new Workbook();

	//Obtaining the reference of the first worksheet
	Worksheet worksheet = workbook.getWorksheets().get(0);

	//Adding a sample value to "A1" cell
	worksheet.getCells().get("A1").putValue(50);
	worksheet.getCells().get("A2").putValue(100);
	worksheet.getCells().get("A3").putValue(150);

	//Adding a sample value to "B1" cell
	worksheet.getCells().get("B1").putValue(60);
	worksheet.getCells().get("B2").putValue(32);
	worksheet.getCells().get("B3").putValue(50);

	//Adding a chart to the worksheet
	int chartIndex = worksheet.getCharts().add(ChartType.COLUMN, 5, 0, 25, 10);

	//Accessing the instance of the newly added chart
	Chart chart = worksheet.getCharts().get(chartIndex);

	//Adding NSeries (chart data source) to the chart ranging from "A1" cell to "B3"
	chart.getNSeries().add("A1:B3", true);

	chart.setShowDataTable(true);

	//Getting Chart Table
	ChartDataTable chartTable = chart.getChartDataTable();

	//Setting Chart Table Font Color
	chartTable.getFont().setColor(com.aspose.cells.Color.getRed());
	chartTable.setBackgroundMode(BackgroundMode.OPAQUE);
	//Setting Legend Key Visibility
	chartTable.setShowLegendKey(true);

	chartTable.setHasBorderHorizontal(true);
	chartTable.setHasBorderOutline(true);
	chartTable.setHasBorderVertical(true);
	
	
	// Save the Microsoft Excel file.
	workbook.save(dataDir + "MyBook.xls");

I tried other charts and settings - no way :disappointed:

Please, need help!

Thanks in advance and have a nice day

@miduha,

Please try our latest version/fix: Aspose.Cells for Java v18.6.4

I have tested your sample code using v18.6.4 and it works fine and chart’s data table is displayed fine, see the screenshot for your reference:

Thank you, but it still doesn’t work for me :

2018-07-06_08h13_14.png (46.6 KB)

I have another question (don’t know if I should open a new topic): I need to do a chart like this one :

2018-07-06_08h44_07.png (124.3 KB)

but I didn’t find how to make the parts of columns above the chart line (orange) to be also orange and to have a value of this difference on it. Is it possible to do?

@miduha,

Thanks for the screenshots.

  1. It looks like you are using OpenOffice to open the Excel file. Please use MS Excel as OpenOffice has limited set of features and chart’s data table won’t be shown in it.

  2. Please create your desired chart in MS Excel manually and save the file to provide us here, we will check on how to do it via Aspose.Cells APIs.

Amjad, thank you very much! :pray:
There is no problem with chart’s data table in MS Excel.
So I will create the second chart manually and send it to you

Have a nice weekend!

@miduha,

Good to know that chart’s data table is displayed fine in MS Excel.

Take your time to create your second chart and send the file to us.