I want to offer users of my application to download a docx file which would contain dynamic content depending on their request. I prepared a template with header, otherwise the OpenXML creation is pain in the somewhere. Now I am having trouble with editing it and returning it as FileResult in my ASP MVC application.
My plan is to read a file to MemoryStream
and edit it as WordprocessingDocument
and then returning MemoryStream as Byte[]
.
I have two problems here:
- If I read
WordprocessingDocument
directly from file without memory stream, I don't see a way to transform it to the shapeFileResult()
wants. - If I create new
WordprocessingDocument
with emptyMemoryStream
I can simply create content and return it asFile
but I lack the previously prepared header with desired content.
So, how to edit a .docx
template and return it as FileResult()
?