简体   繁体   中英

How can I merge cells of Excel package worksheet in C#?

I just want to merge number of cells in one column using worksheet of ExcelPackage ; There is the way that I create my worksheet:

        var excelFile = new FileInfo(fileName);
        var package = new ExcelPackage(excelFile);
        var workSheet = package.Workbook.Worksheets.Add(sheetName);

So How can I merge cells in this worksheet? I will be thankful for any solution.

// Place data in cells
worksheet.Cells["A1"].Value = "Cell A1";
// Or [row, column] notation:
worksheet.Cells[2,1].Value = "Cell A2";

// Merge cells
worksheet.Cells["A1:B1"].Merge = true;
// Or [row, column] notation:
worksheet.Cells[FromRow, FromColumn, ToRow, ToColumn].Merge = true;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM