Posts Tagged ‘excel to csv’
Split an Excel file’s tabs into CSV with C#
Split an Excel file into csv, with each tab going into a separate csv file, in the background using C#.
using System.IO; using Microsoft.Office.Interop.Excel; Microsoft.Office.Interop.Excel.Application app = new Microsoft.Office.Interop.Excel.Application(); //Run in background app.DisplayAlerts = false; //Open excel file Workbook wb = app.Workbooks.Open("path_to_excel.xls"); //Iterate through sheets in the excel file foreach (Worksheet sheet in wb.Worksheets) { string sheetName = sheet.Name; //Output file name string outputFilepath = sheetName + ".csv"; //Save the sheet as CSV sheet.SaveAs(outputFilepath, XlFileFormat.xlCSVWindows); } //Clean-up wb.Close(); app.Quit();