2016-04-20 115 views

回答

2

我有點困惑你的問題,因爲默認NPOI 通過xxxCellValue屬性返回單元格的值。考慮下面的示例代碼:

using (var stream = new FileStream(@"..\..\..\Data\SheetWithFormula.xlsx", FileMode.Open)) 
{ 
    var workbook = new XSSFWorkbook(stream); 
    var sheet = workbook.GetSheetAt(0); 

    var row = sheet.GetRow(2); 
    var cell = row.GetCell(2); 

    Console.WriteLine("Cell value: {0} (formula: {1})", cell.NumericCellValue, cell.CellFormula); 
} 
相關問題