Example #1
0
        static ReportBuilder InitAutoGenerateReport(ReportBuilder reportBuilder)
        {
            if (reportBuilder != null && reportBuilder.DataSource != null && reportBuilder.DataSource.Tables.Count > 0)
            {
                DataSet ds = reportBuilder.DataSource;

                int _TablesCount = ds.Tables.Count;
                ReportTable[] reportTables = new ReportTable[_TablesCount];

                if (reportBuilder.AutoGenerateReport)
                {
                    for (int j = 0; j < _TablesCount; j++)
                    {
                        DataTable dt = ds.Tables[j];
                        ReportColumns[] columns = new ReportColumns[dt.Columns.Count];
                        ReportScale ColumnScale = new ReportScale();
                        ColumnScale.Width = 4;
                        ColumnScale.Height = 1;
                        ReportDimensions ColumnPadding = new ReportDimensions();
                        ColumnPadding.Default = 2;
                        for (int i = 0; i < dt.Columns.Count; i++)
                        {
                            columns[i] = new ReportColumns() { ColumnCell = new ReportTextBoxControl() { Name = dt.Columns[i].ColumnName, Size = ColumnScale, Padding = ColumnPadding }, HeaderText = dt.Columns[i].ColumnName, HeaderColumnPadding = ColumnPadding };
                        }

                        reportTables[j] = new ReportTable() { ReportName = dt.TableName, ReportDataColumns = columns };
                    }

                }
                reportBuilder.Body = new ReportBody();
                reportBuilder.Body.ReportControlItems = new ReportItems();
                reportBuilder.Body.ReportControlItems.ReportTable = reportTables;
            }
            return reportBuilder;
        }
Example #2
0
        private static string GetDataSetFields(ReportColumns[] reportColumns)
        {
            string strFields = "";

            strFields += @"<Fields>";
            for (int i = 0; i < reportColumns.Length; i++)
            {
                strFields += @"<Field Name=""" + reportColumns[i].ColumnCell.Name + @""">
              <DataField>" + reportColumns[i].ColumnCell.Name + @"</DataField>
              <rd:TypeName>System.String</rd:TypeName>
            </Field>";
            }
            strFields += @"</Fields>";
            return strFields;
        }