Exemplo n.º 1
0
        public XlsCrossDataTableBuilder(ReportDef report, CrossDataTable table)
        {
            Report = report;
            Table  = table;

            Headers.Add(new XlsGridReportSectionText(Report.Caption));
        }
        public XlsCrossDataTableAdjustInfo(CrossDataTable table)
        {
            //FormId = report.Id;

            if (table.Columns != null)
            {
                foreach (var column in table.ColumnItems())
                {
                    AddControlBand(column);
                }
            }
        }
        private void AddColumn(CrossDataTable table, ReportDef report, SqlQueryReader reader, ReportAttributeColumnDef column, Dictionary <Guid, SqlQuerySource> sourceMap,
                               SqlQueryDataSet dataSet, Dictionary <CrossDataColumn, SqlQueryDataSetField> columnMaps)
        {
            SqlQuerySource querySource;
            var            reportSource     = report.GetSourceDef(column.Attribute.SourceId);
            var            reportSourceAttr = reportSource.Attributes != null
                ? reportSource.Attributes.FirstOrDefault(a => a.Id == column.Attribute.AttributeId)
                : null;

            var hasQuerySource = sourceMap.TryGetValue(column.Attribute.SourceId, out querySource);

            var attr = reportSourceAttr == null
                ? !hasQuerySource
                    ? reader.Query.FindAttribute(column.Attribute.AttributeId)
                    : reader.Query.FindAttribute(querySource, column.Attribute.AttributeId)
                : !hasQuerySource
                    ? reader.Query.FindAttribute(reportSourceAttr.Ident)
                    : reader.Query.FindAttribute(querySource, reportSourceAttr.Ident);

            if (attr != null)
            {
                var i = reader.Query.Attributes.IndexOf(attr);

                if (column.Grouping == ReportColumnGroupingType.None ||
                    column.Grouping == ReportColumnGroupingType.Group)
                {
                    var crossColumn = new CrossDataKeyColumn(i, column.Caption);
                    table.AddColumn(crossColumn);
                    columnMaps.Add(crossColumn,
                                   new SqlQueryDataSetField(dataSet, attr,
                                                            column.Grouping == ReportColumnGroupingType.None
                                ? SqlQuerySummaryFunction.None
                                : SqlQuerySummaryFunction.Group));
                }
                else if (column.Grouping == ReportColumnGroupingType.CrossGroup)
                {
                    var crossColumn = new CrossDataGroupColumn(i, column.Caption);
                    table.AddColumn(crossColumn);
                    columnMaps.Add(crossColumn, new SqlQueryDataSetField(dataSet, attr));
                }
                else
                {
                    var crossColumn = new CrossDataFuncColumn(i, column.Caption, column.ToSqlGrouping());
                    table.AddColumn(crossColumn);
                    columnMaps.Add(crossColumn, new SqlQueryDataSetField(dataSet, attr, column.ToSqlGrouping()));
                }
            }
        }
        private CrossDataTable CreateCrossDataTable(ReportDef report, SqlQueryReader reader)
        {
            var table      = new CrossDataTable();
            var sourceMap  = MapSources(report, reader);
            var columnMaps = new Dictionary <CrossDataColumn, SqlQueryDataSetField>();
            var dataSet    = new SqlQueryDataSet(Provider, reader);

            if (report.Columns != null)
            {
                foreach (var column in report.Columns.OfType <ReportAttributeColumnDef>())
                {
                    AddColumn(table, report, reader, column, sourceMap, dataSet, columnMaps);
                }
            }

            table.Fill(dataSet, columnMaps);

            return(table);
        }
Exemplo n.º 5
0
 private void AdjustReportColumns(CrossDataTable table)
 {
     Headers.ForEach(_adjuster.AddReportSection);
     _adjuster.Forms.Add(new XlsCrossDataTableAdjustInfo(table));
     Footers.ForEach(_adjuster.AddReportSection);
 }