We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How to Set X_Values to a Line Series

Dear Team,

I have a requirement where we need to set x_values (position of data point) to a line series same like how we do for a scatter chart. (chart.getNSeries().get(index).setXValues(cellName))
I could able to get it manually in excel but unable to do by code. Attaching the sample excel for your reference.X_VALUES.zip (168.3 KB)

Could you please help me in achieving this.

Yasaswini Challa


Thanks for using Aspose APIs.

Please see the following sample code, its sample input and output Excel files as well as screenshot for your help. Please also read the comments inside the code. It should help you fix your issue. Let us know your feedback.

Download Link:
Input and Output Excel files.zip (20.4 KB)


Workbook wb = new Workbook(dirPath + "LC.xlsx");

Worksheet ws = wb.getWorksheets().get(0);

Chart ch = ws.getCharts().get(0);

Series s = ch.getNSeries().get(0);

//Proper way

//But this will also work

wb.save(dirPath + "output.xlsx");


Thank you Shakeel, it works!!


Good to know that the suggested code figures out your issue now. Feel free to contact us any time if you need further help or have some other issue or queries, we will be happy to assist you soon.

Hi Amjad,

Can you please help me to get the same functionality as you mentioned above, to set custom category axis labels to a scatter chart (SCATTER_CONNECTED_BY_LINES_WITHOUT_DATA_MARKER).

Thanks in advance for your early response.

Yasaswini Challa


Please create your desired chart (SCATTER_CONNECTED_BY_LINES_WITHOUT_DATA_MARKER) with custom category axis in MS Excel manually and save the file to provide us here, we will check and guide you on how to do it via Aspose.Cells APIs.