Posted 20 April 2023, 12:16 pm EST - Updated 20 April 2023, 12:22 pm EST
Hello!
I’m attempting to build a custom table and add it to an existing RDL Multi-Section report. I’m having trouble figuring out how to add it. The sample code I’m using from github is:
PageReport pageReport = new PageReport();
System.IO.FileInfo fi = new System.IO.FileInfo("C:\\My Dev\\PDSAPI\\PDSAPI\\Reports\\MFS.rdlx");
pageReport.Load(fi);
pageReport.Run();
//Creating a Table reportitem
Table table = new Table();
table.Name = "Table1";
//Creating the rows,columns as well as TableCells for the table as well as TextBoxes to be placed within the Table Cells
TextBox[] tableTextBoxes = new TextBox[6];
TableCell[] tableCells = new TableCell[6];
TableRow[] tableRows = new TableRow[2];
TableColumn[] tableColumns = new TableColumn[3];
String[] textBoxValues = new String[] { "Sample", "Test", "Data", "Column", "Headers", "Test" };
String[] columnsWidth = new String[] { "9cm", "4.6cm", "5.3cm" };
String[] rowsHeight = new String[] { "1.5cm", "1.5cm" };
//Setting properties for the Textboxes to be placed in the TableCells
for (int i = 0; i < tableTextBoxes.Length; i++)
{
tableTextBoxes.SetValue(new TextBox(), i);
tableTextBoxes[i].Name = "textBox" + (i + 1);
tableTextBoxes[i].Value = ExpressionInfo.FromString(textBoxValues[i]);
tableTextBoxes[i].Style.PaddingBottom = tableTextBoxes[i].Style.PaddingLeft = tableTextBoxes[i].Style.PaddingRight = tableTextBoxes[i].Style.PaddingTop = ExpressionInfo.FromString("2pt");
tableTextBoxes[i].Style.TextAlign = ExpressionInfo.FromString("Left");
tableCells.SetValue(new TableCell(), i);
tableCells[i].ReportItems.Add(tableTextBoxes[i]);//Adding the TextBoxes to the TableCells
if (i < rowsHeight.Length)
{
tableRows.SetValue(new TableRow(), i);
tableRows[i].Height = "1.25cm";
table.Height += "1.25cm";
}
if (i < columnsWidth.Length)
{
tableColumns.SetValue(new TableColumn(), i);
tableColumns[i].Width = columnsWidth[i];
table.Width += columnsWidth[i];
table.TableColumns.Add(tableColumns[i]);
tableCells[i].ReportItems[0].Style.BackgroundColor = ExpressionInfo.FromString("LightBlue");
tableRows[0].TableCells.Add(tableCells[i]);
}
else
{
tableCells[i].ReportItems[0].Style.BackgroundColor = ExpressionInfo.FromString("=Choose((RowNumber(\"Table1\") +1) mod 2, \"PaleGreen\",)");
tableRows[1].TableCells.Add(tableCells[i]);
}
}
table.Header.TableRows.Add(tableRows[0]);
table.Details.TableRows.Add(tableRows[1]);
table.Top = "1cm";
table.Left = "0.635cm";
pageReport.Report.Body.ReportItems.Add(table);
The pageReport.Report.Body.ReportItems is empty, even though I have 22 controls in the designer already. I found the controls buried very deep in the pageReport.Report object. I found them by clicking into pageReport.Report.Components. This gives me a component for PageReportModel.ReportSection. Drilling down into that object’s components show 2 components - one of which is a PageReportModel.Body. Clicking into the components of this object shows the 22 controls I have added to the report. I know this is where the table needs to be added, but I can’t figure out how to add it.
I’ve added screenshots to try to help explain.
How do I add the table object into the components?
