/** * create an HSSFSheet for this HSSFWorkbook, adds it to the sheets and returns * the high level representation. Use this to create new sheets. * * @return HSSFSheet representing the new sheet. */ @Override public HSSFSheet createSheet() { HSSFSheet sheet = new HSSFSheet(this); _sheets.add(sheet); workbook.setSheetName(_sheets.size() - 1, "Sheet" + (_sheets.size() - 1)); boolean isOnlySheet = _sheets.size() == 1; sheet.setSelected(isOnlySheet); sheet.setActive(isOnlySheet); return sheet; }
/** * Convenience method to set the active sheet. The active sheet is is the sheet * which is currently displayed when the workbook is viewed in Excel. * 'Selected' sheet(s) is a distinct concept. */ @Override public void setActiveSheet(int index) { validateSheetIndex(index); int nSheets = _sheets.size(); for (int i=0; i<nSheets; i++) { getSheetAt(i).setActive(i == index); } workbook.getWindowOne().setActiveSheetIndex(index); }
boolean isOnlySheet = _sheets.size() == 1; sheet.setSelected(isOnlySheet); sheet.setActive(isOnlySheet); return sheet;
HSSFSheet clonedSheet = srcSheet.cloneSheet(this); clonedSheet.setSelected(false); clonedSheet.setActive(false);
HSSFWorkbook wb = new HSSFWorkbook(new FileInputStream(file)); HSSFSheet s = wb.getSheetAt(0); s.setActive(true); HSSFRow row = s.getRow(0); HSSFCell cell = row.getCell(0); cell.setAsActiveCell(); FileOutputStream out = new FileOutputStream(file);
/** * create an HSSFSheet for this HSSFWorkbook, adds it to the sheets and returns * the high level representation. Use this to create new sheets. * * @return HSSFSheet representing the new sheet. */ public HSSFSheet createSheet() { HSSFSheet sheet = new HSSFSheet(this); _sheets.add(sheet); workbook.setSheetName(_sheets.size() - 1, "Sheet" + (_sheets.size() - 1)); boolean isOnlySheet = _sheets.size() == 1; sheet.setSelected(isOnlySheet); sheet.setActive(isOnlySheet); return sheet; }
/** * create an HSSFSheet for this HSSFWorkbook, adds it to the sheets and returns * the high level representation. Use this to create new sheets. * * @return HSSFSheet representing the new sheet. */ public HSSFSheet createSheet() { HSSFSheet sheet = new HSSFSheet(this); _sheets.add(sheet); workbook.setSheetName(_sheets.size() - 1, "Sheet" + (_sheets.size() - 1)); boolean isOnlySheet = _sheets.size() == 1; sheet.setSelected(isOnlySheet); sheet.setActive(isOnlySheet); return sheet; }
/** * create an HSSFSheet for this HSSFWorkbook, adds it to the sheets and returns * the high level representation. Use this to create new sheets. * * @return HSSFSheet representing the new sheet. */ @Override public HSSFSheet createSheet() { HSSFSheet sheet = new HSSFSheet(this); _sheets.add(sheet); workbook.setSheetName(_sheets.size() - 1, "Sheet" + (_sheets.size() - 1)); boolean isOnlySheet = _sheets.size() == 1; sheet.setSelected(isOnlySheet); sheet.setActive(isOnlySheet); return sheet; }
/** * Convenience method to set the active sheet. The active sheet is is the sheet * which is currently displayed when the workbook is viewed in Excel. * 'Selected' sheet(s) is a distinct concept. */ public void setActiveSheet(int index) { validateSheetIndex(index); int nSheets = _sheets.size(); for (int i=0; i<nSheets; i++) { getSheetAt(i).setActive(i == index); } workbook.getWindowOne().setActiveSheetIndex(index); }
/** * Convenience method to set the active sheet. The active sheet is is the sheet * which is currently displayed when the workbook is viewed in Excel. * 'Selected' sheet(s) is a distinct concept. */ public void setActiveSheet(int index) { validateSheetIndex(index); int nSheets = _sheets.size(); for (int i=0; i<nSheets; i++) { getSheetAt(i).setActive(i == index); } workbook.getWindowOne().setActiveSheetIndex(index); }
/** * Convenience method to set the active sheet. The active sheet is is the sheet * which is currently displayed when the workbook is viewed in Excel. * 'Selected' sheet(s) is a distinct concept. */ @Override public void setActiveSheet(int index) { validateSheetIndex(index); int nSheets = _sheets.size(); for (int i=0; i<nSheets; i++) { getSheetAt(i).setActive(i == index); } workbook.getWindowOne().setActiveSheetIndex(index); }
boolean isOnlySheet = _sheets.size() == 1; sheet.setSelected(isOnlySheet); sheet.setActive(isOnlySheet); return sheet;
boolean isOnlySheet = _sheets.size() == 1; sheet.setSelected(isOnlySheet); sheet.setActive(isOnlySheet); return sheet;
boolean isOnlySheet = _sheets.size() == 1; sheet.setSelected(isOnlySheet); sheet.setActive(isOnlySheet); return sheet;
HSSFSheet clonedSheet = srcSheet.cloneSheet(this); clonedSheet.setSelected(false); clonedSheet.setActive(false);
HSSFSheet clonedSheet = srcSheet.cloneSheet(this); clonedSheet.setSelected(false); clonedSheet.setActive(false);
/** * create an HSSFSheet from an existing sheet in the HSSFWorkbook. * * @return HSSFSheet representing the cloned sheet. */ public HSSFSheet cloneSheet(int sheetIndex) { validateSheetIndex(sheetIndex); HSSFSheet srcSheet = _sheets.get(sheetIndex); String srcName = workbook.getSheetName(sheetIndex); HSSFSheet clonedSheet = srcSheet.cloneSheet(this); clonedSheet.setSelected(false); clonedSheet.setActive(false); String name = getUniqueSheetName(srcName); int newSheetIndex = _sheets.size(); _sheets.add(clonedSheet); workbook.setSheetName(newSheetIndex, name); // Check this sheet has an autofilter, (which has a built-in NameRecord at workbook level) int filterDbNameIndex = findExistingBuiltinNameRecordIdx(sheetIndex, NameRecord.BUILTIN_FILTER_DB); if (filterDbNameIndex != -1) { NameRecord newNameRecord = workbook.cloneFilter(filterDbNameIndex, newSheetIndex); HSSFName newName = new HSSFName(this, newNameRecord); names.add(newName); } // TODO - maybe same logic required for other/all built-in name records workbook.cloneDrawings(clonedSheet.getSheet()); return clonedSheet; }