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

//获取单元格的公式值

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);

猜你喜欢

转载自www.cnblogs.com/fangen/p/10271120.html
今日推荐