static void Main(string[] args) { var path = @"BVV000732480032.xlsx"; try { var td = ExcelFileHelper.ReadExcelToCSVFormat(path); } catch (Exception ex) { Console.WriteLine(ex.Message); } Console.ReadKey(); }
public static string[] ReadExcelToCSVFormat(string path) { var stringLines = new List <string>(); var lineBuilder = new StringBuilder(); var td = ExcelFileHelper.ReadExcelToTable(path); var columnCount = td.Columns.Count; for (int i = 0; i < td.Rows.Count; i++) { lineBuilder.Clear(); for (int j = 1; j <= td.Columns.Count; j++) { lineBuilder.Append($"{td.Rows[i][$"F{j}"].ToString()},"); } stringLines.Add(lineBuilder.ToString()); } return(stringLines.ToArray()); }