static string GenerateTableHeaderRow(ReportBuilder reportBuilder, ReportTable table) { ReportColumns[] columns = table.ReportDataColumns; ReportTextBoxControl ColumnCell = new ReportTextBoxControl(); ReportDimensions padding = new ReportDimensions(); if (columns == null) return ""; string strTableRow = ""; strTableRow = @"<TablixRow> <Height>0.6cm</Height> <TablixCells>"; for (int i = 0; i < columns.Length; i++) { ColumnCell = columns[i].ColumnCell; padding = columns[i].HeaderColumnPadding; strTableRow += @"<TablixCell> <CellContents> " + GenerateTextBox("txtHeader_" + table.ReportName + "_", ColumnCell.Name, columns[i].HeaderText == null || columns[i].HeaderText.Trim() == "" ? ColumnCell.Name : columns[i].HeaderText, false, padding) + @" </CellContents> </TablixCell>"; } strTableRow += @"</TablixCells></TablixRow>"; return strTableRow; }
static string GenerateTableRow(ReportBuilder reportBuilder, ReportTable table) { ReportColumns[] columns = table.ReportDataColumns; ReportTextBoxControl ColumnCell = new ReportTextBoxControl(); ReportScale colHeight = ColumnCell.Size; ReportDimensions padding = new ReportDimensions(); if (columns == null) return ""; string strTableRow = ""; strTableRow = @"<TablixRow> <Height>0.6cm</Height> <TablixCells>"; for (int i = 0; i < columns.Length; i++) { ColumnCell = columns[i].ColumnCell; padding = ColumnCell.Padding; strTableRow += @"<TablixCell> <CellContents> " + GenerateTextBox("txtCell_" + table.ReportName + "_", ColumnCell.Name, "", true, padding) + @" </CellContents> </TablixCell>"; } strTableRow += @"</TablixCells></TablixRow>"; return strTableRow; }
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; }
static string GetTextBox(string textBoxName, ReportDimensions padding = null, params string[] strValues) { string strTextBox = ""; strTextBox = @" <Textbox Name=""" + textBoxName + @"""> <CanGrow>true</CanGrow> <KeepTogether>true</KeepTogether> <Paragraphs> <Paragraph> <TextRuns>"; for (int i = 0; i < strValues.Length; i++) { strTextBox += GetTextRun(strValues[i].ToString()); } strTextBox += @"</TextRuns> <Style /> </Paragraph> </Paragraphs> <rd:DefaultName>" + textBoxName + @"</rd:DefaultName> <Top>1.0884cm</Top> <Left>0cm</Left> <Height>0.6cm</Height> <Width>7.93812cm</Width> <ZIndex>2</ZIndex> <Style> <Border> <Style>None</Style> </Border>"; strTextBox += GetDimensions(padding) + @"</Style> </Textbox>"; return strTextBox; }
private static string GetDimensions(ReportDimensions padding = null) { string strDimensions = ""; if (padding != null) { if (padding.Default == 0) { strDimensions += string.Format("<PaddingLeft>{0}pt</PaddingLeft>", padding.Left); strDimensions += string.Format("<PaddingRight>{0}pt</PaddingRight>", padding.Right); strDimensions += string.Format("<PaddingTop>{0}pt</PaddingTop>", padding.Top); strDimensions += string.Format("<PaddingBottom>{0}pt</PaddingBottom>", padding.Bottom); } else { strDimensions += string.Format("<PaddingLeft>{0}pt</PaddingLeft>", padding.Default); strDimensions += string.Format("<PaddingRight>{0}pt</PaddingRight>", padding.Default); strDimensions += string.Format("<PaddingTop>{0}pt</PaddingTop>", padding.Default); strDimensions += string.Format("<PaddingBottom>{0}pt</PaddingBottom>", padding.Default); } } return strDimensions; }
static string GenerateTextBox(string strControlIDPrefix, string strName, string strValueOrExpression = "", bool isFieldValue = true, ReportDimensions padding = null) { string strTextBox = ""; strTextBox = @" <Textbox Name=""" + strControlIDPrefix + strName + @"""> <CanGrow>true</CanGrow> <KeepTogether>true</KeepTogether> <Paragraphs> <Paragraph> <TextRuns> <TextRun>"; if (isFieldValue) strTextBox += @"<Value>=Fields!" + strName + @".Value</Value>"; else strTextBox += @"<Value>" + strValueOrExpression + "</Value>"; strTextBox += @"<Style /> </TextRun> </TextRuns> <Style /> </Paragraph> </Paragraphs> <rd:DefaultName>" + strControlIDPrefix + strName + @"</rd:DefaultName> <Style> <Border> <Color>LightGrey</Color> <Style>Solid</Style> </Border>" + GetDimensions(padding) + @"</Style> </Textbox>"; return strTextBox; }