/** * sets the order of appearance for a given sheet. * * @param sheetname the name of the sheet to reorder * @param pos the position that we want to insert the sheet into (0 based) */ @Override public void setSheetOrder(String sheetname, int pos) { int idx = getSheetIndex(sheetname); sheets.add(pos, sheets.remove(idx)); // Reorder CTSheets CTSheets ct = workbook.getSheets(); XmlObject cts = ct.getSheetArray(idx).copy(); workbook.getSheets().removeSheet(idx); CTSheet newcts = ct.insertNewSheet(pos); newcts.set(cts); //notify sheets //noinspection deprecation CTSheet[] sheetArray = ct.getSheetArray(); for(int i=0; i < sheetArray.length; i++) { sheets.get(i).sheet = sheetArray[i]; } updateNamedRangesAfterSheetReorder(idx, pos); updateActiveSheetAfterSheetReorder(idx, pos); }
/** * sets the order of appearance for a given sheet. * * @param sheetname the name of the sheet to reorder * @param pos the position that we want to insert the sheet into (0 based) */ public void setSheetOrder(String sheetname, int pos) { int idx = getSheetIndex(sheetname); sheets.add(pos, sheets.remove(idx)); // Reorder CTSheets CTSheets ct = workbook.getSheets(); XmlObject cts = ct.getSheetArray(idx).copy(); workbook.getSheets().removeSheet(idx); CTSheet newcts = ct.insertNewSheet(pos); newcts.set(cts); //notify sheets for(int i=0; i < sheets.size(); i++) { sheets.get(i).sheet = ct.getSheetArray(i); } }
/** * sets the order of appearance for a given sheet. * * @param sheetname the name of the sheet to reorder * @param pos the position that we want to insert the sheet into (0 based) */ @Override public void setSheetOrder(String sheetname, int pos) { int idx = getSheetIndex(sheetname); sheets.add(pos, sheets.remove(idx)); // Reorder CTSheets CTSheets ct = workbook.getSheets(); XmlObject cts = ct.getSheetArray(idx).copy(); workbook.getSheets().removeSheet(idx); CTSheet newcts = ct.insertNewSheet(pos); newcts.set(cts); //notify sheets //noinspection deprecation CTSheet[] sheetArray = ct.getSheetArray(); for(int i=0; i < sheetArray.length; i++) { sheets.get(i).sheet = sheetArray[i]; } updateNamedRangesAfterSheetReorder(idx, pos); updateActiveSheetAfterSheetReorder(idx, pos); }