Ejemplo n.º 1
0
 private static void PlaceZAxis(this Table table, ExcelWorksheet worksheet, ExcelCoordinate start)
 {
     table.
     Axes.
     Where(a => a.Direction == Direction.Z).
     Where(a => a.IsOpen).
     OrderBy(a => a.Order).
     SelectMany(a => a.Ordinates).
     OrderBy(o => o.Path).
     Select(o => $"*{o.Code}").
     Select((o, i) => Tuple.Create(o, start.Column + i)).
     ToList().
     ForEach(o => worksheet.Cells[start.Row, o.Item2].Value = o.Item1);
 }
Ejemplo n.º 2
0
        private static void PlaceCellNames(ExcelWorksheet worksheet, List <Tuple <string, int> > rows, List <Tuple <string, int> > columns, string tableCode, ExcelCoordinate start)
        {
            var cells = rows.SelectMany(r => columns.Select(c => (new[] { r, c }))).ToList();

            cells.ForEach(rc => worksheet.Cells[start.Row + rc.First().Item2, start.Column + rc.Last().Item2].Value = GetCellName(tableCode, rc));
            cells.ForEach(rc => worksheet.Names.Add(GetCellName(tableCode, rc), worksheet.Cells[start.Row + rc.First().Item2, start.Column + rc.Last().Item2]));
        }
Ejemplo n.º 3
0
        public static ExcelCoordinate WriteToWorksheet(this Table table, ExcelWorksheet worksheet, ExcelCoordinate start)
        {
            worksheet.Cells[start.Row, start.Column].Value = table.Code;
            var size = table.PlaceTableAxes(worksheet, start);

            return(start.Add(size));
        }
Ejemplo n.º 4
0
        public static TableSize PlaceTableAxes(this Table table, ExcelWorksheet worksheet, ExcelCoordinate start)
        {
            table.PlaceZAxis(worksheet, start.Offset(0, 2));

            var columns = table.GetColumns();

            PlaceColumns(worksheet, columns, start.Offset(2, 2));

            var rows = table.GetRows();

            PlaceRows(worksheet, rows, start.Offset(3, 1));

            var size = new TableSize(columns.Count, rows.Count);

            PlaceCellNames(worksheet, rows, columns, table.Code, start.Offset(3, 2));
            PlaceDataArea(worksheet, table.Code, start.Offset(3, 2), size);

            return(size);
        }
Ejemplo n.º 5
0
 private static void PlaceRows(ExcelWorksheet worksheet, List <Tuple <string, int> > rows, ExcelCoordinate start)
 => rows.ForEach(o => worksheet.Cells[start.Row + o.Item2, start.Column].Value = o.Item1);
Ejemplo n.º 6
0
 private static void PlaceColumns(ExcelWorksheet worksheet, List <Tuple <string, int> > columns, ExcelCoordinate start)
 => columns.ForEach(o => worksheet.Cells[start.Row, start.Column + o.Item2].Value = o.Item1);
Ejemplo n.º 7
0
 private static void PlaceDataArea(ExcelWorksheet worksheet, string tableCode, ExcelCoordinate start, TableSize size)
 => worksheet.Names.Add(GetDataAreaName(tableCode), worksheet.Cells[start.Row, start.Column, start.Row + size.Rows - 1, start.Column + size.Columns - 1]);