Download the locally saved Doc file

Hi,

I created a doc type template and saved in the root folder. It is working and storing the data but I want to download the doc file. I'm also attaching snap. I'm using ASP.NET Core. 

I also tried " return File(stream, "application/msword", "Result.docx");" . 

can you please help me on that.

OpenDoc.jpg

SavingDoc.jpg  


7 Replies

SB Suriya Balamurugan Syncfusion Team September 15, 2022 05:13 PM UTC

Hi Pawan,

From the given details, we have found that your requirement is to download the doc file.

To achieve your requirement, we suggest you to save the Word document to a memory stream and then use that memory stream to download the doc file. Please refer the below highlighted code snippet to achieve your requirement.

//Saves the Word document to MemoryStream.

MemoryStream stream = new MemoryStream();

document.Save(stream, FormatType.Docx);

stream.Position = 0;

 

//Download Word document in the browser.

return File(stream, "application/msword", "Result.docx");


We have prepared the sample application to download the doc file and it can be downloaded from the below attachment.

Please refer our documentation link to know more about how to download the generated Word document file,
https://help.syncfusion.com/file-formats/docio/create-word-document-in-asp-net-core

Please refer our online example link to know more about how to download the generated Word document file,
https://ej2.syncfusion.com/aspnetcore/Word/HelloWorld#/bootstrap5

Regards,
Suriya Balamurugan.


If this post is helpful, please consider accepting it as the solution so that other members can locate it more quickly.



Attachment: ASP.NETCore_d51ca525.zip


GU gugal replied to Suriya Balamurugan September 15, 2022 05:28 PM UTC

Hi Suriya B,

 Thanks for the reply. 

As I mentation above, I was using my own template for changing data and  I already tried

 " return File(stream, "application/msword", "Result.docx"); "  this.

FileError.jpg



SB Suriya Balamurugan Syncfusion Team September 16, 2022 10:51 AM UTC

Hi Pawan,

We have tried to reproduce the reported problem using the given details at our end.

We suspect that the problem might be due to the sample application which used at your end. So, could you please provide us the issue reproducible sample application from your end, which will be helpful to reproduce the exact issue at our end.

Also, share us what kind of ASP.NET Core application used at your side like ASP.NET Core Web App, ASP.NET Core Web App (Model-View-Controller), ASP.NET Core Web API as shown below,



Based on the above details, we will proceed further to reproduce the exact issue and provide you appropriate solution at the earliest.

Regards,
Suriya Balamurugan.



GU gugal September 18, 2022 08:51 AM UTC

Hi Suriya, 
Thanks for the replay. 

I'm Using ASP.NET Core Web App with the latest version.

So, Can you please create a demo project example take a .docx file as template and make some changes with hard coded after that please try to download in different type of format in your local system. And share that link with us.
Thanks


Regards,

Pawan  



SB Suriya Balamurugan Syncfusion Team September 19, 2022 01:44 PM UTC

Hi Pawan,

We have prepared the ASP.NET Core Web App to download Word document using Syncfusion DocIO library as per your requirement. The sample application can be downloaded below attachment.

Please refer below link to know more about ASP.NET Core Web application,
https://docs.microsoft.com/en-us/visualstudio/get-started/csharp/tutorial-aspnet-core?view=vs-2022

Regards,
Suriya Balamurugan.


If this post is helpful, please consider accepting it as the solution so that other members can locate it more quickly.


Attachment: FindAndReplace_4d8c5edc.zip


GU gugal replied to Suriya Balamurugan September 20, 2022 06:03 AM UTC

HI Suriya B,

Thanks for the reply.

I think you didn't get my question.

here I'm taking a doc file as template.

OpenDoc003.jpg

After that you made some changes like Name, Address and Mobile Number with hard coded and will you please try to download the edited doc file in ASP.NET Core 6.0.0.


Regards,

Pawan



SB Suriya Balamurugan Syncfusion Team September 20, 2022 09:55 AM UTC

Hi Pawan,

We have prepared the ASP.NET Core Web App as per your requirement. The sample application can be downloaded below link.
https://www.syncfusion.com/downloads/support/directtrac/general/ze/FindAndReplace-735500783.zip

In this sample application, we have done the following things,
1. Taking a doc file as template.
2. Made some changes like Name, Address and Mobile Number with hard coded.
3. Download the edited doc file.

Still, if your requirement is not meet means, then kindly provide us complete end requirement along with input template, and screenshot/output document of the expected result which will helpful to provide you the appropriate solution at the earliest.

Regards,
Suriya Balamurugan.


Loader.
Up arrow icon