Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            var path = @"BVV000732480032.xlsx";

            try
            {
                var td = ExcelFileHelper.ReadExcelToCSVFormat(path);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            Console.ReadKey();
        }
Ejemplo n.º 2
0
        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());
        }