【问题标题】:how do i merge excel files with devexpress我如何将excel文件与devexpress合并
【发布时间】:2021-04-07 20:03:45
【问题描述】:

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

我使用本手册来合并文件。

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

没有人工作。

xlsx 文件放在 bin\Debug 文件夹中。 Sheets 包含 Sheet1,其中有不同的数据

代码

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);


        }
    }
}

【问题讨论】:

    标签: c# devexpress filemerge


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2023-03-23
      • 1970-01-01
      • 2013-07-30
      • 2020-12-06
      • 1970-01-01
      • 1970-01-01
      • 2020-07-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多