- protected void Page_Load(object sender, EventArgs e)
- {
- if (IsPostBack)
- {
- return;
- }
- GrapeCity.ActiveReports.PageReport report1 = new GrapeCity.ActiveReports.PageReport(new System.IO.FileInfo(Server.MapPath("") + "\\PageReport1.rdlx"));
- report1.Document.LocateDataSource += new GrapeCity.ActiveReports.LocateDataSourceEventHandler(Document_LocateDataSource);
- WebViewer1.PdfExportOptions.FitWindow = false;
- WebViewer1.PdfExportOptions.DisplayMode = GrapeCity.ActiveReports.Export.Pdf.Section.DisplayMode.Outlines;
- WebViewer1.Report = report1;
- CustomizeToolBar();
- }
- private void CustomizeToolBar()
- {
- //设置显示语言版本为中文
- this.WebViewer1.FlashViewerOptions.ResourceLocale = "zh_CN";
- ToolButton btnWord = Tool.CreateButton("Word");
- btnWord.ToolTip = "导出到 Word";
- btnWord.Caption = "导出到 Word";
- btnWord.ClickNavigateTo = "ARExport.ashx?exporttype=Word";
- this.WebViewer1.FlashViewerToolBar.Tools.Add(btnWord);
- ToolButton btnExcel = Tool.CreateButton("Excel");
- btnExcel.ToolTip = "导出到 Excel";
- btnExcel.Caption = "导出到 Excel";
- btnExcel.ClickNavigateTo = "ARExport.ashx?exporttype=Excel";
- this.WebViewer1.FlashViewerToolBar.Tools.Add(btnExcel);
- }
- void Document_LocateDataSource(object sender, GrapeCity.ActiveReports.LocateDataSourceEventArgs args)
- {
- if (args.DataSourceName == "DataSource1")
- {
- if (args.DataSetName == "DataSet1")
- {
- args.Data = GetDate();
- }
- }
- }
- private DataTable GetDate()
- {
- DataTable dt = new DataTable();
- dt.Columns.Add("Col1");
- dt.Columns.Add("Col2");
- dt.Columns.Add("Col3");
- dt.Rows.Add(1, 1, 1);
- dt.Rows.Add(2, 1, 1);
- dt.Rows.Add(3, 1, 1);
- dt.Rows.Add(4, 1, 1);
- dt.Rows.Add(5, 1, 1);
- dt.Rows.Add(6, 1, 1);
- return dt;
- }
复制代码
你看下 我的代码 |