private void RenderDataTableBody(SheetContext sheetContext, DataTabler dataTabler)
        {
            var dataTableDataLocation = dataTabler.DataStart;

            var columns     = DataSource.Columns;
            var rows        = DataSource.Rows;
            int columnIndex = 0;
            int rowIndex    = 0;

            foreach (DataColumn dataColumn in columns)
            {
                rowIndex = 0;
                foreach (DataRow dataRow in rows)
                {
                    int   rowLocation    = dataTableDataLocation.RowIndex + rowIndex;
                    int   columnLocation = dataTableDataLocation.ColumnIndex + columnIndex;
                    ICell cell           = sheetContext.GetCell(rowLocation, columnLocation, copyBeforeColumnCell: true);
                    if (null == cell)
                    {
                        throw new RenderException($"DataTable [{dataTabler.Name}],cell[{rowLocation},{columnLocation}] is null");
                    }
                    cell.Value = dataRow[dataColumn].CastTo <string>();
                    rowIndex  += 1;
                }
                columnIndex += 1;
            }
        }
        private void RenderDataTableHender(SheetContext sheetContext, DataTabler dataTabler)
        {
            var dataTableHeaderLocation = dataTabler.HeaderStart;

            var columns              = DataSource.Columns;
            int columnCount          = columns.Count;
            int rowHeaderLocation    = dataTableHeaderLocation.RowIndex;
            int columnHeaderLocation = dataTableHeaderLocation.ColumnIndex + columns.Count - 1;

            for (int startH = dataTableHeaderLocation.ColumnIndex; startH < columnHeaderLocation; startH++)
            {
                ICell cell = sheetContext.GetCell(rowHeaderLocation, startH, copyBeforeColumnCell: true);
                if (null == cell)
                {
                    throw new RenderException($"DataTable[{dataTabler.Name}],cell[{rowHeaderLocation},{startH}] is null");
                }
            }
            sheetContext.MergeCells(rowHeaderLocation, rowHeaderLocation, dataTableHeaderLocation.ColumnIndex, columnHeaderLocation);

            ICell merageCell = sheetContext.GetCell(dataTableHeaderLocation);

            merageCell.Value = DataSource.TableName.CastTo <string>();
        }
Beispiel #3
0
        public void Render(SheetContext sheetContext)
        {
            Parameter parameter = sheetContext.WorksheetContainer.Parameters[Name];

            foreach (var location in parameter.Locations)
            {
                ICell cell = sheetContext.GetCell(location);
                if (null == cell)
                {
                    throw new RenderException($"parameter[{parameter.Name}],cell[{location.RowIndex},{location.ColumnIndex}] is null");
                }
                var parameterName = $"$[{parameter.Name}]";
                if (parameterName.Equals(cell.GetStringValue().Trim()))
                {
                    cell.Value = Value;
                }
                else
                {
                    cell.Value = (cell.GetStringValue().Replace(parameterName, Value.CastTo <string>()));
                }
            }
        }