deno.land / x / sheetjs@v0.18.3 / demos / chrome / table.js

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com *//* eslint-env browser *//* global XLSX, chrome */chrome.runtime.onInstalled.addListener(function() { chrome.contextMenus.create({ type: "normal", id: "sjsexport", title: "Export Table to XLSX", contexts: ["page", "selection"] }); chrome.contextMenus.create({ type: "normal", id: "sj5export", title: "Export All Tables in Page", contexts: ["page", "selection"] }); chrome.contextMenus.onClicked.addListener(function(info/*, tab*/) { var mode = ""; switch(info.menuItemId) { case 'sjsexport': mode = "JS"; break; case 'sj5export': mode = "J5"; break; default: return; } chrome.tabs.query({active: true, currentWindow: true}, function(tabs){ chrome.tabs.sendMessage(tabs[0].id, {Sheet:mode}, sjsexport_cb); }); });
chrome.contextMenus.create({ id: "sjsabout", title: "About", contexts: ["browser_action"] }); chrome.contextMenus.onClicked.addListener(function(info/*, tab*/) { if(info.menuItemId !== "sjsabout") return; chrome.tabs.create({url: "https://sheetjs.com/"}); });});
function sjsexport_cb(wb) { if(!wb || !wb.SheetNames || !wb.Sheets) { return alert("Error in exporting table"); } XLSX.writeFile(wb, "export.xlsx");}
sheetjs

Version Info

Tagged at
2 years ago