@Test void renameSheetTest() throws IOException, InvalidFormatException { File file = ResourceUtils.getFile(getClass(), "/test.xls"); File temp = File.createTempFile("unittest_", ".xls"); FileUtils.copyFile(file, temp); ExcelUtils.renameSheet("unittest", temp, 0); Workbook workbook = WorkbookFactory.create(new FileInputStream(temp)); assertEquals("unittest", workbook.getSheetAt(0).getSheetName()); }
public static void renameSheet(String newSheetname, File file, int index) { try (FileInputStream fis = new FileInputStream(file); Workbook workbook = WorkbookFactory.create(fis)) { workbook.setSheetName(index, newSheetname); workbook.write(new FileOutputStream(file)); } catch (Exception e) { throw new MolgenisDataException(e); } }
ExcelUtils { public static void renameSheet(String newSheetname, File file, int index) { try (FileInputStream fis = new FileInputStream(file); Workbook workbook = WorkbookFactory.create(fis)) { workbook.setSheetName(index, newSheetname); workbook.write(new FileOutputStream(file)); } catch (Exception e) { throw new MolgenisDataException(e); } } }
ExcelUtils { public static void renameSheet(String newSheetname, File file, int index) { try (FileInputStream fis = new FileInputStream(file); Workbook workbook = WorkbookFactory.create(fis)) { workbook.setSheetName(index, newSheetname); workbook.write(new FileOutputStream(file)); } catch (Exception e) { throw new MolgenisDataException(e); } } private  ExcelUtils(); }
ExcelUtils { public static void renameSheet(String newSheetname, File file, int index) { try (FileInputStream fis = new FileInputStream(file); Workbook workbook = WorkbookFactory.create(fis)) { workbook.setSheetName(index, newSheetname); workbook.write(new FileOutputStream(file)); } catch (Exception e) { throw new MolgenisDataException(e); } } private  ExcelUtils(); static void renameSheet(String newSheetname, File file, int index); static int getNumberOfSheets(File file); static boolean isExcelFile(String filename); }
ExcelUtils { public static void renameSheet(String newSheetname, File file, int index) { try (FileInputStream fis = new FileInputStream(file); Workbook workbook = WorkbookFactory.create(fis)) { workbook.setSheetName(index, newSheetname); workbook.write(new FileOutputStream(file)); } catch (Exception e) { throw new MolgenisDataException(e); } } private  ExcelUtils(); static void renameSheet(String newSheetname, File file, int index); static int getNumberOfSheets(File file); static boolean isExcelFile(String filename);  }