Hello,
I want to load document(.docx) and replace some content,
here is code:
RadFlowDocument document;
using (Stream input = System.IO.File.OpenRead(templatePath))
{
document = provider.Import(input);
}
RadFlowDocumentEditor editor = new RadFlowDocumentEditor(document);
1. Replace text: I use :
editor.ReplaceText("#Name#", "AAAAAAA");
4 Answers, 1 is accepted
I use
IEnumerable<Table> tables = editor.Document.EnumerateChildrenOfType<Table>();
foreach (var table in tables)
{
//find table caption="XX"
//do domething
}
now I have problem,how can i find the table caption?
like this link:
https://docs.telerik.com/devtools/aspnet-ajax/controls/editor/functionality/dialogs/table-wizard
3. How can I find and replace text like #Chart# to a Chart?
Hi,
Thank you for your interest in Telerik Document Processing.
If I am understanding correctly the scenario, you would like to find a caption of a table and modify its content, am I right? When a caption is added to a table, the caption content may be represented as a Paragraph element with a Caption style. In order to achieve the desired result, after the document is imported using the WordsProcessing library, you can iterate the Paragraph elements with a Caption style id and manipulate their content, for example:
foreach (var paragraph in document.EnumerateChildrenOfType<Paragraph>().Where(p => p.StyleId == "Caption"))
{
paragraph.Inlines.AddRun(" modified");
}
Regarding the replacement of text content with a chart, I am afraid that with the current implementation of the library charts are not supported. We have logged a feature request in our feedback portal: Add possibility to work with charts in a flow document, where you can vote to increase its priority and subscribe to be notified when the status of the item changes. I am sorry that I couldn't find any workaround to provide you with.
Regards,
Georgi
Progress Telerik
Because there are many table in the word template and table order maybe change by user,
so I want to find an attribute to determine which table it is.
I use:
document.EnumerateChildrenOfType<Paragraph>().Where(p => p.StyleId == "Caption")
but it not found, hope there is an easier way to find the table, like this:
document.Tables.FirstOrDefault(t => t.TableCaption == "Target_Table");//Reference DocX
Regarding point 3, I will think of other ways,
Thanks :-)
Hello,
Please, excuse me for misunderstanding you in my previous answer. The example I mentioned is related to Paragraph elements with a caption style designated to a Table, Figure, or Equation, and not to a table with caption property. Table caption property is not supported by the current implementation of the WordsProcessing library. We have logged a feature request in our feedback portal: Add support of alternative text of a Table. I am afraid that I couldn't find any other table properties appropriate for the scenario you would like to achieve.
We had a team discussion about this feature request and we have increased the priority of this item. However, the implementation of the item depends on whether it passes the QA check and I cannot commit to a specific time-frame when it will be delivered. Please, make sure to click the Follow button to be notified when the status of the item changes.
Regards,
Georgi
Progress Telerik