This is a migrated thread and some comments may be shown as answers.

Render Word Document in MVC Razor View

1 Answer 667 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Ted
Top achievements
Rank 1
Ted asked on 28 Mar 2017, 08:44 PM

Hi,

the Scenario goes as follows - user fills out a form and submits it. The data from the form is merged with a word document template. I want to show the user the completed document. 

here is code snippet  -> return new Result { CoverSheet = memoryStream.ToArray() };

I'm stuck on how to view the document here is my razorview:

I'm stuck on how to render the coversheet. I have tried TelerikReporting and am currently looking at @(Html.Kendo().Editor()...

I see examples for how to use Import to open a word document but now how to create a view with existing data. Any help with how to proceed would be appreciated.

 

 

1 Answer, 1 is accepted

Sort by
0
Accepted
Ianko
Telerik team
answered on 30 Mar 2017, 10:25 AM

Hello Ted,

Instead of returning the Word document as a file/stream you can convert that Word file to HTML on the server and send it to the view to be rendered. For that, you can check out the RadWordsProcessing's DocxFormatProvider and HtmlFormatProvider to accomplish conversion from Word documents to HTML. 

By returning HTML, you can render the result in any HTML container you need or directly set that to the Value() method of the Kendo Editor or use the generated output to return the HTML as view or partial view (http://stackoverflow.com/questions/7682031/asp-net-mvc3-return-raw-html-to-view).  

Regards,
Ianko
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Editor
Asked by
Ted
Top achievements
Rank 1
Answers by
Ianko
Telerik team
Share this question
or