HSSFWorkbook hssfworkbook = new HSSFWorkbook();
ISheet sheet = hssfworkbook.CreateSheet("Sheet1");
hssfworkbook.CreateSheet("Sheet2");
hssfworkbook.CreateSheet("Sheet3");
//Title
IRow row = sheet.CreateRow(0); //创建行对象
ICell cell = row.CreateCell(0); //创建单元格对象
int rIndx=1;
cell.CellFormula = "F" + rIndx + "+G" + rIndx + "+H" + rIndx + "+I" + rIndx + "+J" + rIndx;//单元格公式为:=F1+G1+H1+I1+J1
cell.CellFormula="SUMIF(J6:J78,"语文",D6:D78)";//J列是语文的D列成绩汇总
//模板自动公式需要激活
sheet.ForceFormulaRecalculation = true;
//公式列获取值
HSSFFormulaEvaluator e = new HSSFFormulaEvaluator(hssfworkbook);
cell = e.EvaluateInCell(cell);