Question: I want to rearrange the sheets being generated before writing it to an xls document using apache poi in java. Is there any way of doing it?
For ex:sheet Names are "RF for 10","Blended for 10","RF for 30","Blended for 30".

I want the xls to be generated in the following order of sheets:
"RF for 10","RF for 30","Blended for 10","Blended for 30".

Answer: 
You can rearrange the order of the sheets in a workbook with the [`setSheetOrder`](http://poi.apache.org/apidocs/org/apache/poi/ss/usermodel/Workbook.html#setSheetOrder(java.lang.String,%20int)) method of the `Workbook` class.
You can create a new sheet in a specific position of the book. 

```
 * Create a new sheet in a specific position of the book, if the sheet name has
 * 32 characters or more the method createSafeSheetName get 31 characters and
 * remove unsafe characters
 * 
 * @param book      book of excel
 * @param nameSheet Sheet name
 * @param position  index of the new sheet

 * @return
 */
protected Sheet createSheet(XSSFWorkbook book, String nameSheet, Integer positionSheet) {
    Sheet sheet = book.createSheet(WorkbookUtil.createSafeSheetName(nameSheet));
    book.setSheetOrder(sheet.getSheetName(), positionSheet);
    return sheet;
}

```