List of usage examples for org.apache.poi.ss.usermodel Sheet setSelected
void setSelected(boolean value);
Note: multiple sheets can be selected, but only one sheet can be active at one time.
From source file:csv.impl.ExcelWriter.java
License:Open Source License
/** * This method selects the given sheet.//from www . j a va 2 s.co m * This will reset the internal row counter (see {@link #printRow(Object[])}). * @param sheet sheet to be selected */ public void selectSheet(Sheet sheet) { sheet.setSelected(true); rowNum = 0; maxColumns = -1; }
From source file:fr.amapj.service.engine.generator.excel.ExcelGeneratorTool.java
License:Open Source License
/** * Permet de dplacer la page courante l'index spcifi *//*w w w . java 2 s.co m*/ public void setSheetFirst() { int nb = wb.getNumberOfSheets(); // On construit la liste des noms des feuilles dans le bon ordre List<String> sheetName = new ArrayList<>(); sheetName.add(sheet.getSheetName()); for (int i = 0; i < nb - 1; i++) { Sheet s = wb.getSheetAt(i); sheetName.add(s.getSheetName()); } // On applique ensuite chaque feuille son nouveau numero d'ordre for (int i = 0; i < nb; i++) { wb.setSheetOrder(sheetName.get(i), i); Sheet s = wb.getSheetAt(i); if (i == 0) { s.setSelected(true); } else { s.setSelected(false); } } }
From source file:packtest.SelectedSheet.java
License:Apache License
public static void main(String[] args) throws IOException { Workbook wb = new XSSFWorkbook(); //or new HSSFWorkbook(); wb.createSheet("row sheet"); wb.createSheet("another sheet"); Sheet sheet3 = wb.createSheet(" sheet 3 "); sheet3.setSelected(true); wb.setActiveSheet(2);//from w ww . java2s . c o m // Create various cells and rows for spreadsheet. FileOutputStream fileOut = new FileOutputStream("selectedSheet.xlsx"); wb.write(fileOut); fileOut.close(); wb.close(); }
From source file:poi.xssf.usermodel.examples.SelectedSheet.java
License:Apache License
public static void main(String[] args) throws Exception { Workbook wb = new XSSFWorkbook(); //or new HSSFWorkbook(); Sheet sheet = wb.createSheet("row sheet"); Sheet sheet2 = wb.createSheet("another sheet"); Sheet sheet3 = wb.createSheet(" sheet 3 "); sheet3.setSelected(true); wb.setActiveSheet(2);// w w w . ja va 2 s.c o m // Create various cells and rows for spreadsheet. FileOutputStream fileOut = new FileOutputStream("selectedSheet.xlsx"); wb.write(fileOut); fileOut.close(); }