VB.NET使用NPOI設定Cell Formula
網路上找了許多範例都是用
Dim sheet1 As HSSFSheet = hssfworkbook.CreateSheet("Sheet1")
Dim row1 As HSSFRow = sheet1.CreateRow(0)
Dim cel1 As HSSFCell = row1.CreateCell(0)
Dim cel2 As HSSFCell = row1.CreateCell(1)
Dim cel3 As HSSFCell = row1.CreateCell(2)
Dim celSum1 As HSSFCell = row1.CreateCell(3)
Dim celSum2 As HSSFCell = row1.CreateCell(4)
Dim celSum3 As HSSFCell = row1.CreateCell(5)
cel1.SetCellValue(1)
cel2.SetCellValue(2)
cel3.SetCellValue(3)
celSum2.SetCellFormula("sum(A1,C1)")
但是即使更新到NPOI 1.2.5
在Cell下面還是沒有SetCellFormula這個方法
所以改用
celSum2.CellFormula = "sum(A1,C1)"
這樣就可以設定Cell Formula了