JQGrid:将网格导出为PDF [英] JQGrid: Export Grid to PDF

查看:112
本文介绍了JQGrid:将网格导出为PDF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以将JQGrid数据导出到Excel/PDF.我使用SQL Server 2008 R2作为数据库和用于HTTP请求/响应的WCF服务.使用JavaScript编写客户端,并通过WCF服务进行AJAX调用以与SQL数据库进行交互.

Is there any way of exporting JQGrid data to Excel/PDF. I am using SQL server 2008 R2 as database and WCF service for HTTP Request/response. Client is written using JavaScript and AJAX calls are made to interact with SQL database through WCF service.

jqgrid的'excelExport'功能可以工作吗?

Will 'excelExport' function of jqgrid work?

以下是收集网格数据并存储的代码:

Here is the code to collect Grid Data and store:

enter code here
function ExportExcel() {
    var mya=new Array();
    mya = $("#PrjBudgetGrid").getDataIDs();  // Get All IDs
    var data = $("#PrjBudgetGrid").getRowData(mya[0]);     // Get First row to get the labels
    var colNames=new Array(); 
    var ii=0;
    for (var i in data) {
        colNames[ii++] = i;
    }     // capture col names
    var html = "";
    for (i = 0; i < mya.length; i++) {
        data = $("#PrjBudgetGrid").getRowData(mya[i]); // get each row
        for (j = 0; j < colNames.length; j++) {
            html = html + data[colNames[j]] + "\t"; // output each column as tab delimited
        }
        html = html + "\n";  // output each row with end of line

    }
    html=html+"\n";  // end of line at the end
}

推荐答案

您可以使用答案中的代码或甚至更好的是另一个最新的答案.代码的一部分将数据导出到Excel,您可以轻松地将其更改为WCF代码.请参见此处示例如何使用Stream作为WCF方法的输出.

You can use the code from the answer or even better from another more recent answer. The part of the code which export data to Excel you can easy change to WCF code. See here an example how to use Stream as the output of WCF method.

这篇关于JQGrid:将网格导出为PDF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