服务器端Word Automation DocX.dll

时间:2015-12-03 16:10:19

标签: c# ms-word automation server-side docx

我想知道DocX.dll对于服务器端Word自动化有多可靠?

我使用过Interop.Word并且无法在SQL Server上运行。所以,我正在考虑使用DocX.dll进行文档操作。

有没有人知道如何在没有Visual Studio的情况下在服务器端设置(添加引用).dll?

我已将.dll文件复制到bin文件夹,但它似乎无法正常工作。按钮Click事件没有响应,没有错误没有异常。

<asp:Button ID="newDocument" runat="server" text="New Offer"
            OnClick="newDocument_Click"/> 

这是OnClick方法:

protected void genDocument_Click(object sender, EventArgs e) 
{
    DocX document = DocX.Load(@"g:\\OfferDocuments\\MainDocument.docx"); 

    if (!ReguTechProp.Checked) 
    { 
        // If checkbox not checked, remove the table 
        document.Tables[10].Remove(); 
    } 

    document.ReplaceText("Name", "Ayesha", false, RegexOptions.IgnoreCase); 
    document.SaveAs(@"C:\\OfferDocument.docx"); 
} 

它正在我的localhost上运行,文档被操作并保存。但不是在服务器上。

我在项目的bin文件夹中复制了DocX.dll,在服务器上。我已经通过Visual Studio在我的localhost上添加了对.dll的引用。这有什么不同吗?

另外,我在Server上有相同的代码。但是当我点击按钮时,没有任何反应。它不显示任何错误或任何异常。按钮/窗口甚至不会冻结。

1 个答案:

答案 0 :(得分:0)

如果您指的是这个DocX(https://docx.codeplex.com/),我已经在生产环境中使用了几年。只要您坚持使用简单的文档格式,它就能很好地工作。

相关问题