public void ImportCSV(string filePath) { if (!File.Exists(filePath)) { return; } if (Path.GetExtension(filePath) != ".csv") { return; } ImportFileTimeStamp = CDateTime.Now; ImportFile = filePath; var lines = File.ReadAllLines(filePath); var strings = lines.Select(line => line.Split(';')).ToArray(); var width = strings[0].Length; var height = strings.Length; var grid = new string[height, width]; for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { string value; try { value = strings[i][j]; } catch { value = string.Empty; } grid[i, j] = value; } } this.headers = new TDynArray <string>(); for (int i = 0; i < width; i++) { this.headers.Add(grid[0, i]); } this.data = new TDynArray <TDynArray <string> >(); for (int i = 1; i < height; i++) { var row = new TDynArray <string>(); for (int j = 0; j < width; j++) { row.Add(grid[i, j]); } this.data.Add(row); } }
public void AddRow() { var row = new TDynArray <string>(); for (int i = 0; i < headers.Count; i++) { row.Add(string.Empty); } data.Add(row); }
public void AddCollumn(string headerName) { if (string.IsNullOrWhiteSpace(headerName)) { return; } headers.Add(headerName); for (int i = 0; i < data.Count; i++) { data[i].Add(string.Empty); } }