重置excel公式

   private void resetCalFormual( String sheetName, String filePath,
            Map<Integer, Integer[]> cellFormula ) throws Exception
    {
        Excel excel = new Excel();
        IWorkBook workbook = excel.OpenWorkBook( filePath );
        WorkSheet sheet = workbook.GetSheet(sheetName);
        Set<Entry<Integer, Integer[]>> sets = cellFormula.entrySet();
        Row row = null;
        Cell cell = null;
        
        for ( Entry<Integer, Integer[]> entry : sets )
      
        {
            row = sheet.getRow( entry.getKey().intValue() );
         
            for ( Integer cellStr : entry.getValue() )
         
            {
                cell = row.getCell( cellStr.intValue() );
                if ( Cell.CELL_TYPE_FORMULA == cell.getCellType() )
                {
                    cell.setCellFormula( cell.getCellFormula() );
                }
            }

        }

        workbook.Save( filePath );
        workbook.Close();

    }

你可能感兴趣的:(Excel)