| | |
| | | function ws_ajax_preview() { |
| | | //参数具体说明请参考帮助文档中的“WEB报表(B/S报表)->WEB报表客户端->启动参数说明”部分 |
| | | var args = { |
| | | /*report: urlAddRandomNo("../grf/产品流传单A5.grf"),*/ |
| | | report: urlAddRandomNo("https://121.196.36.24:8001/grf/产品流传单A5.grf"), |
| | | report: urlAddRandomNo("../grf/产品流传单A5.grf"), |
| | | data: |
| | | { |
| | | "recordset": [ |
| | |
| | | } |
| | | </script> |
| | | |
| | | <p><a href='javascript:ws_ajax_export_xls();'>导出Excel(AJAX)</a>通过AJAX方式获取报表模板与报表数据</p> |
| | | <script language="javascript" type="text/javascript"> |
| | | function ws_ajax_export_xls() { |
| | | var args = { |
| | | type: "xls", |
| | | report: urlAddRandomNo("../grf/1a.grf"), |
| | | data: "../data/DataCenter.ashx?data=Customer", |
| | | reportid: "1a" //这个参数不是必须的,只是用于回发消息标识报表身份 |
| | | }; |
| | | |
| | | webapp_ws_ajax_run(args); |
| | | } |
| | | </script> |
| | | |
| | | |
| | | <h3>自定义打印参数</h3> |
| | | <p> <a href='javascript:print_arguments();'>自定义打印参数</a>:指定打印机,设置逐份打印与打印份数。</p> |
| | | <script language="javascript" type="text/javascript"> |
| | | function print_arguments() { |
| | | var args = { |
| | | type: "print", //如果是要进行打印,将 type 设置为 print |
| | | report: urlAddRandomNo("../grf/1a.grf"), |
| | | data: "../data/DataCenter.ashx?data=Customer", |
| | | PrinterName: "Microsoft Print to PDF", //指定要输出的打印机名称 |
| | | Collate: false, //不按逐份方式打印 |
| | | Copies: 5 //共打印5份 |
| | | } |
| | | |
| | | webapp_ws_ajax_run(args); |
| | | } |
| | | </script> |
| | | |
| | | <p> <a href='javascript:export_xls_custom();'>自定义导出Excel</a>:设置合适的选项参数,将数据导出为连续的表格,页眉页脚不导出,不显示导出参数对话框等。</p> |
| | | <script language="javascript" type="text/javascript"> |
| | | function export_xls_custom() { |
| | | var args = { |
| | | report:urlAddRandomNo("../grf/1a.grf"), |
| | | data: "../data/DataCenter.ashx?data=Customer", |
| | | type: "xls", |
| | | ExportPageBreak: false, |
| | | ExportPageHeaderFooter: false, |
| | | SameAsPrint: false, |
| | | showOptionDlg: false, //指定不显示导出选项对话框 |
| | | filename: "d:\\temp\\gridreport.xls", //指定导出的文件路径与文件名 |
| | | //open: false //指定导出后不自动打开文件 |
| | | } |
| | | |
| | | webapp_ws_ajax_run(args); |
| | | } |
| | | </script> |
| | | |
| | | <h3>更多应用方式</h3> |
| | | |
| | | <p><a href='javascript:ws_data_from_string();'>打印预览(报表数据来自字符串)</a>:通过WebSocket直接将网页中的字符串数据传递给WEB报表客户端。</p> |
| | | <script language="javascript" type="text/javascript"> |
| | | function ws_data_from_string() { |
| | | var args = { |
| | | type: "preview", //设置不同的属性可以执行不同的任务,如:preview print pdf xls csv txt rtf img grd |
| | | report: urlAddRandomNo("../grf/1a.grf"), |
| | | //实际应用中,data应该为程序中通过各种途径获取到的数据,最后要将数据转换为报表需要的XML或JSON格式的字符串数据 |
| | | data:"<xml>" + |
| | | "<row><CustomerID>HUNGC</CustomerID><CompanyName>五金机械</CompanyName><ContactName>苏先生</ContactName><ContactTitle>销售代表</ContactTitle></row>" + |
| | | "<row><CustomerID>CENTC</CustomerID><CompanyName>三捷实业</CompanyName><ContactName>王先生</ContactName><ContactTitle>市场经理</ContactTitle></row>" + |
| | | "<row><CustomerID>CACTU</CustomerID><CompanyName>威航货运</CompanyName><ContactName>刘先生</ContactName><ContactTitle>销售代理</ContactTitle></row>" + |
| | | "</xml>", |
| | | reportid: "ws_data_from_string" //这个参数不是必须的,只是用于回发消息标识报表身份 |
| | | }; |
| | | |
| | | webapp_ws_ajax_run(args); |
| | | } |
| | | </script> |
| | | |
| | | <p><a href='javascript:ws_data_from_object();'>打印预览(报表数据来自JSON对象)</a>:通过WebSocket直接将网页中的JSON对象数据传递给WEB报表客户端。</p> |
| | | <script language="javascript" type="text/javascript"> |
| | | function ws_data_from_object() { |
| | | var args = { |
| | | type: "preview", //设置不同的属性可以执行不同的任务,如:preview print pdf xls csv txt rtf img grd |
| | | report: urlAddRandomNo("../grf/1a.grf"), |
| | | //实际应用中,data应该为程序中通过各种途径获取到的数据,最后要将数据转换为报表需要的XML或JSON格式的字符串数据 |
| | | data: |
| | | { |
| | | "recordset": [ |
| | | { |
| | | "CustomerID": "ALFKI", |
| | | "CompanyName": "三川实业有限公司", |
| | | "ContactName": "刘小姐", |
| | | "Address": "大崇明路 50 号", |
| | | "City": "天津", |
| | | "Region": "华北", |
| | | "PostalCode": "343567", |
| | | "Phone": "(030) 30074321" |
| | | }, |
| | | { |
| | | "CustomerID": "ANATR", |
| | | "CompanyName": "东南实业", |
| | | "ContactName": "王先生", |
| | | "Address": "承德西路 80 号", |
| | | "City": "天津", |
| | | "Region": "华北", |
| | | "PostalCode": "234575", |
| | | "Phone": "(030) 35554729" |
| | | } |
| | | ] |
| | | }, |
| | | reportid: "ws_data_from_object" //这个参数不是必须的,只是用于回发消息标识报表身份 |
| | | }; |
| | | |
| | | webapp_ws_ajax_run(args); |
| | | } |
| | | </script> |
| | | |
| | | |
| | | |
| | | </body> |
| | | </html> |