2016-09-28 60 views
-1

我想在asp.net web应用程序中打开Microsoft word文档like this我如何在asp.net上做到这一点。如何emberd微软word到asp.net web应用程序

+0

你想在用户点击链接时打开Word,或者想要将它嵌入到Web应用程序窗口中,就好像它在浏览器中运行一样? –

+0

'Haitham Shaddad'是的,这正是我想要的,将它嵌入到我的Web应用程序窗口中,就好像它在浏览器中运行一样。是否有任何方法可以在ASP.net中执行此操作? –

回答

0

您可以使用this link的Aceoffix插件。

并查看asp.net示例的演示。

您可以在每个月份刷新尝试许可证。

,我使用开放字,这些代码在浏览器中:

Microsoft.Office.Interop.Word.Application application = new Microsoft.Office.Interop.Word.Application(); 
Microsoft.Office.Interop.Word.Document document = null; 

     //open word template:     
document = application.Documents.Add(Server.MapPath("Smear.docx")); 

    //save word doc to folder: 
string NameReport = Server.MapPath(serial.Trim() + ".docx"); 
document.SaveAs(NameReport); 
application.Quit(); 

前退出应用程序,您可以编辑fields文本文档(我是在标题部分):

foreach (Microsoft.Office.Interop.Word.Section section in document.Sections) 
{ 
    document.TrackRevisions = false; 
    Microsoft.Office.Interop.Word.HeadersFooters headers = section.Headers; 
    foreach (Microsoft.Office.Interop.Word.HeaderFooter header in headers) 
    { 
     Microsoft.Office.Interop.Word.Fields fields = header.Range.Fields;  
     foreach (Microsoft.Office.Interop.Word.Field field in fields) 
     {  
      switch (field.Result.Text) 
      { 
       case "example_field1": 
        field.Result.Text = "your text"; 
        break; 
       case "example-field2": 
        field.Result.Text = " your text"; 
        break; 
      } 
     } 
    } 
}