在ASP.NET中合并Word文档 [英] Merge Word Documents in ASP.NET
本文介绍了在ASP.NET中合并Word文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是ASP.NET编程的新手.我的问题是关于合并服务器中的Word文档.当用户发送请求时,程序将合并所有word文档,这些文档位于服务器的一个x文件夹中.然后,它将把合并的Word文档发送给用户.我该怎么做?你能给我一些建议吗?
谢谢,
Hi,
I am new at ASP.NET programming. My problem is about merging word documents in server. When user sends a request, the program will merge all word documents,which is in one x folder in server. Then, it will send this merged word document to user. How can I do it? Can you give me some advice about it?
Thanks,
推荐答案
hi
您可以使用第三方dll
使用dll
希望对您有所帮助:)
hi
you can use third party dll for it
aspose dll
hope it will help:)
希望这些链接对您有所帮助.
使用C#合并Word文档 [ http://devpinoy.org/blogs/keithrull/archive/2007/05/23/how-to-merge-multiple-microsoft-word-documents-in-c.aspx [
Hope these link will help you.
Merging Word Documents with C#[^]
http://devpinoy.org/blogs/keithrull/archive/2007/05/23/how-to-merge-multiple-microsoft-word-documents-in-c.aspx[^]
如果要串联多个 C#DOCX 文件,则可以轻松实现此 C#/VB.NET Word 组件,然后
Hi,
if you want to concatenate multiple C# DOCX files, you can do it easily with this C# / VB.NET Word component, and then ASP.NET export to Word so user can download the final document with a browser.
Here is a sample C# code:
// Use the component in free mode.
ComponentInfo.SetLicense("FREE-LIMITED-KEY");
// Create document instance that will contain all concatenated input documents.
var finalDocument = new DocumentModel();
// For each input document.
foreach (string filePath in filePaths)
{
// Load an input document.
var document = DocumentModel.Load(filePath, LoadOptions.DocxDefault);
// Import and add every input document section to the final document.
foreach (var section in document.Sections)
finalDocument.Sections.Add(finalDocument.Import(section, true));
}
// Microsoft Packaging API cannot write directly to Response.OutputStream.
// Therefore we use temporary MemoryStream.
using (MemoryStream documentStream = new MemoryStream())
{
finalDocument.Save(documentStream, SaveOptions.DocxDefault);
// Stream file to browser.
Response.Clear();
Response.ContentType = "application/vnd.openxmlformats";
Response.AddHeader("Content-Disposition", "attachment; filename=Document.docx");
documentStream.WriteTo(Response.OutputStream);
Response.End();
}
这篇关于在ASP.NET中合并Word文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文