Click here to Skip to main content
15,892,072 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
I have been using using Microsoft.Office.Interop.Word in my webserver (yes, i know it is not recommended).

When I ran it on my machine, it runs fine, but when running on the server I get a timeout on the following line:
Documents.Open //when trying to open the file.

Is there something I'm missing? Is there a better way to edit a Word document within web servers/websites? (I can't create a new one using string builder or outputting into file; I need to edit an existing one that sits on the server.)

Any input will be appreciated as I'm stuck on this for few days already...
Posted

You can use HtmlTextWriter on webpage for create Word/Excel document and post edit...

For example: export Grid on webpage to Word
public static void ExportToWord(System.Web.UI.Page p, DataGrid grdGridView, string fileName)
{
  p.Response.Clear();
  p.Response.AddHeader("content-disposition", string.Format("attachment;filename={0}.doc", fileName));
  p.Response.Charset = "";
  p.Response.ContentType = "application/vnd.doc";
  StringWriter stringWrite = new StringWriter();
  HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
  myGridView.RenderControl(htmlWrite);
  p.Response.Write(stringWrite.ToString());
  p.Response.End();
}
 
Share this answer
 
You can take a look at:
http://blogs.msdn.com/b/microsoft_office_word/archive/2009/10/26/introducing-word-automation-services.aspx[^]
and
http://blogs.msdn.com/b/microsoft_office_word/archive/2009/09/09/co-authoring-in-word-2010.aspx[^]

Full authoring capabilities doesn't come cheap, but if you do the math:
(hours required to implement solution) x (hourly rate)

You can probably justify buying a sharepoint server license ...

Regards
Espen Harlinn
 
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