翻譯|使用教程|編輯:龔雪|2021-04-20 10:14:34.403|閱讀 376 次
概述:本文主要介紹通過修改生成的Workbook對(duì)象,將不同的樣式和值更改應(yīng)用于導(dǎo)出到Excel的Kendo UI PivtoGrid中。
# 界面/圖表報(bào)表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關(guān)鏈接:
Kendo UI for jQuery R1 2021 SP2試用版下載
Kendo UI是帶有jQuery、Angular、React和Vue庫的JavaScript UI組件的最終集合,無論選擇哪種JavaScript框架,都可以快速構(gòu)建高性能響應(yīng)式Web應(yīng)用程序。通過可自定義的UI組件,Kendo UI可以創(chuàng)建數(shù)據(jù)豐富的桌面、平板和移動(dòng)Web應(yīng)用程序。通過響應(yīng)式的布局、強(qiáng)大的數(shù)據(jù)綁定、跨瀏覽器兼容性和即時(shí)使用的主題,Kendo UI將開發(fā)時(shí)間加快了50%。
您可以通過修改生成的Workbook對(duì)象,將不同的樣式和值更改應(yīng)用于導(dǎo)出到Excel的Kendo UI PivtoGrid中。
下面的示例演示如何實(shí)現(xiàn)此操作。
<div id="example"> <button id="export">Export</button> <div id="pivotgrid"></div> <script> $(document).ready(function () { var pivotgrid = $("#pivotgrid").kendoPivotGrid({ excel: { fileName: "Kendo UI PivotGrid Export.xlsx", proxyURL: "http://demos.telerik.com/kendo-ui/service/export", filterable: true }, excelExport: function(e) { var sheet = e.workbook.sheets[0]; var rows = sheet.rows; var rowIdx, colIdx, cells, cell; for (rowIdx = 0; rowIdx < rows.length; rowIdx++) { if (rows[rowIdx].type === "data") { cells = rows[rowIdx].cells; for (colIdx = sheet.freezePane.colSplit; colIdx < cells.length; colIdx++) { cell = cells[colIdx]; cell.background = "#aabbcc"; cell.value = kendo.toString(cell.value, "c"); } } } }, dataCellTemplate: $("dataCellTemplate").html(), filterable: true, sortable: true, columnWidth: 200, height: 580, dataSource: { type: "xmla", columns: [{ name: "[Date].[Calendar]", expand: true }, { name: "[Product].[Category]" } ], rows: [{ name: "[Geography].[City]" }], measures: ["[Measures].[Reseller Freight Cost]"], transport: { connection: { catalog: "Adventure Works DW 2008R2", cube: "Adventure Works" }, read: "http://demos.telerik.com/olap/msmdpump.dll" }, schema: { type: "xmla" }, error: function (e) { alert("error: " + kendo.stringify(e.errors[0])); } } }).data("kendoPivotGrid"); $("#export").click(function() { pivotgrid.saveAsExcel(); }); }); </script> </div>
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請(qǐng)務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請(qǐng)郵件反饋至chenjj@fc6vip.cn
文章轉(zhuǎn)載自:慧都網(wǎng)