VTable導出當前頁和導出所有頁數據

表格導出的是當前顯示的表格,如果是分頁表格想導出全部的數據話。有兩種方法可以實現

  1. 表格先顯示的全量數據,導出后再恢復當前頁。
  2. 新建一個隱藏的表格實例顯示全量數據導出這個隱藏的表格實例。
    在這里插入圖片描述
    下面是全量代碼:
<template><div><div ref="listTableExport" id = "CONTAINER_ID" style="width: 1580px; height: 800px"></div><div id = "CONTAINER_HiDE" style="display : none"></div><div style="width: 1580px; height: 50px" class="right-align"><button id="first-buttom" > 首頁</button><button id="prev-buttom" > 上一頁</button><span id="page-namber">1</span><input id="cpnr" type="hidden"><span>/</span><span id="total-page">共 頁</span><input id="mpnr" type="hidden"><button id="next-buttom">下一頁</button><button id="tail-buttom" > 尾頁</button><span id="total-num">共 條</span><input  id="spn" type="number" ><button id="skip-buttom"> 跳轉</button></div></div></template><script setup>import * as VTable from '@visactor/vtable';
// 使用時需要引入插件包@visactor/vtable-export
import {downloadCsv,exportVTableToCsv,downloadExcel,exportVTableToExcel,
} from "@visactor/vtable-export";
// umd引入時導出工具會掛載到VTable.exportlet tableInstance;
let tableInstance_hide;
fetch('https://lf9-dp-fe-cms-tos.byteorg.com/obj/bit-cloud/VTable/North_American_Superstore_Pivot_data.json').then(res => res.json()).then(data => {const option = {records: data,rows: [{dimensionKey: 'City',title: 'City',headerStyle: {textStick: true},width: 'auto'}],columns: [{dimensionKey: 'Category',title: 'Category',headerStyle: {textStick: true},width: 'auto'}],indicators: [{indicatorKey: 'Quantity',title: 'Quantity',width: 'auto',showSort: false,headerStyle: {fontWeight: 'normal'},style: {padding: [16, 28, 16, 28],color(args) {if (args.dataValue >= 0) return '#000000';return 'red';}}},{indicatorKey: 'Sales',title: 'Sales',width: 'auto',showSort: false,headerStyle: {fontWeight: 'normal'},format: rec => {return '$' + Number(rec).toFixed(2);},style: {padding: [16, 28, 16, 28],color(args) {if (args.dataValue >= 0) return '#000000';return 'red';}}},{indicatorKey: 'Profit',title: 'Profit',width: 'auto',showSort: false,headerStyle: {fontWeight: 'normal'},format: rec => {return '$' + Number(rec).toFixed(2);},style: {padding: [16, 28, 16, 28],color(args) {if (args.dataValue >= 0) return '#000000';return 'red';}}}],corner: {titleOnDimension: 'row',headerStyle: {textStick: true}},dataConfig: {sortRules: [{sortField: 'Category',sortBy: ['Office Supplies', 'Technology', 'Furniture']}]},widthMode: 'standard',pagination:{perPageCount:10,currentPage:0,},};tableInstance = new VTable.PivotTable(document.getElementById("CONTAINER_ID"), option);const option_hide = {records: data,rows: [{dimensionKey: 'City',title: 'City',}],columns: [{dimensionKey: 'Category',title: 'Category',}],indicators: [{indicatorKey: 'Quantity',title: 'Quantity',},{indicatorKey: 'Sales',title: 'Sales',},{indicatorKey: 'Profit',title: 'Profit',}],dataConfig: {sortRules: [{sortField: 'Category',sortBy: ['Office Supplies', 'Technology', 'Furniture']}]},};  tableInstance_hide = new VTable.PivotTable(document.getElementById("CONTAINER_HiDE"), option_hide);//分頁相關代碼let pageNumber = 0;// const totalNum = option.records.length;const totalNum = option.pagination.totalCount;const pageSize =option.pagination.perPageCount;const pageNumberSpan = document.getElementById("page-namber");const totalPageSpan = document.getElementById("total-page");const totalNumSpan = document.getElementById("total-num");const totalPg = Math.ceil(totalNum/pageSize);//總頁數totalPageSpan.innerHTML='共'+totalPg+'頁';totalNumSpan.innerHTML='共'+totalNum+'條';document.getElementById("prev-buttom").addEventListener("click", () => {if (pageNumber === 0) {return;}pageNumber--;tableInstance.updatePagination({currentPage: pageNumber});pageNumberSpan.innerHTML = '第'+(pageNumber+1)+'頁';});document.getElementById("first-buttom").addEventListener("click", () => {pageNumber=1;pageNumber--;tableInstance.updatePagination({currentPage: pageNumber});pageNumberSpan.innerHTML = '第'+(pageNumber+1)+'頁';document.getElementById("spn").value ='';});document.getElementById("tail-buttom").addEventListener("click", () => {pageNumber=totalPg-1;tableInstance.updatePagination({currentPage: pageNumber});pageNumberSpan.innerHTML = '第'+(pageNumber+1)+'頁';document.getElementById("spn").value ='';});document.getElementById("next-buttom").addEventListener("click", () => {if (pageNumber === (totalPg-1)) {return;}pageNumber++;tableInstance.updatePagination({currentPage: pageNumber});pageNumberSpan.innerHTML = '第'+(pageNumber+1)+'頁';});document.getElementById("skip-buttom").addEventListener("click", () => {let specificPageNum = document.getElementById("spn").value;//要跳轉的頁if (specificPageNum > totalPg) {pageNumber=totalPg-1;document.getElementById("spn").value=totalPg;}else{pageNumber = specificPageNum-1}if (specificPageNum <= 0) {pageNumber=0;document.getElementById("spn").value =1;}tableInstance.updatePagination({currentPage: pageNumber});pageNumberSpan.innerHTML = '第'+(pageNumber+1)+'頁';});window['tableInstance'] = tableInstance;window['tableInstance_hide'] = tableInstance_hide;bindExport(totalNum,pageNumber);});function bindExport(totalNum,pageNumber) {let exportContainer = document.getElementById('export-buttom');if (exportContainer) {exportContainer.parentElement.removeChild(exportContainer);}exportContainer = document.createElement('div');exportContainer.id = 'export-buttom';exportContainer.style.position = 'absolute';exportContainer.style.bottom = '0';exportContainer.style.right = '0';window['tableInstance'].getContainer().appendChild(exportContainer);const exportCsvButton = document.createElement('button');exportCsvButton.innerHTML = '全量CSV-export';const exportExcelButton = document.createElement('button');exportExcelButton.innerHTML = '全量Excel-export';exportContainer.appendChild(exportCsvButton);exportContainer.appendChild(exportExcelButton);const exportCsvButton_currentPage = document.createElement('button');exportCsvButton_currentPage.innerHTML = '當頁CSV-export';const exportExcelButton_currentPage = document.createElement('button');exportExcelButton_currentPage.innerHTML = '當頁Excel-export';exportContainer.appendChild(exportCsvButton_currentPage);exportContainer.appendChild(exportExcelButton_currentPage);const exportCsvButton_hide = document.createElement('button');exportCsvButton_hide.innerHTML = '隱藏全量CSV-export';const exportExcelButton_hide = document.createElement('button');exportExcelButton_hide.innerHTML = '隱藏全量Excel-export';exportContainer.appendChild(exportCsvButton_hide);exportContainer.appendChild(exportExcelButton_hide);exportCsvButton.addEventListener('click', () => {window.tableInstance.updatePagination({perPageCount:totalNum,currentPage: pageNumber});if (window.tableInstance) {downloadCsv(exportVTableToCsv(window.tableInstance), 'export');}window.tableInstance.updatePagination({perPageCount:10,currentPage: pageNumber});});exportExcelButton.addEventListener('click', async () => {window.tableInstance.updatePagination({perPageCount:totalNum,currentPage: 0});if (window.tableInstance) {downloadExcel(await exportVTableToExcel(window.tableInstance, {formatExportOutput: ({ cellType, cellValue, table, col, row }) => {          }
} ), 'export');}window.tableInstance.updatePagination({perPageCount:10,currentPage: pageNumber});});exportCsvButton_currentPage.addEventListener('click', () => {if (window.tableInstance) {downloadCsv(exportVTableToCsv(window.tableInstance), 'export');}});exportExcelButton_currentPage.addEventListener('click', async () => {if (window.tableInstance) {downloadExcel(await exportVTableToExcel(window.tableInstance, {formatExportOutput: ({ cellType, cellValue, table, col, row }) => {           }
} ), 'export');}});exportCsvButton_hide.addEventListener('click', () => {if (window.tableInstance_hide) {downloadCsv(exportVTableToCsv(window.tableInstance_hide), 'export');}});exportExcelButton_hide.addEventListener('click', async () => {if (window.tableInstance_hide) {downloadExcel(await exportVTableToExcel(window.tableInstance_hide, {formatExportOutput: ({ cellType, cellValue, table, col, row }) => {         }
} ), 'export');}});
}
</script>

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/diannao/35470.shtml
繁體地址,請注明出處:http://hk.pswp.cn/diannao/35470.shtml
英文地址,請注明出處:http://en.pswp.cn/diannao/35470.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

