Click here to Skip to main content
15,881,687 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How can i embedded CSV/Text file object in to the word document using OpenXml sdk?

Regards,
Ratheesh
Posted
Updated 15-Apr-15 16:44pm
v4

You can use AltChunk Class[^] which is used for importing the file's content.
You can find a nice video tutorial (introduction) to altChunks here.

But I need to point out that in this case, where you have an AlternativeFormatImportPartType.TextPlain, you will get this text displayed as "Courier New" with "10.5" size and I believe that cannot be changed.
But there are other supported AlternativeFormatImportPartTypes[^] that you could use (like HTML for example) which would enable you to define this content's styling (formatting).
 
Share this answer
 
Comments
RS.Ratheesh 16-Apr-15 5:44am    
Hi Mario,

Thanks for your reply. I need to display (CSV/Text file) as icon not the entire contents. I can able to do this for MS-Word and MS-Excel.

Thanks,
Ratheesh
Mario Z 16-Apr-15 6:50am    
Oh I see, well in that case I believe you are looking for OleObject Class[^]
Unfortunately I do not have much experience in them, but I found this SO post which looks very promising.

Also just in case you're interested here is what I would additionally do:
1. create the required DOCX file with MS Word
2. unzip that DOCX file
3. look for the "document.xml" file in it
4. open that "document.xml" and check how the MS Word wrote that
5. investigate those DOCX elements that MS Word used
I have similar scenario, where I have to present CSV text data from external file in MS Word table, which needs to be formatted as well. I am using 3rd party tool for that, because it is very easy to create a template document, format it and then I am reading CSV file into a .NET class. In my last step I merge template and data and generate final document as .docx, pdf or xps. In certain cases I need to implement conditional logic, which hides certain data, based on what user selects. The toolkit handles that on template level based on Boolean values in data.

You can see an example of how to use the toolkit here.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900