本帖最后由 KearneyKang 于 2017-8-11 14:27 编辑
您好
您是想自己写一个报表的导出按钮是吧!参考代码如下
- <script type="text/javascript">
- $(document).ready(function () {
- $(".arvToolBar").append("<span style='margin-right:5px;'><input id='btnPrint' type='Button' value='打印' onclick='OnPrint()'/></span>");
- $(".arvToolBar").append("<span style='margin-right:5px;'><input id='btnExportPDF' type='Button' value='PDF' onclick='OnExportPDF()'/></span>");
- $(".arvToolBar").append("<span style='margin-right:5px;'><input id='btnExportWord' type='Button' value='Word' onclick='OnExportWord()'/></span>");
- $(".arvToolBar").append("<span style='margin-right:5px;'><input id='btnExportExcel' type='Button' value='Excel' onclick='OnExportExcel()'/></span>");
- });
- function OnExportPDF() {
- var viewModel = GetViewModel('WebViewer1');
- if (!viewModel.PageLoaded())
- return;
- viewModel.Export(ExportType.Pdf, function (url) {
- try {
- window.open(url, '_blank');
- } catch (e) {
- }
- }, true, { FileName: 'ActiveReports报表.pdf' });
- };
- function OnPrint() {
- var viewModel = GetViewModel('WebViewer1');
- if (!viewModel.PageLoaded())
- return;
- viewModel.Print();
- };
- function OnExportWord() {
- var viewModel = GetViewModel('WebViewer1');
- if (!viewModel.PageLoaded())
- return;
- viewModel.Export(ExportType.Word, function (url) {
- try {
- window.open(url, '_blank');
- } catch (e) {
- }
- }, true, { FileName: 'ActiveReports报表.doc' });
- };
- function OnExportExcel() {
- var viewModel = GetViewModel('WebViewer1');
- if (!viewModel.PageLoaded())
- return;
- viewModel.Export(ExportType.Xls, function (url) {
- try {
- window.open(url, '_blank');
- } catch (e) {
- }
- }, true, { FileName: 'ActiveReports报表.xlsx' });
- };
- </script>
复制代码 参考demo见附件 |