快速創建條形熱力圖

Excel中的條件格式可以有效的凸顯數據特征&#xff0c;如下圖中B列所示。 現在需要使用圖表展現熱力條形圖&#xff0c;如下圖所示。由于顏色有多個過渡色&#xff0c;因此手工逐個設置數據條的顏色&#xff0c;基本上是不可能完成的任務&#xff0c;使用VBA代碼可以快速創建這…

git stash相關命令解釋

git stash 這個命令會保存你當前工作區和暫存區的所有更改到一個臨時的“stash”區域&#xff0c;然后使你的工作目錄和暫存區變得干凈&#xff08;即回到最近一次提交的狀態&#xff09;。 當你想要回到這個“stash”區域中的更改時&#xff0c;你可以使用 git stash list 來查…

SRE監控的四個黃金指標到底長啥樣?

一、監控的黃金信號 掌握系統運行狀態&#xff0c;了解組件、服務的可靠性和穩定性&#xff0c;需要借助監控系統收集指標、可視化數據&#xff0c;并在異常出現時進行操作提醒。那么監控的都要關注哪些呢&#xff1f;我們來了解一下監控的指標&#xff0c;即系統中衡量的最重…

【pytorch03】pytorch基本數據類型

問題&#xff1a;String類型在pytorch中如何表示&#xff1f; 很遺憾&#xff0c;pytorch不是完備的語言庫&#xff0c;而是面向數據計算的一個GPU加速庫&#xff0c;因此沒有內建對string的支持 我們會在做NLP的時候會遇到all string處理的問題&#xff0c;就比如說一句話&am…

