List of usage examples for org.apache.poi.ss.usermodel Sheet showInPane
void showInPane(int toprow, int leftcol);
From source file:engine.ExcelUpdater.java
License:Apache License
/** * Load information of UT code into the UT report. *//*from w ww .j a v a 2 s. c om*/ public boolean update(File excelFile, ConfigInfo confInfo) { LOG.debug("Updating file : " + excelFile.getPath()); try { String filename = excelFile.getName(); if (filename.endsWith(Constant.DOT_XLS)) { workbook = new HSSFWorkbook(new FileInputStream(excelFile)); } else if (filename.endsWith(Constant.DOT_XLSX)) { workbook = new XSSFWorkbook(new FileInputStream(excelFile)); } } catch (FileNotFoundException ex) { LOG.error("Could not found '" + excelFile.getPath() + "'", ex); } catch (IOException ex) { LOG.error("Could not read/write '" + excelFile.getPath() + "'", ex); } ; Sheet sheet; Integer nSeqNo = confInfo.getStartValue(); int len = workbook.getNumberOfSheets(); String cellAddr; for (int sheetNo = workbook.getSheetIndex(confInfo.getStartSheet()); sheetNo < len; sheetNo++) { if (sheetNo < 0) { LOG.info("Layou file '" + excelFile.getPath() + "' is wrong."); return false; } // i is special sheet if (confInfo.containSpecialSheetNo(sheetNo)) { cellAddr = confInfo.getSpecialCellAddr(sheetNo); } else { cellAddr = confInfo.getGivenCell(); } sheet = workbook.getSheetAt(sheetNo); PoiUtil.setContent(sheet, cellAddr, nSeqNo); nSeqNo++; } // Set focus workbook.setActiveSheet(confInfo.getFocusSheetNo()); sheet = workbook.getSheetAt(confInfo.getFocusSheetNo()); CellReference cellRef = new CellReference(confInfo.getFocusCell()); sheet.showInPane((short) cellRef.getRow(), (short) cellRef.getCol()); // Save file FileOutputStream os = null; try { os = new FileOutputStream(excelFile); workbook.write(os); } catch (FileNotFoundException ex) { LOG.error("Could not save file.", ex); } catch (IOException ex) { LOG.error("Could not save file.", ex); } finally { if (os != null) { try { os.close(); } catch (IOException ex) { LOG.warn(ex); } } } return true; }