2013-01-15 92 views
0

有沒有任何方法將JQGrid數據導出到Excel/PDF。我使用SQL Server 2008 R2作爲數據庫,並使用WCF服務進行HTTP請求/響應。客戶端使用JavaScript編寫,AJAX調用通過WCF服務與SQL數據庫交互。JQGrid:將網格導出爲PDF

請問'excelExport'jqgrid的功能工作嗎?

這裏是收集格柵數據中的代碼和存儲:


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 
} 

回答

1

您可以從another more recent answer使用代碼the answer,甚至更好。將數據導出到Excel的代碼部分可以輕鬆更改爲WCF代碼。請參閱here示例如何使用Stream作爲WCF方法的輸出。

+0

謝謝奧列格,我會嘗試你的解決方案並恢復原狀。 –

+0

@ user1724302:不客氣! – Oleg

+0

奧列格,我怎麼可以把JQGrid數據使用AJAX調用WCF服務導出到Excel? –