c#npoi 报错Cannot get a numeric value from a text cell 的解决

时间:2018-05-24 17:22:09   收藏:0   阅读:1318
一般是因为cell里边的值为数字导致,有时变成文本格式还是解决不了这个问题.  
下边的代码是c# 改变设置cell类型的方法 是用这个参数 CellType.String

 

Row.GetCell((int)customer_level_index).SetCellType(CellType.String);
detail.customer_level = Row.GetCell((int)customer_level_index).StringCellValue;


这个下边是网上的

POI 实际上setCellValue的时候根据传入参数的类型会自动设置celltype,所以
long vll = Long.valueOf(vls.trim()); //sheet.getRow(i).getCell(j).setCellType(Cell.CELL_TYPE_NUMERIC); 要mark掉,否则有异常 sheet.getRow(i).getCell(j).setCellValue(vll);

 

原文:https://www.cnblogs.com/zuochanzi/p/9083676.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!