我是论坛的新手,我刚开始在 Visual Studio 2013 上使用新的 Web 应用程序。我需要创建一个应用程序,将所有内容从一个 Word 文档复制到另一个文档。我发现这个插件应该可以完成这项工作,但我不知道如何将它放入我的代码中并使其工作。我需要在 MVC 应用程序中执行此操作,所以也许我没有将代码放在正确的位置(现在它在模型中)。有人可以帮我告诉我如何让它工作吗?请查看我拥有的代码:
using Spire.Doc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace DocumentApplication.Models
{
public class HomeModel
{
public string Message { get; set; }
}
public class CopyDocument
{
Document sourceDoc = new Document("source.docx");
Document destinationDoc = new Document("target.docx");
foreach (Section sec in sourceDoc.Sections)
{
foreach (DocumentObject obj in sec.Body.ChildObjects)
{
destinationDoc.Sections[0].Body.ChildObjects.Add(obj.Clone());
}
}
destinationDoc.SaveToFile("target.docx");
System.Diagnostics.Process.Start("target.docx");
}
public class OpenDocument
{
Document document = new Document(@"C:\Users\daniel\Documents\ElAl-DRP.doc");
}
}
我无法编译它,因为我在“foreach”行上有一个错误,上面写着:“类'结构'或接口成员声明中的令牌'foreach'无效”。
请帮我。
提前致谢