- <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
- <%@ Register Assembly="GrapeCity.ActiveReports.Web.v8" Namespace="GrapeCity.ActiveReports.Web" TagPrefix="ActiveReportsWeb" %>
- <head id="Head1" runat="server">
- <title>ReportViewer</title>
-
- <script src="../Scripts/jquery-1.7.2.min.js" type="text/javascript"></script>
- <%-- <link rel="stylesheet" type="text/css" href="../../Content/Site.css"/>--%>
-
- <script type="text/javascript">
- var viewMode;
- // viewMode = GetViewModel('1_WebViewer1');
- // viewMode.culture = "zh-CN";
- $(document).ready(function () {
- $('#WebViewer1').bind('loaded', function () {
- viewMode = GetViewModel('1_WebViewer1');
- });
- });
- function Button1_onclick() {
- viewMode = GetViewModel('1_WebViewer1');
- if (viewMode.PageLoaded()) {
- viewMode.Export(ExportType.Pdf, function (uri) {
- window.location = uri;
- }, true, { FileName: "ActiveReports报表.pdf" });
- }
- }
- function Button2_onclick() {
- viewMode = GetViewModel('1_WebViewer1');
- if (viewMode.PageLoaded()) {
- viewMode.Export(ExportType.Xls, function (uri) {
- window.location = uri;
- }, true, { FileName: "ActiveReports报表.xls" });
- }
- }
- function Button3_onclick() {
- viewMode = GetViewModel('1_WebViewer1');
- if (viewMode.PageLoaded()) {
- viewMode.Export(ExportType.Word, function (uri) {
- window.location = uri;
- }, true, { FileName: "ActiveReports报表.doc" });
- }
- }
- </script>
- </head>
- <script runat="server">
- void Page_Load(){
- // System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("zh-CN");
- // System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("zh-CN");
- WebViewer1.Report = ViewBag.Report;
- //WebViewer1.
- }
-
- </script>
- <script Language="javascript" type="text/javascript">
- function viewer_loaded() {
- // alert("loaaded");s
- var viewModel = GetViewModel('1_WebViewer1');
- //$('#customToolbar').appendTo($('#controlTable');
- $('#customToolbar').appendTo('.arvToolBar');
- };
- function document_onload() {
- $('#1_WebViewer1').bind('loaded', viewer_loaded);
- };
- function exportPDF() {
- var viewModel = GetViewModel('1_WebViewer1');
- if (viewModel.PageLoaded()) {
- viewModel.Export(ExportType.Pdf, function (uri) {
- window.location = uri;
- }, true, { FileName: "ActiveReports报表.pdf" });
- }
- }
- </script>
- <body onload="return document_onload()">
- <div id="customToolbar" style = "display:inline"><button onclick='exportPDF()' style=" width: 105px; font-size: medium; height: 22px;">Export</button>
- </div>
- <table>
- <tr>
- <td><input id="Button1" type="button" value="Pdf" onclick="return Button1_onclick()" /></td>
- <td><input id="Button2" type="button" value="Exel" onclick="return Button2_onclick()" /></td>
- <td><input id="Button3" type="button" value="Word" onclick="return Button3_onclick()" /></td>
- </tr>
- </table>
- <div>
- <ActiveReportsWeb:WebViewer ID="WebViewer1" runat="server" >
- </ActiveReportsWeb:WebViewer>
- </div>
- </body>
复制代码
摸着石头过河,靠分析页面输出,实现了javascript导出pdf,word,excel的功能,请版主速度更新ar8控件在mvc3下的资源文档,以前的文档在mvc 3下基本都会产生令人困惑的错误 |