简体   繁体   English

如何在 C# 工作表中合并 Excel package 工作表的单元格?

[英]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 ;我只想使用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;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用c#检查excel工作表是否合并了单元格 - how to check if excel worksheet has merged cells using c# 如何合并C#创建的二进制Excel单元格? - How can i merge binary excel cell created by C#? 我应该如何声明一个Microsoft.Office.Interop.Excel.Worksheet,以便可以在C#中将其关闭? - How should I declare a Microsoft.Office.Interop.Excel.Worksheet so I can close it in C#? 如何在C#中的多个Excel工作表上打印数据 - How can I print data on more than one excel worksheet in C# c#-(Excel互操作)如何在VSTO中将一个工作表复制到另一工作簿? - c# - (Excel interop)How can I copy one worksheet to another workbook in VSTO? 如何使用DocumentFormat.OpenXml C#获取excel工作表中的特定列? - How can I get the specific column in excel worksheet using DocumentFormat.OpenXml C#? C#Excel Interop:如何“获取”工作表中已有的表格? - C# Excel Interop: how can I “get” a table that is already in a worksheet? 如何将 Excel 工作表中特定行或单元格的 fonts 加粗为 C#? - How can I bold the fonts of a specific row or cell in an Excel worksheet with C#? c#:访问 excel 工作表中的单元格会引发 NullReferenceException - c#: Accessing cells in excel worksheet throws NullReferenceException 如何在Excel的Excel.Range对象中选择工作表中的所有单元格? - How to Select all the cells in a worksheet in Excel.Range object of c#?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM