如何解决NPOI 映射器正在修剪具有列类型的 Excel 列的前导零 - 特殊
目前,我正在测试使用 NPOI.Mapper 库将 Excel 列映射到 DTO 的功能。
当列类型为 General、Text 等时,映射工作正常, 但它在下面的场景中失败了 如果 Excel 列类型为 Special 并且我添加了前导零,则映射器正在修剪该列的前导零。例如
ProductCode ProductDescription
00004652 00004652
00100100 00100100
Upon mapping the data to a list,the list contains 2 items of that Type
1)ProductCode : 4652
ProductDescription : 4652
2)ProductCode : 100100
ProductDescription : 100100
But my desired output should be
1)ProductCode : 00004652
ProductDescription : 00004652
2)ProductCode : 00100100
ProductDescription : 00100100
代码
public ICollection<T> Read(IFormFile file)
{
var workbook = WorkbookFactory.Create(file.OpenReadStream());
var mapper = ExcelClassMap.Register(workbook);
var result = mapper.Take<T>(sheetIndex: 0).Select(_ => _.Value).ToList();
return result;
}
谁能帮我解决这个问题。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。