1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| // Ouvrir Excel :
Microsoft.Office.Interop.Excel.Application appExcel = new Microsoft.Office.Interop.Excel.Application();
appExcel.DisplayAlerts = false;
// Ouvrir le classeur :
Microsoft.Office.Interop.Excel.Workbook wkbExcel = appExcel.Workbooks.Open(@"D:\Classeur.xls", Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing);
// Boucler sur les feuilles :
foreach (Microsoft.Office.Interop.Excel.Worksheet sheet in wkbExcel.Worksheets)
{
// Enregistrer la feuille en csv :
sheet.SaveAs(@"D:\" + sheet.Name + ".csv", Microsoft.Office.Interop.Excel.XlFileFormat.xlCSV, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing);
}
// Fermer le classeur et Excel :
wkbExcel.Close(Type.Missing, Type.Missing, Type.Missing);
wkbExcel = null;
appExcel.Quit();
appExcel = null; |