travel_he 发表于 2017-2-10 14:01:51

关于WebViewer自定义导出按钮的问题

本帖最后由 Lenka.Guo 于 2017-2-10 16:16 编辑

WebViewer导出按钮要自行定义,建议代码:

      Dim btnCSV As GrapeCity.ActiveReports.Web.Controls.ToolButton = GrapeCity.ActiveReports.Web.Controls.Tool.CreateButton("CSV")
      btnCSV.ToolTip = "导出到 CSV"
      btnCSV.Caption = "导出到 CSV"
      btnCSV.ClickNavigateTo = "ARExport.ashx?ExportType=CSV" '设置点击按钮执行的服务
      Me.WebViewer1.FlashViewerToolBar.Tools.Add(btnCSV) '添加按钮到 FlashViewer 中

这样就有一个问题,不同类型导出各自一个按钮,数量众多,而且是文字按钮不美观,可事定义一个下拉的图形按钮,这样既美观又节省地方!

有否建议代码???

Lenka.Guo 发表于 2017-2-10 14:11:12

您可以参考博客:http://blog.gcpowertools.com.cn/post/advanced-html-viewer-with-export-options.aspx

在前端代码中添加 select控件。

travel_he 发表于 2017-2-10 15:32:18

有VB代码的版本吗?

Lenka.Guo 发表于 2017-2-10 16:15:56

没有VB示例,其实后端没有太大差异,只是前端JS 为webveiwer TOOLBAR 绑定了<select >控件

travel_he 发表于 2017-2-13 08:56:28

而且由于版本不对有些方法都有出入!!!
如:
                  //Create the HTML export object
                  //GrapeCity.ActiveReports.Export.Html.Section.HtmlExport htmlExport1 = new GrapeCity.ActiveReports.Export.Html.Section.HtmlExport();
                  GrapeCity.ActiveReports.Export.Html.Page.HtmlRenderingExtension htmlExport1 = new GrapeCity.ActiveReports.Export.Html.Page.HtmlRenderingExtension();


                  //Export the report to HTML in this session's webcache
                  CustomHtml.MyCustomHtmlOutputter outputter = new CustomHtml.MyCustomHtmlOutputter(this.Context);
                  
                  htmlExport1.Export(rpt.Document, outputter, "");
                  Response.Redirect("ReportOutput" + "/" + System.IO.Path.GetFileName(outputter.mainPage));


htmlExport1.Export这个方法在AR10下就有错,有针对AR10的代码吗?

Lenka.Guo 发表于 2017-2-13 09:11:05

这个博客中所涉及的.export 方法同样存在于AR10 中,未找到相关方法是因为缺少引用:GrapeCity.ActiveReports.Export.Html.v10,把这个dll添加到项目中即可。

详情参考博客: http://blog.gcpowertools.com.cn/post/exportreport.aspx

travel_he 发表于 2017-2-13 10:08:07

本帖最后由 travel_he 于 2017-2-13 10:12 编辑

此文件已引用,否则GrapeCity.ActiveReports.Export.Html.Page.HtmlRenderingExtension htmlExport1 = new GrapeCity.ActiveReports.Export.Html.Page.HtmlRenderingExtension();
就会报错!!



是否还有其它文件也需要引用?

Lenka.Guo 发表于 2017-2-13 10:30:31

HTMLExport 和HtmlRenderingExtension 是导出的两种方式。

如果您想要使用HtmlExport ,先引入GrapeCity.ActiveReports.Export.Html.v10,然后添加以下代码(博客中有VB 代码的写法):' Export the report in HTML format.
Dim HtmlExport1 As New GrapeCity.ActiveReports.Export.Html.Section.HtmlExport()
HtmlExport1.Export(MyDocument, Application.StartupPath + "\HTMLExpt.html")


如果需要使用HtmlRenderingExtension ,也需要引入GrapeCity.ActiveReports.Export.Html.v10 dll,然后添加以下代码
' Provide the page report you want to render.
Dim report As New GrapeCity.ActiveReports.PageReport(New System.IO.FileInfo("C:\Sample_PageReport.rdlx"))
Dim reportDocument As New GrapeCity.ActiveReports.Document.PageDocument(report)

' Create a directory
Dim outputDirectory As New System.IO.DirectoryInfo("C:\MyHTML")
outputDirectory.Create()

' Provide settings for your rendering output.
Dim htmlSetting As New GrapeCity.ActiveReports.Export.Html.Page.Settings()
Dim setting As GrapeCity.ActiveReports.Extensibility.Rendering.ISettings = htmlSetting

' Set the rendering extension and render the report.
Dim htmlRenderingExtension As New GrapeCity.ActiveReports.Export.Html.Page.HtmlRenderingExtension()
Dim outputProvider As New GrapeCity.ActiveReports.Rendering.IO.FileStreamProvider(outputDirectory, System.IO.Path.GetFileNameWithoutExtension(outputDirectory.Name))
reportDocument.Render(htmlRenderingExtension, outputProvider, htmlSetting)

travel_he 发表于 2017-2-14 09:11:18

:victory:

Lenka.Guo 发表于 2017-2-14 09:27:03

travel_he 发表于 2017-2-14 09:11


:loap1:
页: [1]
查看完整版本: 关于WebViewer自定义导出按钮的问题