如何将excel文件与devexpress合并



我试图将两个Excel文件与Devexpress库合并。我没有任何错误,但没有发生任何事情。调试看起来也不错。我可以看到图纸名称等

我使用本手册合并文件

https://docs.devexpress.com/OfficeFileAPI/120383/spreadsheet-document-api/examples/workbooks/how-to-merge-multiple-workbooks-into-one-document

没有人工作。

xlsx文档被放置在bin\Debug文件夹中。图纸包含图纸1,其中有不同的数据

代码

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Data.OleDb;
using DevExpress.Spreadsheet;
using System.Drawing;
using DevExpress.XtraSpreadsheet;
using DevExpress.Docs;
namespace Merge_Files
{
class Program
{
static void Main(string[] args)
{
// Create the first workbook.
Workbook book1 = new Workbook();
book1.LoadDocument("Test1.xlsx", DocumentFormat.Xlsx);
// Create the second workbook.
Workbook book2 = new Workbook();
book2.LoadDocument("Test2.xlsx", DocumentFormat.Xlsx);
// Copy all worksheets from "Document1" to "Document2".
book2.Append(book1);

}
}
}

我认为您需要使用SaveDocument方法来实际持久化对物理文件的更改。您应该调用book2.SaveDocument("Text2.xlsx"(来完成此操作。

最新更新