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


一般是因为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);

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM