c#导出excel,如何设置工作表名
发布网友
发布时间:2022-05-19 01:16
我来回答
共1个回答
热心网友
时间:2024-03-02 15:09
这个比较容易实现,可以在Spire.XLS.dll的辅助下完成,参考这篇教程:C# 命名工作表
using Spire.Xls;
namespace changeename
{
class Program
{
static void Main(string[] args)
{
Workbook workbook = new Workbook();
workbook.LoadFromFile(@"D:\michelle\my file\Excel Font.xlsx");
Worksheet worksheet = workbook.Worksheets[0];
Worksheet worksheet1 = workbook.Worksheets[1];
Worksheet worksheet2 = workbook.Worksheets[2];
worksheet.Name = "Rename sheet1";
worksheet1.Name = "Rename sheet2";
worksheet2.Name = "Rename sheet3";
worksheet.TabColor = Color.DarkGreen;
worksheet1.TabColor = Color.Red;
worksheet2.TabColor = Color.Gold;
workbook.SaveToFile("Reanme.xlsx",ExcelVersion.Version2010);
System.Diagnostics.Process.Start(workbook.FileName);
}
}
}