private void WritePage(string header, string[] rows) { SplitColumnResult splitResult = SplitInColumn(rows, header); int[] columnWidth = CalcColumnWidth(splitResult); WriteHeader(splitResult.HeaderCol, columnWidth); WriteDataRow(splitResult.DataCol, columnWidth); WriteFooter(); }
private SplitColumnResult SplitInColumn(string[] rows, string header) { var result = rows.Select(s => s.Split(new [] { ';' }, StringSplitOptions.None)); var headerResult = header.Split(new[] { ';' }, StringSplitOptions.None); var splitColumnResult = new SplitColumnResult { DataCol = result, HeaderCol = headerResult, }; return(splitColumnResult); }
private int[] CalcColumnWidth(SplitColumnResult splitResult) { var unitedCols = splitResult.DataCol.Union(new[] { splitResult.HeaderCol }); var result = new int[splitResult.HeaderCol.Length]; foreach (var unitedCol in unitedCols) { for (int i = 0; i < unitedCol.Length; i++) { result[i] = Math.Max(result[i], unitedCol[i].Length); } } return(result); }