I trying to merge two Excel files with Devexpress library. I don't have any errors but there isn't happening anything. Debug also looking good. I can see sheet names etc.
I use this manual to merge files.
No one working.
xlsx documents are placed in bin\Debug folder. Sheets contains Sheet1 where are different data
Code
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);
}
}
}
I think you need to use the SaveDocument method to actually persist your changes to the physical file. You should be invoking book2.SaveDocument("Text2.xlsx") to accomplish this.