public ActionResult PrintFormDataList(Guid formId) { try { var source = FormGeneratorComponent.Instance.FormDataFacade.ReportFormDataForExcel(formId, SessionParameters.Culture); StiReport report = new StiReport { ScriptLanguage = StiReportLanguageType.CSharp }; report.Dictionary.Synchronize(); report.Load(Server.MapPath("~/Areas/FormGenerator/Reports/RptFormDataList.mrt")); StiPage page = report.Pages.Items[0]; var pageConponents = page.GetComponents(); StiTable table = (StiTable)pageConponents[0]; table.ColumnCount = source.Columns.Count; table.RowCount = source.Rows.Count + 1; table.HeaderRowsCount = 1; table.Width = page.Width; table.Height = page.GridSize * 12; table.CreateCell(); int indexHeaderCell = 0; foreach (DataColumn column in source.Columns) { var headerCell = table.Components[indexHeaderCell] as StiTableCell; if (headerCell != null) { headerCell.Text.Value = column.Caption; headerCell.HorAlignment = StiTextHorAlignment.Center; headerCell.VertAlignment = StiVertAlignment.Center; headerCell.Border = new StiBorder(StiBorderSides.All, Color.FromArgb(32, 178, 170), 1, StiPenStyle.Solid); } indexHeaderCell++; } foreach (DataRow row in source.Rows) { foreach (DataColumn column in source.Columns) { var headerCell = table.Components[indexHeaderCell] as StiTableCell; if (headerCell != null) { headerCell.Text.Value = row[column].ToString(); headerCell.HorAlignment = StiTextHorAlignment.Center; headerCell.VertAlignment = StiVertAlignment.Center; headerCell.Border = new StiBorder(StiBorderSides.All, Color.FromArgb(32, 178, 170), 1, StiPenStyle.Solid); } indexHeaderCell++; } } SessionParameters.Report = report; return(Content("true")); } catch (Exception ex) { ShowExceptionMessage(ex); return(Content("false")); } }
async private void buttonCreateReport_Click(object sender, RoutedEventArgs e) { StiReport report = new StiReport(); report.ScriptLanguage = StiReportLanguageType.CSharp; report.RegBusinessObject("view", "view", CreateBusinessObject()); report.Dictionary.SynchronizeBusinessObjects(); StiPage page = report.Pages[0]; //Create Table StiTable table = new StiTable(); table.Name = "Table1"; if (rbAWNone.IsChecked == true) { table.AutoWidth = StiTableAutoWidth.None; } else if (rbAWPage.IsChecked == true) { table.AutoWidth = StiTableAutoWidth.Page; } else { table.AutoWidth = StiTableAutoWidth.Table; } if (rbAWTNone.IsChecked == true) { table.AutoWidthType = StiTableAutoWidthType.None; } else if (rbAWTFullTable.IsChecked == true) { table.AutoWidthType = StiTableAutoWidthType.FullTable; } else { table.AutoWidthType = StiTableAutoWidthType.LastColumns; } table.ColumnCount = 3; table.RowCount = 3; table.HeaderRowsCount = 1; table.FooterRowsCount = 1; table.Width = page.Width; table.Height = page.GridSize * 12; table.BusinessObjectGuid = report.Dictionary.BusinessObjects[0].Guid; page.Components.Add(table); table.CreateCell(); table.TableStyle = StiTableStyle.Style59; int indexHeaderCell = 0; int indexDataCell = 3; string[] columns = new string[] { "Column1", "Column2", "Column3" }; foreach (string column in columns) { //Set text on header StiTableCell headerCell = table.Components[indexHeaderCell] as StiTableCell; headerCell.Text.Value = column; headerCell.HorAlignment = StiTextHorAlignment.Center; headerCell.VertAlignment = StiVertAlignment.Center; StiTableCell dataCell = table.Components[indexDataCell] as StiTableCell; dataCell.Text.Value = "{view." + column + "}"; dataCell.Border = new StiBorder(StiBorderSides.All, Color.FromArgb(255, 32, 178, 170), 1, StiPenStyle.Dash); indexHeaderCell++; indexDataCell++; } StiTableCell dataCheckBoxCell = table.Components[indexDataCell - 1] as StiTableCell; dataCheckBoxCell.CellType = StiTablceCellType.CheckBox; //Set text on footer StiTableCell footerCell = table.Components[table.Components.Count - 1] as StiTableCell; footerCell.Text.Value = "Count - {Count()}"; footerCell.Font = new Font("Arial", 15, System.Drawing.FontStyle.Bold); footerCell.VertAlignment = StiVertAlignment.Center; footerCell.HorAlignment = StiTextHorAlignment.Center; //Render without progress bar await report.RenderAsync(); viewerControl.Report = report; }
private void PrintDataGrid(DataGrid sender) { DataView dataView = (DataView)sender.DataSource; StiReport report = new StiReport(); report.ScriptLanguage = StiReportLanguageType.CSharp; //Add data to datastore report.RegData("view", dataView); //Fill dictionary report.Dictionary.Synchronize(); StiPage page = report.Pages.Items[0]; //Create Table StiTable table = new StiTable(); table.Name = "Table1"; if (rbAWNone.Checked) { table.AutoWidth = StiTableAutoWidth.None; } else if (rbAWPage.Checked) { table.AutoWidth = StiTableAutoWidth.Page; } else { table.AutoWidth = StiTableAutoWidth.Table; } if (rbAWTNone.Checked) { table.AutoWidthType = StiTableAutoWidthType.None; } else if (rbAWTFullTable.Checked) { table.AutoWidthType = StiTableAutoWidthType.FullTable; } else { table.AutoWidthType = StiTableAutoWidthType.LastColumns; } table.ColumnCount = 3; table.RowCount = 3; table.HeaderRowsCount = 1; table.FooterRowsCount = 1; table.Width = page.Width; table.Height = page.GridSize * 12; table.DataSourceName = "view" + dataView.Table.TableName; page.Components.Add(table); table.CreateCell(); table.TableStyleFX = new StiTable27StyleFX(); table.TableStyle = Stimulsoft.Report.Components.Table.StiTableStyle.Style59; int indexHeaderCell = 0; int indexDataCell = 3; foreach (DataColumn column in dataView.Table.Columns) { //Set text on header StiTableCell headerCell = table.Components[indexHeaderCell] as StiTableCell; headerCell.Text.Value = column.Caption; headerCell.HorAlignment = StiTextHorAlignment.Center; headerCell.VertAlignment = StiVertAlignment.Center; StiTableCell dataCell = table.Components[indexDataCell] as StiTableCell; dataCell.Text.Value = "{view" + dataView.Table.TableName + "." + Stimulsoft.Report.CodeDom.StiCodeDomSerializator.ReplaceSymbols(column.ColumnName) + "}"; dataCell.Border = new StiBorder(StiBorderSides.All, Color.FromArgb(32, 178, 170), 1, StiPenStyle.Dash); indexHeaderCell++; indexDataCell++; } StiTableCell dataCheckBoxCell = table.Components[indexDataCell - 1] as StiTableCell; dataCheckBoxCell.CellType = StiTablceCellType.CheckBox; //Set text on footer StiTableCell footerCell = table.Components[table.Components.Count - 1] as StiTableCell; footerCell.Text.Value = "Count - {Count()}"; footerCell.Font = new Font("Arial", 15, FontStyle.Bold); footerCell.VertAlignment = StiVertAlignment.Center; footerCell.HorAlignment = StiTextHorAlignment.Center; //Render without progress bar report.Render(false); report.Show(); }
public ActionResult GetUserFormReport(Guid formId) { try { var source = CongressComponent.Instance.BaseInfoComponents.UserFormsFacade.ReportUserForms(formId, this.Homa.Id, SessionParameters.Culture); StiReport report = new StiReport { ScriptLanguage = StiReportLanguageType.CSharp }; report.Dictionary.Synchronize(); report.Load(Server.MapPath("~/Areas/Congress/Reports/RptUserForms.mrt")); StiPage page = report.Pages.Items[0]; var p = page.GetComponents(); StiTable table = (StiTable)p[0]; table.ColumnCount = source.Columns.Count; table.RowCount = source.Rows.Count + 1; table.HeaderRowsCount = 1; table.Width = page.Width; table.Height = page.GridSize * 12; table.Name = "Table1"; table.CreateCell(); var indexHeaderCell = 0; foreach (DataColumn column in source.Columns) { var headerCell = table.Components[indexHeaderCell] as StiTableCell; if (headerCell != null) { headerCell.Text.Value = column.Caption; headerCell.HorAlignment = StiTextHorAlignment.Center; headerCell.VertAlignment = StiVertAlignment.Center; headerCell.Border = new StiBorder(StiBorderSides.All, Color.FromArgb(32, 178, 170), 1, StiPenStyle.Solid); } indexHeaderCell++; } foreach (DataRow row in source.Rows) { foreach (DataColumn column in source.Columns) { StiTableCell headerCell = table.Components[indexHeaderCell] as StiTableCell; if (headerCell != null) { headerCell.Text.Value = row[column].ToString(); headerCell.HorAlignment = StiTextHorAlignment.Center; headerCell.VertAlignment = StiVertAlignment.Center; headerCell.Border = new StiBorder(StiBorderSides.All, Color.FromArgb(32, 178, 170), 1, StiPenStyle.Solid); } indexHeaderCell++; } } SessionParameters.Report = report; this.Redirect("/ReportBuilder/ReportView"); return(Content("true")); } catch (Exception ex) { ShowExceptionMessage(ex); return(Redirect("Index")); } }