@SuppressWarnings("deprecation")
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
CTSheet[] sheetArray = ct.getSheetArray();
for(int i=0; i < sheetArray.length; i++) {
sheets.get(i).sheet = sheetArray[i];
}
}