sheetname问题
Closed this issue · 6 comments
zpzhangwenhan commented
版本1.17.0, 指定 sheetname 好像不起作用
zpzhangwenhan commented
......
setting.HasSheetConfiguration(1, "我是一个Sheet", true);
setting.HasSheetSetting(config =>
{
config.StartRowIndex = 1;
config.SheetName = "我是一个Sheet";
config.AutoColumnWidthEnabled = true;
......
zpzhangwenhan commented
我是这么用的
void Main()
{
//制造数据
List<ExcelExportDTO> exprotDataList = new List<UserQuery.ExcelExportDTO>();
for (int i = 0; i < 10; i++)
{
var temp = new ExcelExportDTO
{
Name = "张三" + i,
Address = "北京海淀" + i,
Birthday = DateTime.Now,
Remark = "Remark" + i
};
exprotDataList.Add(temp);
}
var setting = FluentSettings.For<ExcelExportDTO>();
setting.HasSheetConfiguration(1, "我是一个Sheet_111", true);
setting.HasSheetSetting(s =>
{
s.SheetName = "我是一个Sheet_2222";
});
string deskTopFullPath = System.Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
string exportFileName = Path.Combine(deskTopFullPath, "Test_for_weihanli.xlsx");
exprotDataList.ToExcelFile(exportFileName);
"done".Dump();
/*
测试步骤:
1、创建List数据,配置FluentSetting
2、直接ToExcelFile到文件 表名:Sheet0
*/
}
//[WeihanLi.Npoi.Attributes.Sheet(SheetIndex = 0, SheetName = "TestSheet", AutoColumnWidthEnabled = true)]
public class ExcelExportDTO
{
[WeihanLi.Npoi.Attributes.Column("姓名")]
public string Name { get; set; }
[WeihanLi.Npoi.Attributes.Column("住址")]
public string Address { get; set; }
[WeihanLi.Npoi.Attributes.Column("出生日期")]
public DateTime Birthday { get; set; }
public string Remark { get; set; }
}
WeihanLi commented
感谢示例,重现问题了,是一个BUG,感谢
WeihanLi commented
发了一个新的预览版本 https://www.nuget.org/packages/WeihanLi.Npoi/1.21.0-preview-20210909-023107,可以试一下,没问题的话后面会再发布稳定版
WeihanLi commented
发布了一个稳定版 https://www.nuget.org/packages/WeihanLi.Npoi/1.21.0,可以试一下,issue 先关掉了,有问题的话可以再打开