You need to capture the first sheet at the beginning and then move the other sheets - beginning with the most right - before that sheet.
This works for me:
private void buttonSheetReverseOrder_Click(object sender, EventArgs e)
{
Microsoft.Office.Interop.Excel.Application _excel = new _Excel.Application();
_excel.DisplayAlerts = false;
Workbook workbook = _excel.Workbooks.Open(@"c:\temp\cp.excel\ExcelReverseSheetOrder.xlsx");
Worksheet firstSheet = workbook.Sheets[1];
for (int ix= workbook.Sheets.Count; ix > 1; ix--)
{
workbook.Sheets[workbook.Sheets.Count].Move(firstSheet);
}
workbook.SaveAs(@"c:\temp\cp.excel\ExcelMovedSheets.xlsx");
workbook.Close();
}
[Edit]
In case we have the sheets 'Total', 'Dec' ..... 'Jan' and we need them to reorder to 'Total', 'Jan' ..... 'Dec' we can do it this way:
private void buttonSheetReverseOrder_Click(object sender, EventArgs e)
{
Microsoft.Office.Interop.Excel.Application _excel = new _Excel.Application();
_excel.DisplayAlerts = false;
Workbook workbook = _excel.Workbooks.Open(@"c:\temp\cp.excel\ExcelReverseSheetOrder.xlsx");
Worksheet firstSheet = workbook.Sheets[2];
for (int ix = 13; ix > 2; ix--)
{
workbook.Sheets[workbook.Sheets.Count].Move(firstSheet);
}
workbook.SaveAs(@"c:\temp\cp.excel\ExcelMovedSheets.xlsx");
workbook.Close();
}