您好,
我使用DropDownList来实现选择周。选择后触发事件,在这个事件中加载新的模板。
初始化list
- this.DropDownList1.Items.Insert(0, new ListItem("---选择---", "0"));
- this.DropDownList1.Items.Insert(1, new ListItem("6周", "6周"));
- this.DropDownList1.SelectedIndex = 0;
复制代码
选择是触发的事件
- protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
- {
- // Provide the page report you want to render.
- GrapeCity.ActiveReports.PageReport report = new GrapeCity.ActiveReports.PageReport(new System.IO.FileInfo(Server.MapPath("积成电子3.rdlx")));
- GrapeCity.ActiveReports.Document.PageDocument reportDocument = new GrapeCity.ActiveReports.Document.PageDocument(report);
- report.Report.ReportParameters[0].DefaultValue.Values.Add(DropDownList1.SelectedValue);
- // Provide settings for your rendering output.
- GrapeCity.ActiveReports.Export.Excel.Page.ExcelRenderingExtensionSettings excelSetting = new GrapeCity.ActiveReports.Export.Excel.Page.ExcelRenderingExtensionSettings();
- excelSetting.FileFormat = GrapeCity.ActiveReports.Export.Excel.Page.FileFormat.Xlsx;
- excelSetting.OpenXmlStandard = GrapeCity.ActiveReports.Export.Excel.Page.OpenXmlStandard.Transitional;
- excelSetting.Pagination = false;
- GrapeCity.ActiveReports.Extensibility.Rendering.ISettings setting = excelSetting;
- //Set the rendering extension and render the report.
- GrapeCity.ActiveReports.Export.Excel.Page.ExcelRenderingExtension excelRenderingExtension = new GrapeCity.ActiveReports.Export.Excel.Page.ExcelRenderingExtension();
- GrapeCity.ActiveReports.Rendering.IO.MemoryStreamProvider outputProvider = new GrapeCity.ActiveReports.Rendering.IO.MemoryStreamProvider();
- reportDocument.Render(excelRenderingExtension, outputProvider, excelSetting.GetSettings());
- System.IO.Stream stream = outputProvider.GetPrimaryStream().OpenStream();
- // 通过Spread查看报表
- FpSpread1.OpenExcel(stream);
- FpSpread1.EnableViewState = false;
- FpSpread1.SaveViewStateToSession = false;
- FpSpread1.Sheets[0].OperationMode = FarPoint.Web.Spread.OperationMode.SingleSelect;
- FpSpread1.Sheets[0].AllowPage = false;
- FpSpread1.Sheets[0].FrozenRowCount = 2;
- FpSpread1.Sheets[0].FrozenColumnCount = 4;
- FarPoint.Web.Spread.HyperLinkCellType hlct = new FarPoint.Web.Spread.HyperLinkCellType("http://gcdn.gcpowertools.com.cn");
- for (int row = 4; row < FpSpread1.Sheets[0].RowCount; row += 3)
- {
- for (int col = 4; col < FpSpread1.Sheets[0].ColumnCount; col++)
- {
- if (FpSpread1.Sheets[0].Cells[row, col].Value != null)
- {
- FpSpread1.Sheets[0].Cells[row, col].CellType = hlct;
- }
- }
- }
- }
复制代码
asp页面增加
- <asp:DropDownList ID="DropDownList1" runat="server" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged" AutoPostBack="True"></asp:DropDownList>
复制代码
2015-05-04_141229.jpg
(54.5 KB, 下载次数: 89)
|