- Home
- Forum
- ASP.NET Core - EJ 2
- Need to copy a table with header and replace values multiple times.
Need to copy a table with header and replace values multiple times.
I have a document that calls a API returning a array of data. That document has a table with a header with a marker (%%Name) that I want to replace the name of. Inside the table there are cells with similar markers (%%Row Value1 etc) that I also want to fill in. If there are multple arrays, I want to insert another table with a header so I can fill in the table with the different array. The code below is not meant to coincide with the documents I have uploaded as they are meant to be examples, but this is what I have thus far, but hasn't given me the results I was expecting. It takes the original table, fills out the data, but when I want to copy the table - it uses the filled out data table. For additional example, in the zip file - i have a sample of the document, and how I wish for the document to look like. Any help or pointers would be greatly appreciated. var result = await _myService.GetInfo(lineId); dynamic resultObject = JsonConvert.DeserializeObject(result); List
Attachment: example_dec6ba80.zip
Hi
Sydney,
From the given details, we found that you are populating data into the Word
document by replacing placeholders in Word document with values from JSON. From
the given attachment, we have found that both documents are the same, and it is
not enough to proceed further on our side. So, could you please share us the
exact input template document which maintained at your side with
placeholders and also input JSON or data file.
Based on the above details, we will check on the feasibility to achieve your
requirements using Word library (DocIO) and share more details on it.
Note: If you have confidential data in your inputs, kindly
replace them with some dummy values. We just need your inputs to understand
about the exact requirement.
Regards,
Dharanya.
Thank you for responding and apologies for the mistake. I thought I had them seperate as I was sanitizing the documents and JSON. :)
Enclosed should be three files, the initial document, what I want the intended result to be, and the requested JSON format of how things work.
It's been tricky to figure out, so if you can see what I might be doing wrong, it'd be greatly appreciated!
Thanks aqain!
Sydney
Attachment: syncfusiondociohelp_e4d76ed9.zip
Sydney,
We have prepared and attached the sample to get the result as you attached intended
result.docx. We can achieve this by performing a mail merge (which is the
process of merging data from a data source into a Word template document) using
merge fields (placeholders that can be replaced with data during document
generation).
To do mail merge, it is needed to design template Word document with merge fields. You can insert merge fields either DocIO programmatically or using Microsoft Word application.
Here are the steps to design a template Word document for executing a mail merge using Microsoft Word:
- Insert Merge fields in Word document, where you wish to replace with data from data source (JSON).
2. The merge field "EmployeeName" will now be added to the Word document as like below.
In your requirement, we have achieved this using group mail merge to append
multiple records from a data source to a template document. The records are
inserted between merge fields marked as start and end groups, and this process
is repeated for every record in the data source.
Kindly refer the below Documentation and GitHub sample to know about mail merge
in DocIO.
Documentation-working-with-mail-merge
GitHub-sample-Mail-merge
Note: We have modified the template document to replace content with
merge fields.
Regards,
Dharanya.
Attachment: Generatetableusingmailmege_feab0d6.zip
- 3 Replies
- 2 Participants
-
SB Sydney Brea
- Aug 22, 2024 07:21 PM UTC
- Aug 26, 2024 10:20 AM UTC