您好,
使用前台js进行导出
- <script language="javascript" type="text/javascript">
- var viewModel;
- var printBtn = '<span><input id="btnPrint" type="Button" value="Print" onclick="print()"/></span>';
- var exportSelect = '<select id="ExportSelect" style="width:80px"><option selected disabled>Export</option><option value="PDF" style="background: url(images/pdf.png) right no-repeat; width: 50px">PDF</option><option value="Excel" style="background: url(images/Excel.gif) right no-repeat; width: 50px">Excel</option></select>';
- $(document).ready(function () {
- viewModel = GetViewModel("WebViewer1");
- var toolbar = $('#WebViewer1').find('.arvToolBar');
- toolbar.append(exportSelect);
- toolbar.append(printBtn);
- //Check the selected value in DropDown and Export
- $("#ExportSelect").change(function (e, args) {
- var valueSelected = this.value;
- if (viewModel.PageLoaded()) {
- switch (valueSelected) {
- case "PDF":
- viewModel.Export(ExportType.Pdf, function (uri) {
- window.location = uri;
- }, true);
- break;
- case "Excel":
- viewModel.Export(ExportType.Xls, function (uri) {
- window.location = uri;
- }, true);
- break;
- }
- }
- });
- });
- function print() {
- if (viewModel.PageLoaded()) {
- viewModel.Print();
- }
- };
- </script>
复制代码
预览效果:
设置自定义纸张:
打印:
|