華碩PRIME B450M-K主板開啟虛擬化

1.判斷電腦是否開啟了虛擬化 按下CtrlShiftESC打開任務管理器&#xff0c;切換到性能頁面&#xff0c;選擇查看CPU 如果在右下角看到虛擬化&#xff1a;已禁用&#xff0c;則沒有開啟虛擬化 2.進入BIOS 重啟或開機時&#xff0c;按下DEL或F2進入BIOS設置界面。 屏幕提示&am…

SAP系統中如何用事務碼圖形視圖尋找MD04增強開發實施點

在之前發布的文章中&#xff0c;介紹了善用事務碼的圖形視圖以觀察事務的執行流程以及如何在MD04中實施增強以改變生產訂單的顯示順序。本文結合兩者&#xff0c;介紹一下如何利用事務碼的圖形視圖找到增強開發的實施點。 在事務碼中輸入SE93&#xff0c;進入圖形視圖&#xf…

生命在于學習——Python人工智能原理(4.6)

在這里插一句話&#xff0c;我有兩個好兄弟的github項目&#xff0c;感興趣的可以去看一下&#xff0c;star一下&#xff0c;謝謝。 https://github.com/fliggyaa/fscanpoc https://github.com/R0A1NG/Botgate_bypass 四、Python的程序結構與函數 4.1 Python的分支結構 &…

如何將個人電腦做P2V備份到虛擬化平臺

背景&#xff1a;公司員工個人電腦綁定了商用軟件的license&#xff0c;現在員工離職&#xff0c;license又需要使用&#xff0c;電腦就一直被占用。 解決方法&#xff1a;利用VMware Vcenter Converter Standalone將此臺式電腦上載到公司虛擬化平臺上 具體做法&#xff0c;下…

sklearn-learn的安裝

官網&#xff1a;scikit-learn: machine learning in Python — scikit-learn 1.5.0 documentation 是 pip install scikit-learn 不是 pip install sklearn

Leetcode 700:二叉搜索樹中的搜索

