码迷,mamicode.com
首页 > Windows程序 > 详细

2,C#,NPOI2.2.1,.NET 4.0 获取单元格公式值,设置单元格的格式

时间:2019-01-15 14:22:26      阅读:394      评论:0      收藏:0      [点我收藏+]

标签:format   create   sheet   4.0   icc   tostring   cells   nbsp   公式   

//获取单元格的公式值

String temp;

if (row.GetCell(0).CellType == CellType.Formula)

temp = row.GetCell(0).NumericCellValue.ToString();

else

temp = row.GetCell(0).ToString();

 

//设置单元格格式为0.00,

IDataFormat dataformat = workbook.CreateDataFormat();

 ICellStyle style0 = workbook.CreateCellStyle();

style0.DataFormat = dataformat.GetFormat("0.00");

IRow row = sheet.CreateRow(0);

row.CreateCell(0).CellStyle = style0;

row.GetCell(0).SetCellValue(1);

2,C#,NPOI2.2.1,.NET 4.0 获取单元格公式值,设置单元格的格式

标签:format   create   sheet   4.0   icc   tostring   cells   nbsp   公式   

原文地址:https://www.cnblogs.com/fangen/p/10271120.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!