I learned that I can search the title text of a chart appears in a word file, with the code as follows. dummychart.docx.zip (19.8 KB)
Document doc = new Document("dummychart.docx");
foreach (Section section in doc.Sections)
{
foreach (var node in section.Body)
{
if ( ((Node)node).NodeType == NodeType.Paragraph )
{
foreach ( var nodeInPara in ((Paragraph)node).ChildNodes )
{
if (((Node)nodeInPara).NodeType == NodeType.Shape)
{
if(((Shape)nodeInPara).HasChart)
{
Consle.WriteLine(((Shape)nodeInPara).Chart.Title.Text);
}
}
}
}
}
}
I was expecting it to be “グラフ タイトル” as you can see capture.png (35.1 KB) just as predetermined default value.
But in fact Chart.Title.Text property returned “”;
Once I modified very the same string on word and save it, then the same code prints the modified string.
Is there any way I can get the default value?
Thanks for your inquiry. We have tested the scenario and have managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as WORDSNET-17271. You will be notified via this forum thread once this issue is resolved.
Thank you for your reply.
If it is a bug you can easily reproduce the same situation on Excel and PowerPoint, too.
Not the very same code snippet of course, but with the similar functionality accessing the stuff like Chart.Title.Text respectively for each application.
Sorry that I did not complete the investigation when I open this topic, however, I’d need to add one more question related to this topic.
Do I have an access to “category” property from somewhere relevant to Shape.Chart property mentioned above?
I can touch “title” of the chart ( only if it is modified ).
I can touch “series” of the chart.
How about “categories” ?
Finally I aim to detect all the text property ( including ones not always explicitly visible, such as, AlternativeText ) contained in the chart, then replace them according to a certain manner. I am keep reading the documents and codes to achieve it. Your help will be truly welcomed.
Workbook workbook = new Workbook("e:\\test2\\dummychart.xlsx");
Worksheet worksheet = workbook.Worksheets[0];
Chart chart = worksheet.Charts[0];
chart.Calculate();
string title1Text = chart.Title.Text; //グラフタイトル - Ok
Chart chart1 = worksheet.Charts[1];
chart1.Calculate();
string title2Text = chart1.Title.Text;//Chart Title - Ok
Unfortunately, Aspose.Words does not support the requested feature at the moment. However, we have logged this feature request as WORDSNET-17277 in our issue tracking system. You will be notified via this forum thread once this feature is available.
Thank you. I could improve my code for Excel.
But chart.ChartTitle.TextFrameForOverriding is null when you load dummychart.pptx I sent.
Would you double check this?
I regret that Aspose.Words doesn’t support some operations on some elements in Word.
Thanks for your inquiry. The TextFrameForOverriding is used when chart title is defined by user. If the chart title is automatic (usually it is appears as “Chart Title”) - chart doesn’t store this value in the document.
If the chart title is overridden by user, you can get it using ChartTitle.TextFrameForOverriding.Text property. Otherwise, it returns null. Please use following line of code to get the correct output.
Thank you for your suggestion. Now I understand that.
I would go with a list of the default strings in target languages presumably applicable for the users’ input Word file, choosing the one fits in the place of “Chart Tiltle”.