Hi,
Hi Pierre,
Hi Mudassir,
I am trying to draw a ChartEx and edit it’s Category Axis labels.
To do that in PPT, you have to insert a Chart, Select the Chart -> Design Tab (in Chart Tools section) -> Select Data (this opens the embedded excel worksheet of the chart) -> from the Popup Window that appears -> Click Edit from the left column right under Horizontal (Category) Axis Labels text.
This allows you to select the cell range inside the embedded worksheet from which the category axis will be reading its label values.
Here’s a link for a screenshot that elaborates how this can be done following the above steps:
https://dl.dropbox.com/u/4244333/Functionality.png
I want to do that programmatically in Aspose using C#, but am not able to find any reference to the actual Axis Data Range (excel cells) of the Category Axis.
I hope this sounds a bit clearer.
Thank you!
Pierre
Hi Pierre,
public static void ChangeChartCategory(){String path=@"D:\Aspose Data";PresentationEx pres = new PresentationEx(path + “SampleChart2.pptx”);SlideEx slide = pres.Slides[0];ChartEx chart = (ChartEx)slide.Shapes[0];ChartDataEx chData = chart.ChartData;//First Way/* chData.Categories[0].ChartDataCell.Value = “Cat 1”;*/chData.Categories[1].ChartDataCell.Value = “Cat 2”;chData.Categories[2].ChartDataCell.Value = “Cat 3”;chData.Categories[3].ChartDataCell.Value = “Cat 4”;//Second Way//Setting the index of chart data sheetint defaultWorksheetIndex = 0;//Getting the chart data worksheetChartDataCellFactory fact = chart.ChartData.ChartDataCellFactory;int Cat1Row = chart.ChartData.Categories[0].ChartDataCell.Row;int Cat1Col = chart.ChartData.Categories[0].ChartDataCell.Column;//Changing chart Category Namefact.GetCell(defaultWorksheetIndex, Cat1Row, Cat1Col, “Modified Category 1”);pres.Write(@“D:\Aspose Data\SampleChart_Modified.pptx”);}
Hi Mudassir,
Hi Pierre,
Hi Mudassir,
Thank you answering about another concern I had in mind. Actually I wanted to merge 2 cells together, and I am able to do that myself manually using PPT. You can check this link for a screenshot:
https://dl.dropbox.com/u/4244333/Merge.PNG
I’m not sure why it is doable from my side and not from your side, probably because I am personally plotting the chart programmatically.
My previous question was concerning a selection of 2 columns for the Data Range of the Category Axis Labels, you can check another screenshot (https://dl.dropbox.com/u/4244333/Select2Columns.PNG
) for this attempt, this is easily done in PPT by following the steps I mentioned above and selecting a range of 2 columns for the Category Axis Labels instead of a single column.
Let me know if anything is unclear.
Thank you!
Pierre
Hi Pierre,
public static void ChangeChartCategory(){String path=@“D:\Aspose Data”;PresentationEx pres = new PresentationEx(path + “SampleChart2.pptx”);SlideEx slide = pres.Slides[0];ChartEx chart = (ChartEx)slide.Shapes[0];ChartDataEx chData = chart.ChartData;//First Way/* chData.Categories[0].ChartDataCell.Value = “Cat 1”;*/chData.Categories[1].ChartDataCell.Value = “Cat 2”;chData.Categories[2].ChartDataCell.Value = “Cat 3”;chData.Categories[3].ChartDataCell.Value = “Cat 4”;//Second Way//Setting the index of chart data sheetint defaultWorksheetIndex = 0;//Getting the chart data worksheetChartDataCellFactory fact = chart.ChartData.ChartDataCellFactory;int Cat1Row = chart.ChartData.Categories[0].ChartDataCell.Row;int Cat1Col = chart.ChartData.Categories[0].ChartDataCell.Column;//Changing chart Category Namefact.GetCell(defaultWorksheetIndex, Cat1Row, Cat1Col, “Modified Category 1”);//Logic for merging category labelsMemoryStream mem = chart.ChartData.ReadWorkbookStream();mem.Position = 0;Workbook wb = new Workbook(mem);Worksheet work = wb.Worksheets[0];work.Cells.Merge(Cat1Row, Cat1Col, 2, 1);MemoryStream ms2 = new MemoryStream();wb.Save(ms2, SaveFormat.Auto);ms2.Position = 0;chart.ChartData.WriteWorkbookStream(ms2);pres.Write(@“D:\Aspose Data\SampleChart_Modified.pptx”);}
Hi Mudassir,
Hi Pierre,
The issues you have found earlier (filed as SLIDESNET-33982) have been fixed in this update.
This message was posted using Notification2Forum from Downloads module by Aspose Notifier.
(5)