Results 1 to 1 of 1
Thread: Reading my excel values
- 04-21-2014, 05:00 PM #1Member
- Join Date
- Apr 2014
- Rep Power
Reading my excel values
I have an excel worksheet that has macros & formulas. My objectives are to
(1) Read the file from a specific folder, change the value of E6 and force the recalculations on the entire sheet that work off of that cell
(2) Output the file (with a new name) to a different folder with the new calculated cells and values
(3) From the new created file, grab the calculated values from D10 and E10 (these cells have formulas in them) and output them to the screen and a database.
I have accomplished the first two objectives -but I am struggling on the 3rd.
When I try to grab the values, it is giving me the values as if they were from the beginning file before the E6 value was changed and the calculations were forced.
Can someone please help? I'm not sure what I am doing wrong. My code is below:
FileInputStream file = null; HSSFWorkbook workbook = null; HSSFSheet sheet = null; Cell cell = null; FileInputStream file2 = null; HSSFWorkbook workbook2 = null; HSSFSheet sheet2 = null; Cell cell2 = null; FileOutputStream outFile = null; Double GED_W = 0.0; Double GED_H = 0.0; Double GED_A = 0.0; Double GED_B = 0.0; file = new FileInputStream(new File("I:\\Specials XLS\\"+productline+"\\"+workbookname+".xls")); workbook = new HSSFWorkbook(file); sheet = workbook.getSheet(getsheet); //Update the value of cell cell = sheet.getRow(5).getCell(4); cell.setCellValue(userwidth); workbook.setForceFormulaRecalculation(true); file.close(); outFile = new FileOutputStream(new File("I:\\ORDERS\\"+productline+"\\ORDER_"+ordernumber+"_ORDERLINE_"+orderlinenumber+"_"+mainproducttype+".xls")); workbook.write(outFile); outFile.close(); file2 = new FileInputStream(new File("I:\\ORDERS\\"+productline+"\\ORDER_"+ordernumber+"_ORDERLINE_"+orderlinenumber+"_"+mainproducttype+"_"+(java.sql.Date) dt+".xls")); workbook2 = new HSSFWorkbook(file2); sheet2 = workbook2.getSheet(getsheet); cell2 = sheet2.getRow(9).getCell(3); GED_W = cell2.getNumericCellValue(); System.out.println("GED_W CELL VALUE: " + GED_W); cell2 = sheet.getRow(9).getCell(4); GED_H = cell2.getNumericCellValue(); System.out.println("GED_H CELL VALUE: " + GED_H);
- By vector_ever in forum Apache POIReplies: 43Last Post: 05-23-2014, 02:26 PM
- By javaplus in forum Advanced JavaReplies: 5Last Post: 07-13-2012, 05:46 AM
- By sandeepsai17 in forum New To JavaReplies: 5Last Post: 08-21-2009, 12:03 PM
- By wdb07159 in forum New To JavaReplies: 2Last Post: 05-06-2009, 01:45 PM
- By Java Tip in forum Java TipReplies: 0Last Post: 02-13-2008, 12:19 PM