Пример #1
0
        public ITableRowBuilder <TSource> Apply()
        {
            int indexColumn = 0;
            var data        = _dataFunc().ToList();

            foreach (var item in data)
            {
                foreach (var row in _columnSources.GroupBy(x => x.Row).ToList())
                {
                    indexColumn = _tablePositionFinder.GetColumnForNewRow();
                    foreach (var column in row)
                    {
                        var columnOptionsBuilder = new ColumnOptionsBuilder <TSource>();
                        column.ActionOptions?.Invoke(columnOptionsBuilder);
                        ColumnOptions options = columnOptionsBuilder;

                        // set color if present function
                        options.TextColor       = columnOptionsBuilder.TextColorFunc?.Invoke(item) ?? options.TextColor;
                        options.BackgroundColor = columnOptionsBuilder.BackgroundColorFunc?.Invoke(item) ?? options.BackgroundColor;

                        var pos = _tablePositionFinder.GetNewPosition(indexColumn, options.Colspan, options.Rowspan);

                        setExcelRange(column.SelectorFunc?.Invoke(item) ?? "", pos, options);
                        indexColumn = indexColumn + options.Colspan;
                    }
                }
            }

            return(this);
        }
Пример #2
0
 internal Position GetPositionForCurrentColumn(int colspan, int rowspan)
 {
     return(_tablePositionFinder.GetNewPosition(_currentColumn, colspan, rowspan));
 }