給定二叉搜索樹&#xff08;BST&#xff09;的根節點 root 和一個整數值 val。 你需要在 BST 中找到節點值等于 val 的節點。 返回以該節點為根的子樹。 如果節點不存在&#xff0c;則返回 null 。 public TreeNode searchBST(TreeNode root, int val) {if(rootnull){return n…

.NET C# 樹遍歷、查詢、拷貝與可視化

.NET C# 樹遍歷、查詢、拷貝與可視化 目錄 .NET C# 樹遍歷、查詢、拷貝與可視化1 組件安裝1.1 NuGet包管理器安裝&#xff1a;1.2 控制臺安裝&#xff1a; 2 接口1.1 ITree\<TTreeNode\>1.2 ITree\<TKey, TTreeNode\>1.3 IObservableTree\<TTreeNode\>1.4 IO…

昇思25天學習打卡營第7天 | 模型訓練

內容介紹&#xff1a; 模型訓練一般分為四個步驟&#xff1a; 1. 構建數據集。 2. 定義神經網絡模型。 3. 定義超參、損失函數及優化器。 4. 輸入數據集進行訓練與評估。 具體內容&#xff1a; 1. 導包 import mindspore from mindspore import nn from mindspore.dataset…

手把手教你使用kimi創建流程圖【實踐篇】

學境思源&#xff0c;一鍵生成論文初稿&#xff1a; AcademicIdeas - 學境思源AI論文寫作 引言 在昨日的文章中&#xff0c;我們介紹了如何使用Kimi生成論文中的流程圖。今天&#xff0c;我們將更進一步&#xff0c;通過實踐案例來展示Kimi在生成流程圖方面的應用。這不僅將加…

【大數據技術原理與應用(概念、存儲、處理、分析與應用)】第1章-大數據概述習題與知識點回顧

文章目錄 單選題多選題知識點回顧幾次信息化浪潮主要解決什么問題&#xff1f;信息科技為大數據時代提供哪些技術支撐&#xff1f;數據產生方式有哪些變革&#xff1f;大數據的發展歷程大數據的四個特點&#xff08;4V&#xff09;大數據對思維方式的影響大數據有哪些關鍵技術&…

burpsuite 抓https的方法(CA證書操作)

https://cloud.tencent.com/developer/article/1391501

軟考《信息系統運行管理員》-1.2信息系統運維

1.2信息系統運維 傳統運維模式&#xff08;軟件&#xff09; 泛化&#xff1a;軟件交付后圍繞其所做的任何工作糾錯&#xff1a;軟件運行中錯誤的發現和改正適應&#xff1a;為適應環境做出的改變用戶支持&#xff1a;為軟件用戶提供的支持 新的不同視角下的運維 “管理”的…

Java 面試指南合集

線程篇 springBoot篇 待更新 黑夜無論怎樣悠長&#xff0c;白晝總會到來。 此文會一直更新哈 如果你希望成功&#xff0c;當以恒心為良友&#xff0c;以經驗為參謀&#xff0c;以當心為兄弟&#xff0c;以希望為哨兵。

拉普拉斯變換與卷積

前面描述 卷積&#xff0c;本文由卷積引入拉普拉斯變換。 拉普拉斯變換就是給傅里葉變換的 iωt 加了個實部&#xff0c;也可以反著理解&#xff0c;原函數乘以 e ? β t e^{-\beta t} e?βt 再做傅里葉變換&#xff0c;本質上都是傅里葉變換的擴展。 加入實部的拉普拉斯變…

【建設方案】智慧園區大數據云平臺建設方案(DOC原件)

大數據云平臺建設技術要點主要包括以下幾個方面&#xff1a; 云計算平臺選擇&#xff1a;選擇安全性高、效率性強、成本可控的云計算平臺&#xff0c;如阿里云、騰訊云等&#xff0c;確保大數據處理的基礎環境穩定可靠。 數據存儲與管理&#xff1a;利用Hadoop、HBase等分布式…

一年Java轉GO|19K|騰訊 CSIG 一二面經

面經哥只做互聯網社招面試經歷分享&#xff0c;關注我&#xff0c;每日推送精選面經&#xff0c;面試前&#xff0c;先找面經哥 背景 學歷&#xff1a;本科工作經驗&#xff1a;一年(不算實習)當前語言&#xff1a;Javabase&#xff1a;武漢部門\崗位&#xff1a;騰訊云? 一…