回复 15楼frank.zhang的帖子
我做了一个例子,请用附件的SQLServer数据库备份来重现这个问题,rdlx文件也请看附件,以下是我的客户端导出Excel代码:
- @{
- Layout = "~/Views/Shared/_LayoutReport.cshtml";
- }
- @model SPAPOS.WebApp.Models.ReportResponse
- <div id="page-heading">
- <h2>
- <i class="fa fa-tasks"></i>&nbsp;&nbsp;@Model.Name</h2>
- </div>
- @Html.Partial("ReportViewer", Model.PageReport as object)
- @section jssection{
- <script type="text/javascript">
- var fileName = "@Model.Name";
- var viewModel = GetViewModel("WebViewer1");
- arjq(document).ready(function fn() {
- console.log(viewModel);
- var toolbar = arjq('#WebViewer1').find('.arvToolBar');
- toolbar.append("<span><input id='btnPrint' type='Button' value='打 印' onclick='startPrint()'/></span>");
- toolbar.append("<span><input id='btnExportExcel' type='button' value='导出Excel' onclick='exportExcel(this, ExportType.Xls)'/></span>");
- toolbar.append("<span><input id='btnExportWord' type='button' value='导出Word' onclick='exportExcel(this, ExportType.Word)'/></span>");
- toolbar.append("<span><input id='btnExportPDF' type='button' value='导出PDF' onclick='exportExcel(this, ExportType.Pdf)'/></span>");
- });
- function exportExcel(sender, exportType) {
- if (viewModel.PageLoaded()) {
- viewModel.Export(exportType, function (uri) {
- window.location = uri;
- }, true, { MultiSheet: false, Pagination: false });
- @* var url = '@Url.Action("ExportExcel")';
- window.location.href = url + "?code=@Model.Code";*@
- } else {
- alert("在页面加载完成之前不能进行打印/导出操作。");
- }
- }
- function startPrint() {
- if (viewModel.PageLoaded()) {
- viewModel.Print();
- } else {
- alert("在页面加载完成之前不能进行打印/导出操作。");
- }
- }
- </script>
- }
复制代码
另外,客户端导出excel好慢啊~~ |