import org.apache.poi.poifs.filesystem.*; import java.io.*; import java.util.Vector; import org.apache.poi.hssf.usermodel.*; import com.ibm.bisc.ebiz.base.*; /** * Insert the type's description here. * Creation date: (2003-3-23 17:35:41) * @author: hwc */ public class SCNExcel { /** * SCNExcel constructor comment. */ public SCNExcel() { super(); } public static void main(java.lang.String[] args) { // Insert code to start the application here. try { POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream("e:\\2.xls")); HSSFWorkbook wb = new HSSFWorkbook(fs); HSSFSheet sheet = wb.getSheet("Sheet1"); HSSFRow row = sheet.getRow((short)2); HSSFCell cell = row.getCell((short)3); String f = cell.getCellFormula(); System.out.println("formula = " + f); double d = cell.getNumericCellValue(); cell.setCellType(HSSFCell.CELL_TYPE_NUMERIC); cell.setCellValue(44.0); //cell.setCellFormula(f); FileOutputStream fileOut = new FileOutputStream("e:\\3.xls"); wb.write( fileOut ); fileOut.close(); }catch (Exception e ) { e.printStackTrace(); } } }