EXCEL 读写

HSSFCell nameCell = row.getCell(columnNum);
if (nameCell == null)
{
nameCell = row.createCell(columnNum);
}
nameCell.setCellValue(value);
//更新所有公式计算内容,将计算内容刷新到表格中去
updateFormula();
//保存修改内容
save();
//关闭文件,重新打开,以便读取content的内容更新
CloseParser();

////////////////////////////////////////////////
public void updateFormula()
{
HSSFFormulaEvaluator.evaluateAllFormulaCells(this.wb);
}
/////////////////////////////////////////////
public void save() throws IOException
{
this.xlsInputStream.close();
try {
FileOutputStream fileOut = new FileOutputStream(xslPath);
wb.write(fileOut);
fileOut.close();
} catch (Exception e) {
e.printStackTrace();
}
}
////////////////////////////////////////////////

private HashMap<String, Integer> tableNameMap;
private HSSFSheet theSheet;
private HSSFWorkbook wb;
private String xslPath;
private InputStream xlsInputStream;

你可能感兴趣的:(Excel)