docs.sheetjs.com/index.html

5275 lines
999 KiB
HTML
Raw Permalink Normal View History

2020-01-28 05:02:07 +00:00
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>SheetJS Community Edition</title>
<link rel="icon" href="data:image/x-icon;base64,AAABAAEAEBAAAAEACABoBQAAFgAAACgAAAAQAAAAIAAAAAEACAAAAAAAAAIAAAAAAAAAAAAAAAAAAAAAAAAKCgr/FRUX/xYWGP8YGBr/GRkb/xsbHP8dHR7/Hh4f/x4eIP8fHyD/ICAh/yMjJP8kJCX/JiYo/ygoKv8pKSr/LCwu/y0tLv80NDT/QUFC/0ZGR/9MTE7/UFBR/1JSUv9bW1v/XFxc/2BgYP9hYWP/aGhp/2xsbP9ycnL/d3d3/3l5e/98fHz/f3+A/2dn/P9z3a//cNX8/4CAgP+Xl5f/nZ2e/56en/+fn5//n5+h/6amp/+rq6v/rKys/7CvsP+zs7T/uLi5/7u7u/+8vLz/wMDA/8fHx//Kysr/zc3N/9HR0f/d3d3/3t7e/+Xl5f/q6ur/6+vr/+3t7f/z8/P/9fX1//b29v/39/f/+Pj4//n5+f/6+vr/+/v7//z8/P/9/f3//v7+//////8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/NCYmJiYmJiYmJiYmJiYmNCZKSkpKSkpKSkpKSkpKSiYmSkpKRisdRkMbMklKSkomJkpKSSEiNUhEEQwpSUpKJiZKSi8LHhhAPAwBDDZKSiYmSkoWACA7SEc6HAEaSkomJkpKBxI/SkpKSj4ICkpKJiZKSgUTR0pKSkpGDwZKSiYmSkoTED1KSkpKOQQVSkomJkpKKgowMy4sNycIMUpKJiZKSkEZDgkDAgsNH0VKSiYmSkpKQigUBgkXLUhKSkomJkpKSkpKSkpKSkpKSkpKJiYmJiYmJiYmJiYmJiYmJiYmIyUkNDQ0NDQ0NDQ0NDQmOCYmJiYmJiYmJiYmJiYmOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=" />
<link rel="stylesheet" href="/__/grip/static/octicons/octicons.css" />
<style>
2022-03-25 04:01:40 +00:00
/*!
* GitHub Light v0.4.1
2020-01-28 05:02:07 +00:00
* Copyright (c) 2012 - 2017 GitHub, Inc.
* Licensed under MIT (https://github.com/primer/github-syntax-theme-generator/blob/master/LICENSE)
2022-03-25 04:01:40 +00:00
*/.pl-c{color:#6a737d}.pl-c1,.pl-s .pl-v{color:#005cc5}.pl-e,.pl-en{color:#6f42c1}.pl-smi,.pl-s .pl-s1{color:#24292e}.pl-ent{color:#22863a}.pl-k{color:#d73a49}.pl-s,.pl-pds,.pl-s .pl-pse .pl-s1,.pl-sr,.pl-sr .pl-cce,.pl-sr .pl-sre,.pl-sr .pl-sra{color:#032f62}.pl-v,.pl-smw{color:#e36209}.pl-bu{color:#b31d28}.pl-ii{color:#fafbfc;background-color:#b31d28}.pl-c2{color:#fafbfc;background-color:#d73a49}.pl-c2::before{content:"^M"}.pl-sr .pl-cce{font-weight:bold;color:#22863a}.pl-ml{color:#735c0f}.pl-mh,.pl-mh .pl-en,.pl-ms{font-weight:bold;color:#005cc5}.pl-mi{font-style:italic;color:#24292e}.pl-mb{font-weight:bold;color:#24292e}.pl-md{color:#b31d28;background-color:#ffeef0}.pl-mi1{color:#22863a;background-color:#f0fff4}.pl-mc{color:#e36209;background-color:#ffebda}.pl-mi2{color:#f6f8fa;background-color:#005cc5}.pl-mdr{font-weight:bold;color:#6f42c1}.pl-ba{color:#586069}.pl-sg{color:#959da5}.pl-corl{text-decoration:underline;color:#032f62}.CodeMirror{font-family:monospace;height:300px;color:black;direction:ltr}.CodeMirror-lines{padding:4px 0}.CodeMirror pre{padding:0 4px}.CodeMirror-scrollbar-filler,.CodeMirror-gutter-filler{background-color:white}.CodeMirror-gutters{border-right:1px solid #ddd;background-color:#f7f7f7;white-space:nowrap}.CodeMirror-linenumber{padding:0 3px 0 5px;min-width:20px;text-align:right;color:#999;white-space:nowrap}.CodeMirror-guttermarker{color:black}.CodeMirror-guttermarker-subtle{color:#999}.CodeMirror-cursor{border-left:1px solid black;border-right:none;width:0}.CodeMirror div.CodeMirror-secondarycursor{border-left:1px solid silver}.cm-fat-cursor .CodeMirror-cursor{width:auto;border:0 !important;background:#7e7}.cm-fat-cursor div.CodeMirror-cursors{z-index:1}.cm-fat-cursor-mark{background-color:rgba(20,255,20,0.5);animation:blink 1.06s steps(1) infinite}.cm-animate-fat-cursor{width:auto;border:0;animation:blink 1.06s steps(1) infinite;background-color:#7e7}@keyframes blink{0%{}50%{background-color:transparent}100%{}}.cm-tab{display:inline-block;text-decoration:inherit}.CodeMirror-rulers{position:absolute;left:0;right:0;top:-50px;bottom:-20px;overflow:hidden}.CodeMirror-ruler{border-left:1px solid #ccc;top:0;bottom:0;position:absolute}.cm-s-default .cm-header{color:blue}.cm-s-default .cm-quote{color:#090}.cm-negative{color:#d44}.cm-positive{color:#292}.cm-header,.cm-strong{font-weight:bold}.cm-em{font-style:italic}.cm-link{text-decoration:underline}.cm-strikethrough{text-decoration:line-through}.cm-s-default .cm-keyword{color:#708}.cm-s-default .cm-atom{color:#219}.cm-s-default .cm-number{color:#164}.cm-s-default .cm-def{color:#00f}.cm-s-default .cm-variable-2{color:#05a}.cm-s-default .cm-variable-3,.cm-s-default .cm-type{color:#085}.cm-s-default .cm-comment{color:#a50}.cm-s-default .cm-string{color:#a11}.cm-s-default .cm-string-2{color:#f50}.cm-s-default .cm-meta{color:#555}.cm-s-default .cm-qualifier{color:#555}.cm-s-default .cm-builtin{color:#30a}.cm-s-default .cm-bracket{color:#997}.cm-s-default .cm-tag{color:#170}.cm-s-default .cm-attribute{color:#00c}.cm-s-default .cm-hr{color:#999}.cm-s-default .cm-link{color:#00c}.cm-s-default .cm-error{color:#f00}.cm-invalidchar{color:#f00}.CodeMirror-composing{border-bottom:2px solid}div.CodeMirror span.CodeMirror-matchingbracket{color:#0b0}div.CodeMirror span.CodeMirror-nonmatchingbracket{color:#a22}.CodeMirror-matchingtag{background:rgba(255,150,0,0.3)}.CodeMirror-activeline-background{background:#e8f2ff}.CodeMirror{position:relative;overflow:hidden;background:white}.CodeMirror-scroll{overflow:scroll !important;margin-bottom:-30px;margin-right:-30px;padding-bottom:30px;height:100%;outline:none;position:relative}.CodeMirror-sizer{position:relative;border-right:30px solid transparent}.CodeMirror-vscrollbar,.CodeMirror-hscrollbar,.CodeMirror-scrollbar-filler,.CodeMirror-gutter-filler{position:absolute;z-index:6;display:none}.CodeMirror-vscrollbar{right:0;top:0;overflow-x:hidden;overflow-y:scroll}.CodeMirror-hscrollbar{bottom:0;left:0;overflow-y:hidden;overflow-x:scroll}.CodeMirror-scrollbar-filler{right:0;bottom:0}.CodeMirror-gutter-filler{left:0;bottom
2020-01-28 05:02:07 +00:00
* GitHub Light v0.4.2
* Copyright (c) 2012 - 2017 GitHub, Inc.
* Licensed under MIT (https://github.com/primer/github-syntax-theme-generator/blob/master/LICENSE)
2022-03-25 04:01:40 +00:00
*/.cm-s-github-light.CodeMirror{background:#fff;color:#24292e}.cm-s-github-light .CodeMirror-gutters{background:#fff;border-right-width:0}.cm-s-github-light .CodeMirror-guttermarker{color:white}.cm-s-github-light .CodeMirror-guttermarker-subtle{color:#d0d0d0}.cm-s-github-light .CodeMirror-linenumber{color:#959da5;padding:0 16px 0 16px}.cm-s-github-light .CodeMirror-cursor{border-left:1px solid #24292e}.cm-s-github-light div.CodeMirror-selected,.cm-s-github-light .CodeMirror-line::-moz-selection,.cm-s-github-light .CodeMirror-line>span::-moz-selection,.cm-s-github-light .CodeMirror-line>span>span::-moz-selection,.cm-s-github-light .CodeMirror-line::-moz-selection,.cm-s-github-light .CodeMirror-line>span::-moz-selection,.cm-s-github-light .CodeMirror-line>span>span::-moz-selection{background:#c8c8fa}.cm-s-github-light div.CodeMirror-selected,.cm-s-github-light .CodeMirror-line::selection,.cm-s-github-light .CodeMirror-line>span::selection,.cm-s-github-light .CodeMirror-line>span>span::selection,.cm-s-github-light .CodeMirror-line::-moz-selection,.cm-s-github-light .CodeMirror-line>span::-moz-selection,.cm-s-github-light .CodeMirror-line>span>span::-moz-selection{background:#c8c8fa}.cm-s-github-light .CodeMirror-activeline-background{background:#fafbfc}.cm-s-github-light .CodeMirror-matchingbracket{text-decoration:underline;color:#24292e !important}.cm-s-github-light .CodeMirror-lines{font-family:"SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace;font-size:12px;background:#fff;line-height:1.5}.cm-s-github-light .cm-comment{color:#6a737d}.cm-s-github-light .cm-constant{color:#005cc5}.cm-s-github-light .cm-entity{font-weight:normal;font-style:normal;text-decoration:none;color:#6f42c1}.cm-s-github-light .cm-keyword{font-weight:normal;font-style:normal;text-decoration:none;color:#d73a49}.cm-s-github-light .cm-storage{color:#d73a49}.cm-s-github-light .cm-string{font-weight:normal;font-style:normal;text-decoration:none;color:#032f62}.cm-s-github-light .cm-support{font-weight:normal;font-style:normal;text-decoration:none;color:#005cc5}.cm-s-github-light .cm-variable{font-weight:normal;font-style:normal;text-decoration:none;color:#e36209}details-dialog{position:fixed;margin:10vh auto;top:0;left:50%;transform:translateX(-50%);z-index:999;max-height:80vh;max-width:90vw;width:448px}.octicon{display:inline-block;vertical-align:text-top;fill:currentColor}body.intent-mouse [role="button"]:focus,body.intent-mouse button:focus,body.intent-mouse summary:focus{outline:none}.CodeMirror{height:calc(100vh - 1px)}.file-editor-textarea{width:100%;padding:5px 4px;font:12px "SFMono-Regular",Consolas,"Liberation Mono",Menlo,Courier,monospace;resize:vertical;border:0;border-radius:0;outline:none}.container-preview .tabnav-tabs{margin:-6px 0 -6px -11px}.container-preview .tabnav-tabs .tabnav-tab{padding:12px 15px;border-radius:0}.container-preview .tabnav-tabs>.selected:first-child{border-top-left-radius:3px}.container-preview .tabnav-tabs .selected{font-weight:600}.container-preview.template-editor .commit-create,.container-preview.template-editor .file-actions{display:block}.container-preview.template-editor .show-code,.container-preview.template-editor .commit-preview,.container-preview.template-editor .loading-preview-msg,.container-preview.template-editor .no-changes-preview-msg,.container-preview.template-editor .error-preview-msg{display:none}.container-preview.render-editor .commit-create,.container-preview.render-editor .file-actions{display:block}.container-preview.render-editor .template-editor,.container-preview.render-editor .show-code,.container-preview.render-editor .commit-preview,.container-preview.render-editor .loading-preview-msg,.container-preview.render-editor .no-changes-preview-msg,.container-preview.render-editor .error-preview-msg{display:none}.container-preview.show-code .commit-create,.container-preview.show-code .file-actions{display:block}.container-preview.show-code .template-editor,.container-preview.show-code .render-editor,.container-preview.show-code .commit-preview,.container-preview.show-cod
* Primer-core
* http://primer.github.io
*
* Released under MIT license. Copyright (c) 2018 GitHub Inc.
*//*! normalize.css v4.1.1 | MIT License | github.com/necolas/normalize.css */html{font-family:sans-serif;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}body{margin:0}article,aside,details,figcaption,figure,footer,header,main,menu,nav,section{display:block}summary{display:list-item}audio,canvas,progress,video{display:inline-block}audio:not([controls]){display:none;height:0}progress{vertical-align:baseline}template,[hidden]{display:none}a{background-color:transparent}a:active,a:hover{outline-width:0}abbr[title]{border-bottom:none;text-decoration:underline;-webkit-text-decoration:underline dotted;text-decoration:underline dotted}b,strong{font-weight:inherit}b,strong{font-weight:bolder}dfn{font-style:italic}h1{font-size:2em;margin:0.67em 0}mark{background-color:#ff0;color:#000}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-0.25em}sup{top:-0.5em}img{border-style:none}svg:not(:root){overflow:hidden}code,kbd,pre,samp{font-family:monospace, monospace;font-size:1em}figure{margin:1em 40px}hr{box-sizing:content-box;height:0;overflow:visible}button,input,select,textarea{font:inherit;margin:0}optgroup{font-weight:bold}button,input{overflow:visible}button,select{text-transform:none}button,html [type="button"],[type="reset"],[type="submit"]{-webkit-appearance:button}button::-moz-focus-inner,[type="button"]::-moz-focus-inner,[type="reset"]::-moz-focus-inner,[type="submit"]::-moz-focus-inner{border-style:none;padding:0}button:-moz-focusring,[type="button"]:-moz-focusring,[type="reset"]:-moz-focusring,[type="submit"]:-moz-focusring{outline:1px dotted ButtonText}fieldset{border:1px solid #c0c0c0;margin:0 2px;padding:0.35em 0.625em 0.75em}legend{box-sizing:border-box;color:inherit;display:table;max-width:100%;padding:0;white-space:normal}textarea{overflow:auto}[type="checkbox"],[type="radio"]{box-sizing:border-box;padding:0}[type="number"]::-webkit-inner-spin-button,[type="number"]::-webkit-outer-spin-button{height:auto}[type="search"]{-webkit-appearance:textfield;outline-offset:-2px}[type="search"]::-webkit-search-cancel-button,[type="search"]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-input-placeholder{color:inherit;opacity:0.54}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}*{box-sizing:border-box}input,select,textarea,button{font-family:inherit;font-size:inherit;line-height:inherit}body{font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";font-size:14px;line-height:1.5;color:#24292e;background-color:#fff}a{color:#0366d6;text-decoration:none}a:hover{text-decoration:underline}b,strong{font-weight:600}hr,.rule{height:0;margin:15px 0;overflow:hidden;background:transparent;border:0;border-bottom:1px solid #dfe2e5}hr::before,.rule::before{display:table;content:""}hr::after,.rule::after{display:table;clear:both;content:""}table{border-spacing:0;border-collapse:collapse}td,th{padding:0}button{cursor:pointer;border-radius:0}details summary{cursor:pointer}details:not([open])>*:not(summary){display:none !important}h1,h2,h3,h4,h5,h6{margin-top:0;margin-bottom:0}h1{font-size:32px;font-weight:600}h2{font-size:24px;font-weight:600}h3{font-size:20px;font-weight:600}h4{font-size:16px;font-weight:600}h5{font-size:14px;font-weight:600}h6{font-size:12px;font-weight:600}p{margin-top:0;margin-bottom:10px}small{font-size:90%}blockquote{margin:0}ul,ol{padding-left:0;margin-top:0;margin-bottom:0}ol ol,ul ol{list-style-type:lower-roman}ul ul ol,ul ol ol,ol ul ol,ol ol ol{list-style-type:lower-alpha}dd{margin-left:0}tt,code{font-family:"SFMono-Regular",Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:12px}pre{margin-top:0;margin-bottom:0;font-family:"SFMono-Regular",Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:12px}.octicon{vertical-align:text-bottom}.Box{background-color:#fff;border:1px solid #d1d5da;border-radius:3px}.Box--condensed{line-height:1.25}.Box--condensed .Box-header{padding:8px 16px}.Box--condensed .Box-body{padding:8px 16px}.B
/*# sourceMappingURL=frameworks-afd119c67567f2c750f08c93d4211333.css.map */
2022-03-03 09:23:56 +00:00
2022-03-25 04:01:40 +00:00
/*!
* Primer-marketing
* http://primer.github.io
*
* Released under MIT license. Copyright (c) 2018 GitHub Inc.
*/.alt-mono-font{font-family:"SFMono-Regular",Consolas,"Liberation Mono",Menlo,Courier,monospace}.alt-h0,.alt-h1,.alt-h2,.alt-h3,.alt-h4,.alt-h5,.alt-h6,.alt-lead{-webkit-font-smoothing:antialiased;font-family:Roboto,-apple-system,BlinkMacSystemFont,"Helvetica Neue","Segoe UI","Oxygen","Ubuntu","Cantarell","Open Sans",sans-serif}.alt-h0{font-size:48px;font-weight:300}@media (min-width: 768px){.alt-h0{font-size:54px}}@media (min-width: 1012px){.alt-h0{font-size:72px}}.alt-h1{font-size:36px;font-weight:300}@media (min-width: 768px){.alt-h1{font-size:48px}}@media (min-width: 1012px){.alt-h1{font-size:54px}}.alt-h2{font-size:28px;font-weight:300}@media (min-width: 768px){.alt-h2{font-size:34px}}@media (min-width: 1012px){.alt-h2{font-size:38px}}.alt-h3{font-size:18px;font-weight:400}@media (min-width: 768px){.alt-h3{font-size:20px}}@media (min-width: 1012px){.alt-h3{font-size:22px}}.alt-h4{font-size:16px;font-weight:500}.alt-h5{font-size:14px;font-weight:500}.alt-h6{font-size:12px;font-weight:500}.alt-lead{-webkit-font-smoothing:antialiased;font-size:21px;font-weight:300}@media (min-width: 768px){.alt-lead{font-size:24px}}@media (min-width: 1012px){.alt-lead{font-size:26px}}.alt-text-small{font-size:14px !important}.pullquote{padding-top:0;padding-bottom:0;padding-left:8px;margin-bottom:24px;font-family:"SFMono-Regular",Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:16px;line-height:1.4;color:#586069;border-left:3px solid #e1e4e8}@media (min-width: 768px){.pullquote{padding-left:12px;margin-bottom:32px;margin-left:-15px;font-size:18px;line-height:1.5}}.btn-orange{color:#fff;background-color:#d25a08;background-image:linear-gradient(-180deg, #f7802f 0%, #d25a08 90%)}.btn-orange:focus,.btn-orange.focus{box-shadow:0 0 0 0.2em rgba(247,128,47,0.4)}.btn-orange:hover,.btn-orange.hover{background-color:#c85607;background-image:linear-gradient(-180deg, #f77a25 0%, #c85607 90%);background-position:-.5em;border-color:rgba(27,31,35,0.5)}.btn-orange:active,.btn-orange.selected,[open]>.btn-orange{background-color:#c65e17;background-image:none;border-color:rgba(27,31,35,0.5);box-shadow:inset 0 0.15em 0.3em rgba(27,31,35,0.15)}.btn-orange:disabled,.btn-orange.disabled{color:rgba(255,255,255,0.75);background-color:#e9ad83;background-image:none;border-color:rgba(27,31,35,0.2);box-shadow:none}.btn-orange .Counter{color:#f46909;background-color:#fff}.btn-outline-purple{color:#6f42c1;background-color:#fff;background-image:none}.btn-outline-purple .Counter{background-color:rgba(27,31,35,0.07)}.btn-outline-purple:hover,.btn-outline-purple:active,.btn-outline-purple.selected,[open]>.btn-outline-purple{color:#fff;background-color:#6f42c1;background-image:none;border-color:#6f42c1}.btn-outline-purple:hover .Counter,.btn-outline-purple:active .Counter,.btn-outline-purple.selected .Counter,[open]>.btn-outline-purple .Counter{color:#6f42c1;background-color:#fff}.btn-outline-purple:focus{border-color:#6f42c1;box-shadow:0 0 0 0.2em rgba(111,66,193,0.4)}.btn-outline-purple:disabled,.btn-outline-purple.disabled{color:rgba(27,31,35,0.3);background-color:#fff;border-color:rgba(27,31,35,0.15);box-shadow:none}.btn-outline-orange{color:#f66a0a;background-color:#fff;background-image:none}.btn-outline-orange .Counter{background-color:rgba(27,31,35,0.07)}.btn-outline-orange:hover,.btn-outline-orange:active,.btn-outline-orange.selected,[open]>.btn-outline-orange{color:#fff;background-color:#f66a0a;background-image:none;border-color:#f66a0a}.btn-outline-orange:hover .Counter,.btn-outline-orange:active .Counter,.btn-outline-orange.selected .Counter,[open]>.btn-outline-orange .Counter{color:#f66a0a;background-color:#fff}.btn-outline-orange:focus{border-color:#f66a0a;box-shadow:0 0 0 0.2em rgba(246,106,10,0.4)}.btn-outline-orange:disabled,.btn-outline-orange.disabled{color:rgba(27,31,35,0.3);background-color:#fff;border-color:rgba(27,31,35,0.15);box-shadow:none}.btn-outline-green{color:#28a745;background-color:#fff;background-image:none}.btn-outline-green .Counter{background-color:rgba(27,31,35,0.07)}.btn-outline-green:hover,.btn-outline-green:active,.bt
/*# sourceMappingURL=site-73680c8bae9d90e48e18affb463ea2cd.css.map */
2022-03-03 09:23:56 +00:00
2022-03-25 04:01:40 +00:00
/*!
* Primer-product
* http://primer.github.io
*
* Released under MIT license. Copyright (c) 2018 GitHub Inc.
*/.flash{position:relative;padding:16px;color:#032f62;background-color:#dbedff;border:1px solid rgba(27,31,35,0.15);border-radius:3px}.flash p:last-child{margin-bottom:0}.flash-messages{margin-bottom:24px}.flash-close{float:right;padding:16px;margin:-16px;color:inherit;text-align:center;cursor:pointer;background:none;border:0;-webkit-appearance:none;-moz-appearance:none;appearance:none;opacity:0.6}.flash-close:hover{opacity:1}.flash-action{float:right;margin-top:-3px;margin-left:24px}.flash-warn{color:#735c0f;background-color:#fffbdd;border-color:rgba(27,31,35,0.15)}.flash-error{color:#86181d;background-color:#ffdce0;border-color:rgba(27,31,35,0.15)}.flash-success{color:#165c26;background-color:#dcffe4;border-color:rgba(27,31,35,0.15)}.flash-full{margin-top:-1px;border-width:1px 0;border-radius:0}.warning{padding:.5em;margin-bottom:0.8em;font-weight:600;background-color:#fffbdd}.avatar{display:inline-block;overflow:hidden;line-height:1;vertical-align:middle;border-radius:3px}.avatar-small{border-radius:2px}.avatar-link{float:left;line-height:1}.avatar-group-item{display:inline-block;margin-bottom:3px}.avatar-parent-child{position:relative}.avatar-child{position:absolute;right:-15%;bottom:-9%;background-color:#fff;border-radius:2px;box-shadow:-2px -2px 0 rgba(255,255,255,0.8)}.avatar-stack{display:inline-block;white-space:nowrap}.avatar-stack .avatar{position:relative;z-index:2;display:inline-block;width:20px;height:20px;box-sizing:content-box;margin-right:-15px;background-color:#fff;border-right:1px solid #fff;border-radius:2px;transition:margin 0.1s ease-in-out}.avatar-stack .avatar:only-child{background-color:transparent}.avatar-stack .avatar:first-child{z-index:3}.avatar-stack .avatar:last-child{z-index:1;margin-right:0;border-right:0}.avatar-stack:hover .avatar{margin-right:3px}.avatar-stack:hover .avatar:last-child{margin-right:0}.AvatarStack{position:relative;min-width:26px;height:20px}.AvatarStack .AvatarStack-body{position:absolute}.AvatarStack.AvatarStack--two{min-width:36px}.AvatarStack.AvatarStack--three-plus{min-width:46px}.AvatarStack-body{display:flex;background:#fff}.AvatarStack-body .avatar{position:relative;z-index:2;display:flex;width:20px;height:20px;box-sizing:content-box;margin-right:-11px;background-color:#fff;border-right:1px solid #fff;border-radius:2px;transition:margin 0.1s ease-in-out}.AvatarStack-body .avatar:first-child{z-index:3}.AvatarStack-body .avatar:last-child{z-index:1;border-right:0}.AvatarStack-body .avatar img{border-radius:2px}.AvatarStack-body .avatar:nth-child(n+4){display:none;opacity:0}.AvatarStack-body:hover .avatar{margin-right:3px}.AvatarStack-body:hover .avatar:nth-child(n+4){display:flex;opacity:1}.AvatarStack-body:hover .avatar-more{display:none !important}.avatar.avatar-more{z-index:1;margin-right:0;background:#f6f8fa}.avatar.avatar-more::before,.avatar.avatar-more::after{position:absolute;display:block;height:20px;content:"";border-radius:2px;outline:1px solid #fff}.avatar.avatar-more::before{width:17px;background:#e1e4e8}.avatar.avatar-more::after{width:14px;background:#d1d5da}.AvatarStack--right .AvatarStack-body{right:0;flex-direction:row-reverse}.AvatarStack--right .AvatarStack-body:hover .avatar{margin-right:0;margin-left:3px}.AvatarStack--right .avatar.avatar-more{background:#d1d5da}.AvatarStack--right .avatar.avatar-more::before{width:5px}.AvatarStack--right .avatar.avatar-more::after{width:2px;background:#f6f8fa}.AvatarStack--right .avatar{margin-right:0;margin-left:-11px;border-right:0;border-left:1px solid #fff}.CircleBadge{display:flex;align-items:center;justify-content:center;background-color:#fff;border-radius:50%;box-shadow:0 1px 5px rgba(27,31,35,0.15)}.CircleBadge-icon{max-width:60% !important;height:auto !important;max-height:55% !important}.CircleBadge--small{width:56px;height:56px}.CircleBadge--medium{width:96px;height:96px}.CircleBadge--large{width:128px;height:128px}.DashedConnection{position:relative}.DashedConnection::before{position:absolute;top:50%;left:0;width:100%;content:"";border-bottom:2px dashed #e1e4e8}.DashedConnection .CircleBadge{pos
/*# sourceMappingURL=github-a12fe4c88979a8931d7e7adfee5656fc.css.map */
2020-01-28 05:02:07 +00:00
</style>
<style>
/* Page tweaks */
.preview-page {
margin-top: 64px;
}
/* User-content tweaks */
.timeline-comment-wrapper > .timeline-comment:after,
.timeline-comment-wrapper > .timeline-comment:before {
content: none;
}
/* User-content overrides */
.discussion-timeline.wide {
width: 920px;
}
</style>
</head>
<body>
<div class="page">
<div id="preview-page" class="preview-page" data-autorefresh-url="">
2022-03-25 04:01:40 +00:00
<div role="main" class="main-content">
<div class="container new-discussion-timeline experiment-repo-nav">
<div class="repository-content">
<div id="readme" class="readme boxed-group clearfix announce instapaper_body md">
<h3>
<span class="octicon octicon-book"></span>
SheetJS Community Edition
</h3>
<article class="markdown-body entry-content" itemprop="text" id="grip-content">
<h1>
2021-09-12 09:16:01 +00:00
<a id="user-content-sheetjs" class="anchor" href="#sheetjs" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a><a href="https://sheetjs.com" rel="nofollow">SheetJS</a>
2020-01-28 05:02:07 +00:00
</h1>
2022-02-14 02:02:46 +00:00
<p>The SheetJS Community Edition offers battle-tested open-source solutions for
extracting useful data from almost any complex spreadsheet and generating new
spreadsheets that will work with legacy and modern software alike.</p>
<p><a href="https://sheetjs.com/pro" rel="nofollow">SheetJS Pro</a> offers solutions beyond data processing:
Edit complex templates with ease; let out your inner Picasso with styling; make
custom sheets with images/graphs/PivotTables; evaluate formula expressions and
port calculations to web apps; automate common spreadsheet tasks, and much more!</p>
2022-02-01 06:12:44 +00:00
<p><a href="https://camo.githubusercontent.com/756bdb2076e17b3344ba27668018c9f0011b82a2a02f029790b3e3aa805154d7/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f53686565744a532f73686565746a73" target="_blank" rel="nofollow"><img src="https://camo.githubusercontent.com/756bdb2076e17b3344ba27668018c9f0011b82a2a02f029790b3e3aa805154d7/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f53686565744a532f73686565746a73" alt="License" data-canonical-src="https://img.shields.io/github/license/SheetJS/sheetjs" style="max-width:100%;"></a>
<a href="https://github.com/SheetJS/sheetjs/actions"><img src="https://camo.githubusercontent.com/dba2780ce8f220a047aa004f096aa7b440ceee8afdb7a8b8f539e240e33673d5/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f73686565746a732f73686565746a732f54657374733a2532306e6f64652e6a73" alt="Build Status" data-canonical-src="https://img.shields.io/github/workflow/status/sheetjs/sheetjs/Tests:%20node.js" style="max-width:100%;"></a>
<a href="https://snyk.io/test/github/SheetJS/sheetjs" rel="nofollow"><img src="https://camo.githubusercontent.com/7ce09de464c75d8a533b9b2a156b487ab8db9f025f6ca9119395d894e82f69a7/68747470733a2f2f696d672e736869656c64732e696f2f736e796b2f76756c6e65726162696c69746965732f6769746875622f53686565744a532f73686565746a73" alt="Snyk Vulnerabilities" data-canonical-src="https://img.shields.io/snyk/vulnerabilities/github/SheetJS/sheetjs" style="max-width:100%;"></a>
<a href="https://npmjs.org/package/xlsx" rel="nofollow"><img src="https://camo.githubusercontent.com/d271e8f58341837d08c59de862121e6faa608414d48b74fd12b88c507ee1bcdf/68747470733a2f2f696d672e736869656c64732e696f2f6e706d2f646d2f786c73782e737667" alt="npm Downloads" data-canonical-src="https://img.shields.io/npm/dm/xlsx.svg" style="max-width:100%;"></a>
<a href="https://github.com/SheetJS/sheetjs"><img src="https://camo.githubusercontent.com/5835ef9524626d64db0c7a60890d3723b178fb5ca8783250f405dd15dfc3b000/68747470733a2f2f67612d626561636f6e2e61707073706f742e636f6d2f55412d33363831303333332d312f53686565744a532f73686565746a733f706978656c" alt="Analytics" data-canonical-src="https://ga-beacon.appspot.com/UA-36810333-1/SheetJS/sheetjs?pixel" style="max-width:100%;"></a></p>
<p><a href="https://oss.sheetjs.com/sheetjs/tests/" rel="nofollow"><strong>Browser Test and Support Matrix</strong></a></p>
<p><a href="https://saucelabs.com/u/sheetjs" rel="nofollow"><img src="https://camo.githubusercontent.com/fd3943851066063e253cd05bc1a8b9436b80f841af7d193c3eacb560012acea6/68747470733a2f2f73617563656c6162732e636f6d2f62726f777365722d6d61747269782f73686565746a732e737667" alt="Build Status" data-canonical-src="https://saucelabs.com/browser-matrix/sheetjs.svg" style="max-width:100%;"></a></p>
<p><strong>Supported File Formats</strong></p>
2020-01-28 05:02:07 +00:00
<p><a href="formats.png" target="_blank" rel="noopener noreferrer"><img src="formats.png" alt="circo graph of format support" style="max-width:100%;"></a></p>
<p><a href="legend.png" target="_blank" rel="noopener noreferrer"><img src="legend.png" alt="graph legend" style="max-width:100%;"></a></p>
<h2>
<a id="user-content-table-of-contents" class="anchor" href="#table-of-contents" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>Table of Contents</h2>
<details>
<summary><b>Expand to show Table of Contents</b></summary>
<ul>
<li>
2022-02-14 02:02:46 +00:00
<a href="#getting-started">Getting Started</a>
2020-01-28 05:02:07 +00:00
<ul>
2022-05-11 21:03:03 +00:00
<li>
<a href="#installation">Installation</a>
<ul>
<li><a href="#standalone-browser-scripts">Standalone Browser Scripts</a></li>
<li><a href="#ecmascript-modules">ECMAScript Modules</a></li>
<li><a href="#deno">Deno</a></li>
<li><a href="#nodejs">NodeJS</a></li>
<li><a href="#photoshop-and-indesign">Photoshop and InDesign</a></li>
</ul>
</li>
2022-02-14 02:02:46 +00:00
<li><a href="#usage">Usage</a></li>
<li><a href="#the-zen-of-sheetjs">The Zen of SheetJS</a></li>
2020-01-28 05:02:07 +00:00
<li><a href="#js-ecosystem-demos">JS Ecosystem Demos</a></li>
</ul>
</li>
<li>
2022-02-14 02:02:46 +00:00
<a href="#acquiring-and-extracting-data">Acquiring and Extracting Data</a>
2020-01-28 05:02:07 +00:00
<ul>
2022-02-14 02:02:46 +00:00
<li><a href="#parsing-workbooks">Parsing Workbooks</a></li>
<li><a href="#processing-json-and-js-data">Processing JSON and JS Data</a></li>
<li><a href="#processing-html-tables">Processing HTML Tables</a></li>
2020-01-28 05:02:07 +00:00
</ul>
</li>
<li>
2022-03-03 09:23:56 +00:00
<a href="#processing-data">Processing Data</a>
2020-01-28 05:02:07 +00:00
<ul>
2022-03-03 09:23:56 +00:00
<li><a href="#modifying-workbook-structure">Modifying Workbook Structure</a></li>
<li><a href="#modifying-cell-values">Modifying Cell Values</a></li>
<li><a href="#modifying-other-worksheet--workbook--cell-properties">Modifying Other Worksheet / Workbook / Cell Properties</a></li>
2020-01-28 05:02:07 +00:00
</ul>
</li>
<li>
2022-02-14 02:02:46 +00:00
<a href="#packaging-and-releasing-data">Packaging and Releasing Data</a>
2020-01-28 05:02:07 +00:00
<ul>
2022-02-14 02:02:46 +00:00
<li><a href="#writing-workbooks">Writing Workbooks</a></li>
2020-01-28 05:02:07 +00:00
<li><a href="#writing-examples">Writing Examples</a></li>
<li><a href="#streaming-write">Streaming Write</a></li>
2022-02-14 02:02:46 +00:00
<li><a href="#generating-json-and-js-data">Generating JSON and JS Data</a></li>
<li><a href="#generating-html-tables">Generating HTML Tables</a></li>
2022-03-03 09:23:56 +00:00
<li><a href="#generating-single-worksheet-snapshots">Generating Single-Worksheet Snapshots</a></li>
2020-01-28 05:02:07 +00:00
</ul>
</li>
<li>
<a href="#interface">Interface</a>
<ul>
<li><a href="#parsing-functions">Parsing functions</a></li>
<li><a href="#writing-functions">Writing functions</a></li>
<li><a href="#utilities">Utilities</a></li>
</ul>
</li>
<li>
<a href="#common-spreadsheet-format">Common Spreadsheet Format</a>
<ul>
<li><a href="#general-structures">General Structures</a></li>
<li>
<a href="#cell-object">Cell Object</a>
<ul>
<li><a href="#data-types">Data Types</a></li>
<li><a href="#dates">Dates</a></li>
</ul>
</li>
<li>
<a href="#sheet-objects">Sheet Objects</a>
<ul>
<li><a href="#worksheet-object">Worksheet Object</a></li>
<li><a href="#chartsheet-object">Chartsheet Object</a></li>
<li><a href="#macrosheet-object">Macrosheet Object</a></li>
<li><a href="#dialogsheet-object">Dialogsheet Object</a></li>
</ul>
</li>
<li>
<a href="#workbook-object">Workbook Object</a>
<ul>
<li><a href="#workbook-file-properties">Workbook File Properties</a></li>
</ul>
</li>
<li>
<a href="#workbook-level-attributes">Workbook-Level Attributes</a>
<ul>
<li><a href="#defined-names">Defined Names</a></li>
<li><a href="#workbook-views">Workbook Views</a></li>
<li><a href="#miscellaneous-workbook-properties">Miscellaneous Workbook Properties</a></li>
</ul>
</li>
<li>
<a href="#document-features">Document Features</a>
<ul>
<li><a href="#formulae">Formulae</a></li>
2022-02-14 02:02:46 +00:00
<li><a href="#row-and-column-properties">Row and Column Properties</a></li>
2020-01-28 05:02:07 +00:00
<li><a href="#number-formats">Number Formats</a></li>
<li><a href="#hyperlinks">Hyperlinks</a></li>
<li><a href="#cell-comments">Cell Comments</a></li>
<li><a href="#sheet-visibility">Sheet Visibility</a></li>
<li><a href="#vba-and-macros">VBA and Macros</a></li>
</ul>
</li>
</ul>
</li>
<li>
<a href="#parsing-options">Parsing Options</a>
<ul>
<li><a href="#input-type">Input Type</a></li>
<li><a href="#guessing-file-type">Guessing File Type</a></li>
</ul>
</li>
<li>
<a href="#writing-options">Writing Options</a>
<ul>
<li><a href="#supported-output-formats">Supported Output Formats</a></li>
<li><a href="#output-type">Output Type</a></li>
</ul>
</li>
<li>
<a href="#utility-functions">Utility Functions</a>
<ul>
<li><a href="#array-of-arrays-input">Array of Arrays Input</a></li>
<li><a href="#array-of-objects-input">Array of Objects Input</a></li>
<li><a href="#html-table-input">HTML Table Input</a></li>
<li><a href="#formulae-output">Formulae Output</a></li>
<li>
<a href="#delimiter-separated-output">Delimiter-Separated Output</a>
<ul>
<li><a href="#utf-16-unicode-text">UTF-16 Unicode Text</a></li>
</ul>
</li>
<li><a href="#html-output">HTML Output</a></li>
<li><a href="#json">JSON</a></li>
</ul>
</li>
2022-02-14 02:02:46 +00:00
<li><a href="#file-formats">File Formats</a></li>
2020-01-28 05:02:07 +00:00
<li>
<a href="#testing">Testing</a>
<ul>
<li><a href="#node">Node</a></li>
<li><a href="#browser">Browser</a></li>
<li><a href="#tested-environments">Tested Environments</a></li>
<li><a href="#test-files">Test Files</a></li>
</ul>
</li>
<li>
<a href="#contributing">Contributing</a>
<ul>
<li><a href="#osxlinux">OSX/Linux</a></li>
<li><a href="#windows">Windows</a></li>
<li><a href="#tests">Tests</a></li>
</ul>
</li>
<li><a href="#license">License</a></li>
<li><a href="#references">References</a></li>
</ul>
</details>
<h2>
2022-02-14 02:02:46 +00:00
<a id="user-content-getting-started" class="anchor" href="#getting-started" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>Getting Started</h2>
<h3>
<a id="user-content-installation" class="anchor" href="#installation" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>Installation</h3>
2022-05-11 21:03:03 +00:00
<h4>
<a id="user-content-standalone-browser-scripts" class="anchor" href="#standalone-browser-scripts" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>Standalone Browser Scripts</h4>
<p>Each standalone release script is available at <a href="https://cdn.sheetjs.com/" rel="nofollow">https://cdn.sheetjs.com/</a>.</p>
<p>The current version is <code>0.18.7</code> and can be referenced as follows:</p>
<div class="highlight highlight-text-html-basic"><pre><span class="pl-c">&lt;!-- use version 0.18.7 --&gt;</span>
<span class="pl-kos">&lt;</span><span class="pl-ent">script</span> <span class="pl-c1">lang</span>="<span class="pl-s">javascript</span>" <span class="pl-c1">src</span>="<span class="pl-s">https://cdn.sheetjs.com/xlsx-0.18.7/package/dist/xlsx.full.min.js</span>"<span class="pl-kos">&gt;</span><span class="pl-kos">&lt;/</span><span class="pl-ent">script</span><span class="pl-kos">&gt;</span></pre></div>
<p>The <code>latest</code> tag references the latest version and updates with each release:</p>
2022-04-14 17:50:18 +00:00
<div class="highlight highlight-text-html-basic"><pre><span class="pl-c">&lt;!-- use the latest version --&gt;</span>
<span class="pl-kos">&lt;</span><span class="pl-ent">script</span> <span class="pl-c1">lang</span>="<span class="pl-s">javascript</span>" <span class="pl-c1">src</span>="<span class="pl-s">https://cdn.sheetjs.com/xlsx-latest/package/dist/xlsx.full.min.js</span>"<span class="pl-kos">&gt;</span><span class="pl-kos">&lt;/</span><span class="pl-ent">script</span><span class="pl-kos">&gt;</span></pre></div>
2022-05-11 21:03:03 +00:00
<p><strong>For production use, scripts should be downloaded and added to a public folder
alongside other scripts.</strong></p>
2022-02-14 02:02:46 +00:00
<details>
<summary><b>Browser builds</b> (click to show)</summary>
<p>The complete single-file version is generated at <code>dist/xlsx.full.min.js</code></p>
2022-03-03 09:23:56 +00:00
<p><code>dist/xlsx.core.min.js</code> omits codepage library (no support for XLS encodings)</p>
2022-02-14 02:02:46 +00:00
<p>A slimmer build is generated at <code>dist/xlsx.mini.min.js</code>. Compared to full build:</p>
<ul>
<li>codepage library skipped (no support for XLS encodings)</li>
2022-03-03 09:23:56 +00:00
<li>no support for XLSB / XLS / Lotus 1-2-3 / SpreadsheetML 2003 / Numbers</li>
2022-02-14 02:02:46 +00:00
<li>node stream utils removed</li>
</ul>
2022-04-14 17:50:18 +00:00
<p>These scripts are also available on the CDN:</p>
2022-05-11 21:03:03 +00:00
<div class="highlight highlight-text-html-basic"><pre><span class="pl-c">&lt;!-- use xlsx.mini.min.js from version 0.18.7 --&gt;</span>
<span class="pl-kos">&lt;</span><span class="pl-ent">script</span> <span class="pl-c1">lang</span>="<span class="pl-s">javascript</span>" <span class="pl-c1">src</span>="<span class="pl-s">https://cdn.sheetjs.com/xlsx-0.18.7/package/dist/xlsx.mini.min.js</span>"<span class="pl-kos">&gt;</span><span class="pl-kos">&lt;/</span><span class="pl-ent">script</span><span class="pl-kos">&gt;</span></pre></div>
</details>
<p><a href="https://bower.io/" rel="nofollow">Bower</a> plays nice with the CDN tarballs:</p>
<div class="highlight highlight-source-shell"><pre>$ npx bower install https://cdn.sheetjs.com/xlsx-0.18.7/xlsx-0.18.7.tgz</pre></div>
<p>Bower will place the standalone scripts in <code>bower_components/js-xlsx/dist/</code></p>
<details>
<summary><b>Internet Explorer and ECMAScript 3 Compatibility</b> (click to show)</summary>
<p>For broad compatibility with JavaScript engines, the library is written using
ECMAScript 3 language dialect as well as some ES5 features like <code>Array#forEach</code>.
Older browsers require shims to provide missing functions.</p>
<p>To use the shim, add the shim before the script tag that loads <code>xlsx.js</code>:</p>
<div class="highlight highlight-text-html-basic"><pre><span class="pl-c">&lt;!-- add the shim first --&gt;</span>
<span class="pl-kos">&lt;</span><span class="pl-ent">script</span> <span class="pl-c1">type</span>="<span class="pl-s">text/javascript</span>" <span class="pl-c1">src</span>="<span class="pl-s">shim.min.js</span>"<span class="pl-kos">&gt;</span><span class="pl-kos">&lt;/</span><span class="pl-ent">script</span><span class="pl-kos">&gt;</span>
<span class="pl-c">&lt;!-- after the shim is referenced, add the library --&gt;</span>
<span class="pl-kos">&lt;</span><span class="pl-ent">script</span> <span class="pl-c1">type</span>="<span class="pl-s">text/javascript</span>" <span class="pl-c1">src</span>="<span class="pl-s">xlsx.full.min.js</span>"<span class="pl-kos">&gt;</span><span class="pl-kos">&lt;/</span><span class="pl-ent">script</span><span class="pl-kos">&gt;</span></pre></div>
<p>Due to SSL certificate compatibility issues, it is highly recommended to save
the Standalone and Shim scripts from <a href="https://cdn.sheetjs.com/" rel="nofollow">https://cdn.sheetjs.com/</a> and add to a
public directory in the site.</p>
<p>The script also includes <code>IE_LoadFile</code> and <code>IE_SaveFile</code> for loading and saving
files in Internet Explorer versions 6-9. The <code>xlsx.extendscript.js</code> script
bundles the shim in a format suitable for Photoshop and other Adobe products.</p>
2022-02-14 02:02:46 +00:00
</details>
2022-05-11 21:03:03 +00:00
<h4>
<a id="user-content-ecmascript-modules" class="anchor" href="#ecmascript-modules" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>ECMAScript Modules</h4>
<p><em>Browser ESM</em></p>
2022-02-14 02:02:46 +00:00
<p>The ECMAScript Module build is saved to <code>xlsx.mjs</code> and can be directly added to
2022-04-14 17:50:18 +00:00
a page with a <code>script</code> tag using <code>type="module"</code>:</p>
2022-02-14 02:02:46 +00:00
<div class="highlight highlight-text-html-basic"><pre><span class="pl-kos">&lt;</span><span class="pl-ent">script</span> <span class="pl-c1">type</span>="<span class="pl-s">module</span>"<span class="pl-kos">&gt;</span>
2022-05-11 21:03:03 +00:00
<span class="pl-k">import</span> <span class="pl-kos">{</span> <span class="pl-s1">read</span><span class="pl-kos">,</span> <span class="pl-s1">writeFileXLSX</span> <span class="pl-kos">}</span> <span class="pl-k">from</span> <span class="pl-s">"https://cdn.sheetjs.com/xlsx-0.18.7/package/xlsx.mjs"</span><span class="pl-kos">;</span>
2022-02-14 02:02:46 +00:00
<span class="pl-c">/* load the codepage support library for extended support with older formats */</span>
2022-05-11 21:03:03 +00:00
<span class="pl-k">import</span> <span class="pl-kos">{</span> <span class="pl-s1">set_cptable</span> <span class="pl-kos">}</span> <span class="pl-k">from</span> <span class="pl-s">"https://cdn.sheetjs.com/xlsx-0.18.7/package/xlsx.mjs"</span><span class="pl-kos">;</span>
<span class="pl-k">import</span> <span class="pl-c1">*</span> <span class="pl-k">as</span> <span class="pl-s1">cptable</span> <span class="pl-k">from</span> <span class="pl-s">'https://cdn.sheetjs.com/xlsx-0.18.7/package/dist/cpexcel.full.mjs'</span><span class="pl-kos">;</span>
2022-02-14 02:02:46 +00:00
<span class="pl-en">set_cptable</span><span class="pl-kos">(</span><span class="pl-s1">cptable</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-kos">&lt;/</span><span class="pl-ent">script</span><span class="pl-kos">&gt;</span></pre></div>
2022-05-11 21:03:03 +00:00
<p><em>Frameworks (Angular, VueJS, React) and Bundlers (webpack, etc)</em></p>
<p>The NodeJS package is readily installed from the tarballs:</p>
<div class="highlight highlight-source-shell"><pre>$ npm install --save https://cdn.sheetjs.com/xlsx-0.18.7/xlsx-0.18.7.tgz <span class="pl-c"><span class="pl-c">#</span> npm</span>
$ pnpm install --save https://cdn.sheetjs.com/xlsx-0.18.7/xlsx-0.18.7.tgz <span class="pl-c"><span class="pl-c">#</span> pnpm</span>
$ yarn add --save https://cdn.sheetjs.com/xlsx-0.18.7/xlsx-0.18.7.tgz <span class="pl-c"><span class="pl-c">#</span> yarn</span></pre></div>
<p>Once installed, the library can be imported under the name <code>xlsx</code>:</p>
2022-02-14 02:02:46 +00:00
<div class="highlight highlight-source-ts"><pre><span class="pl-k">import</span> <span class="pl-kos">{</span> <span class="pl-s1">read</span><span class="pl-kos">,</span> <span class="pl-s1">writeFileXLSX</span> <span class="pl-kos">}</span> <span class="pl-k">from</span> <span class="pl-s">"xlsx"</span><span class="pl-kos">;</span>
<span class="pl-c">/* load the codepage support library for extended support with older formats */</span>
<span class="pl-k">import</span> <span class="pl-kos">{</span> <span class="pl-s1">set_cptable</span> <span class="pl-kos">}</span> <span class="pl-k">from</span> <span class="pl-s">"xlsx"</span><span class="pl-kos">;</span>
<span class="pl-k">import</span> <span class="pl-c1">*</span> <span class="pl-k">as</span> <span class="pl-s1">cptable</span> <span class="pl-k">from</span> <span class="pl-s">'xlsx/dist/cpexcel.full.mjs'</span><span class="pl-kos">;</span>
<span class="pl-en">set_cptable</span><span class="pl-kos">(</span><span class="pl-s1">cptable</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
2022-05-11 21:03:03 +00:00
<h4>
<a id="user-content-deno" class="anchor" href="#deno" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>Deno</h4>
2022-04-14 17:50:18 +00:00
<p><code>xlsx.mjs</code> can be imported in Deno:</p>
2022-05-11 21:03:03 +00:00
<div class="highlight highlight-source-ts"><pre><span class="pl-c">// <span class="pl-k">@deno</span>-types="https://cdn.sheetjs.com/xlsx-0.18.7/package/types/index.d.ts"</span>
<span class="pl-k">import</span> <span class="pl-c1">*</span> <span class="pl-k">as</span> <span class="pl-smi">XLSX</span> <span class="pl-k">from</span> <span class="pl-s">'https://cdn.sheetjs.com/xlsx-0.18.7/package/xlsx.mjs'</span><span class="pl-kos">;</span>
2022-02-14 02:02:46 +00:00
<span class="pl-c">/* load the codepage support library for extended support with older formats */</span>
2022-05-11 21:03:03 +00:00
<span class="pl-k">import</span> <span class="pl-c1">*</span> <span class="pl-k">as</span> <span class="pl-s1">cptable</span> <span class="pl-k">from</span> <span class="pl-s">'https://cdn.sheetjs.com/xlsx-0.18.7/package/dist/cpexcel.full.mjs'</span><span class="pl-kos">;</span>
2022-02-14 02:02:46 +00:00
<span class="pl-smi">XLSX</span><span class="pl-kos">.</span><span class="pl-en">set_cptable</span><span class="pl-kos">(</span><span class="pl-s1">cptable</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
2022-05-11 21:03:03 +00:00
<h4>
<a id="user-content-nodejs" class="anchor" href="#nodejs" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>NodeJS</h4>
2022-04-14 17:50:18 +00:00
<p>Tarballs are available on <a href="https://cdn.sheetjs.com" rel="nofollow">https://cdn.sheetjs.com</a>.</p>
2022-05-11 21:03:03 +00:00
<p>Each individual version can be referenced using a similar URL pattern.
<a href="https://cdn.sheetjs.com/xlsx-0.18.7/xlsx-0.18.7.tgz" rel="nofollow">https://cdn.sheetjs.com/xlsx-0.18.7/xlsx-0.18.7.tgz</a> is the URL for <code>0.18.7</code></p>
2022-04-14 17:50:18 +00:00
<p><a href="https://cdn.sheetjs.com/xlsx-latest/xlsx-latest.tgz" rel="nofollow">https://cdn.sheetjs.com/xlsx-latest/xlsx-latest.tgz</a> is a link to the latest
version and will refresh on each release.</p>
2022-05-11 21:03:03 +00:00
<p><em>Installation</em></p>
<p>Tarballs can be directly installed using a package manager:</p>
<div class="highlight highlight-source-shell"><pre>$ npm install https://cdn.sheetjs.com/xlsx-0.18.7/xlsx-0.18.7.tgz <span class="pl-c"><span class="pl-c">#</span> npm</span>
$ pnpm install https://cdn.sheetjs.com/xlsx-0.18.7/xlsx-0.18.7.tgz <span class="pl-c"><span class="pl-c">#</span> pnpm</span>
$ yarn add https://cdn.sheetjs.com/xlsx-0.18.7/xlsx-0.18.7.tgz <span class="pl-c"><span class="pl-c">#</span> yarn</span></pre></div>
2022-04-14 17:50:18 +00:00
<p>For general stability, "vendoring" modules is the recommended approach:</p>
<ol>
<li>
2022-05-11 21:03:03 +00:00
<p>Download the tarball (<code>xlsx-0.18.7.tgz</code>) for the desired version. The current
version is available at <a href="https://cdn.sheetjs.com/xlsx-0.18.7/xlsx-0.18.7.tgz" rel="nofollow">https://cdn.sheetjs.com/xlsx-0.18.7/xlsx-0.18.7.tgz</a></p>
2022-04-14 17:50:18 +00:00
</li>
<li>
<p>Create a <code>vendor</code> subdirectory at the root of your project and move the
tarball to that folder. Add it to your project repository.</p>
</li>
<li>
<p>Install the tarball using a package manager:</p>
</li>
</ol>
2022-05-11 21:03:03 +00:00
<div class="highlight highlight-source-shell"><pre>$ npm install --save file:vendor/xlsx-0.18.7.tgz <span class="pl-c"><span class="pl-c">#</span> npm</span>
$ pnpm install --save file:vendor/xlsx-0.18.7.tgz <span class="pl-c"><span class="pl-c">#</span> pnpm</span>
$ yarn add file:vendor/xlsx-0.18.7.tgz <span class="pl-c"><span class="pl-c">#</span> yarn</span></pre></div>
2022-04-14 17:50:18 +00:00
<p>The package will be installed and accessible as <code>xlsx</code>.</p>
2022-05-11 21:03:03 +00:00
<p><em>Usage</em></p>
<p>By default, the module supports <code>require</code> and it will automatically add support
for streams and filesystem access:</p>
2022-02-14 02:02:46 +00:00
<div class="highlight highlight-source-js"><pre><span class="pl-k">var</span> <span class="pl-c1">XLSX</span> <span class="pl-c1">=</span> <span class="pl-en">require</span><span class="pl-kos">(</span><span class="pl-s">"xlsx"</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
2022-05-11 21:03:03 +00:00
<p>The module also ships with <code>xlsx.mjs</code> for use with <code>import</code>. The <code>mjs</code> version
does not automatically load native node modules:</p>
2022-02-14 02:02:46 +00:00
<div class="highlight highlight-source-js"><pre><span class="pl-k">import</span> <span class="pl-c1">*</span> <span class="pl-k">as</span> <span class="pl-c1">XLSX</span> <span class="pl-k">from</span> <span class="pl-s">'xlsx/xlsx.mjs'</span><span class="pl-kos">;</span>
<span class="pl-c">/* load 'fs' for readFile and writeFile support */</span>
<span class="pl-k">import</span> <span class="pl-c1">*</span> <span class="pl-k">as</span> <span class="pl-s1">fs</span> <span class="pl-k">from</span> <span class="pl-s">'fs'</span><span class="pl-kos">;</span>
<span class="pl-c1">XLSX</span><span class="pl-kos">.</span><span class="pl-en">set_fs</span><span class="pl-kos">(</span><span class="pl-s1">fs</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
2022-03-25 04:01:40 +00:00
<span class="pl-c">/* load 'stream' for stream support */</span>
<span class="pl-k">import</span> <span class="pl-kos">{</span> <span class="pl-v">Readable</span> <span class="pl-kos">}</span> <span class="pl-k">from</span> <span class="pl-s">'stream'</span><span class="pl-kos">;</span>
<span class="pl-c1">XLSX</span><span class="pl-kos">.</span><span class="pl-c1">stream</span><span class="pl-kos">.</span><span class="pl-en">set_readable</span><span class="pl-kos">(</span><span class="pl-v">Readable</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
2022-02-14 02:02:46 +00:00
<span class="pl-c">/* load the codepage support library for extended support with older formats */</span>
<span class="pl-k">import</span> <span class="pl-c1">*</span> <span class="pl-k">as</span> <span class="pl-s1">cpexcel</span> <span class="pl-k">from</span> <span class="pl-s">'xlsx/dist/cpexcel.full.mjs'</span><span class="pl-kos">;</span>
<span class="pl-c1">XLSX</span><span class="pl-kos">.</span><span class="pl-en">set_cptable</span><span class="pl-kos">(</span><span class="pl-s1">cpexcel</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
2022-05-11 21:03:03 +00:00
<h4>
<a id="user-content-photoshop-and-indesign" class="anchor" href="#photoshop-and-indesign" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>Photoshop and InDesign</h4>
2022-04-14 17:50:18 +00:00
<p><code>dist/xlsx.extendscript.js</code> is an ExtendScript build for Photoshop and InDesign.
2022-05-11 21:03:03 +00:00
<a href="https://cdn.sheetjs.com/xlsx-0.18.7/package/dist/xlsx.extendscript.js" rel="nofollow">https://cdn.sheetjs.com/xlsx-0.18.7/package/dist/xlsx.extendscript.js</a> is the
current version. After downloading the script, it can be directly referenced
with a <code>#include</code> directive:</p>
2022-02-14 02:02:46 +00:00
<pre lang="extendscript"><code>#include "xlsx.extendscript.js"
</code></pre>
<h3>
<a id="user-content-usage" class="anchor" href="#usage" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>Usage</h3>
<p>Most scenarios involving spreadsheets and data can be broken into 5 parts:</p>
<ol>
<li>
<p><strong>Acquire Data</strong>: Data may be stored anywhere: local or remote files,
databases, HTML TABLE, or even generated programmatically in the web browser.</p>
</li>
<li>
<p><strong>Extract Data</strong>: For spreadsheet files, this involves parsing raw bytes to
read the cell data. For general JS data, this involves reshaping the data.</p>
</li>
<li>
<p><strong>Process Data</strong>: From generating summary statistics to cleaning data
records, this step is the heart of the problem.</p>
</li>
<li>
<p><strong>Package Data</strong>: This can involve making a new spreadsheet or serializing
with <code>JSON.stringify</code> or writing XML or simply flattening data for UI tools.</p>
</li>
<li>
<p><strong>Release Data</strong>: Spreadsheet files can be uploaded to a server or written
locally. Data can be presented to users in an HTML TABLE or data grid.</p>
</li>
</ol>
<p>A common problem involves generating a valid spreadsheet export from data stored
in an HTML table. In this example, an HTML TABLE on the page will be scraped,
a row will be added to the bottom with the date of the report, and a new file
will be generated and downloaded locally. <code>XLSX.writeFile</code> takes care of
packaging the data and attempting a local download:</p>
<div class="highlight highlight-source-js"><pre><span class="pl-c">// Acquire Data (reference to the HTML table)</span>
<span class="pl-k">var</span> <span class="pl-s1">table_elt</span> <span class="pl-c1">=</span> <span class="pl-smi">document</span><span class="pl-kos">.</span><span class="pl-en">getElementById</span><span class="pl-kos">(</span><span class="pl-s">"my-table-id"</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-c">// Extract Data (create a workbook object from the table)</span>
<span class="pl-k">var</span> <span class="pl-s1">workbook</span> <span class="pl-c1">=</span> <span class="pl-c1">XLSX</span><span class="pl-kos">.</span><span class="pl-c1">utils</span><span class="pl-kos">.</span><span class="pl-en">table_to_book</span><span class="pl-kos">(</span><span class="pl-s1">table_elt</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-c">// Process Data (add a new row)</span>
<span class="pl-k">var</span> <span class="pl-s1">ws</span> <span class="pl-c1">=</span> <span class="pl-s1">workbook</span><span class="pl-kos">.</span><span class="pl-c1">Sheets</span><span class="pl-kos">[</span><span class="pl-s">"Sheet1"</span><span class="pl-kos">]</span><span class="pl-kos">;</span>
<span class="pl-c1">XLSX</span><span class="pl-kos">.</span><span class="pl-c1">utils</span><span class="pl-kos">.</span><span class="pl-en">sheet_add_aoa</span><span class="pl-kos">(</span><span class="pl-s1">ws</span><span class="pl-kos">,</span> <span class="pl-kos">[</span><span class="pl-kos">[</span><span class="pl-s">"Created "</span><span class="pl-c1">+</span><span class="pl-k">new</span> <span class="pl-v">Date</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">toISOString</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">]</span><span class="pl-kos">]</span><span class="pl-kos">,</span> <span class="pl-kos">{</span><span class="pl-c1">origin</span>:<span class="pl-c1">-</span><span class="pl-c1">1</span><span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-c">// Package and Release Data (`writeFile` tries to write and save an XLSB file)</span>
<span class="pl-c1">XLSX</span><span class="pl-kos">.</span><span class="pl-en">writeFile</span><span class="pl-kos">(</span><span class="pl-s1">workbook</span><span class="pl-kos">,</span> <span class="pl-s">"Report.xlsb"</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<p>This library tries to simplify steps 2 and 4 with functions to extract useful
data from spreadsheet files (<code>read</code> / <code>readFile</code>) and generate new spreadsheet
files from data (<code>write</code> / <code>writeFile</code>). Additional utility functions like
<code>table_to_book</code> work with other common data sources like HTML tables.</p>
<p>This documentation and various demo projects cover a number of common scenarios
and approaches for steps 1 and 5.</p>
<p>Utility functions help with step 3.</p>
2022-03-03 09:23:56 +00:00
<p><a href="#acquiring-and-extracting-data">"Acquiring and Extracting Data"</a> describes
solutions for common data import scenarios.</p>
<p><a href="#packaging-and-releasing-data">"Packaging and Releasing Data"</a> describes
solutions for common data export scenarios.</p>
<p><a href="#packaging-and-releasing-data">"Processing Data"</a> describes solutions for
common workbook processing and manipulation scenarios.</p>
<p><a href="#utility-functions">"Utility Functions"</a> details utility functions for
translating JSON Arrays and other common JS structures into worksheet objects.</p>
2022-02-14 02:02:46 +00:00
<h3>
<a id="user-content-the-zen-of-sheetjs" class="anchor" href="#the-zen-of-sheetjs" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>The Zen of SheetJS</h3>
<p><em>Data processing should fit in any workflow</em></p>
<p>The library does not impose a separate lifecycle. It fits nicely in websites
and apps built using any framework. The plain JS data objects play nice with
Web Workers and future APIs.</p>
<p><em>JavaScript is a powerful language for data processing</em></p>
<p>The <a href="#common-spreadsheet-format">"Common Spreadsheet Format"</a> is a simple object
representation of the core concepts of a workbook. The various functions in the
library provide low-level tools for working with the object.</p>
<p>For friendly JS processing, there are utility functions for converting parts of
a worksheet to/from an Array of Arrays. The following example combines powerful
JS Array methods with a network request library to download data, select the
information we want and create a workbook file:</p>
<details>
<summary><b>Get Data from a JSON Endpoint and Generate a Workbook</b> (click to show)</summary>
<p>The goal is to generate a XLSB workbook of US President names and birthdays.</p>
<p><strong>Acquire Data</strong></p>
<p><em>Raw Data</em></p>
<p><a href="https://theunitedstates.io/congress-legislators/executive.json" rel="nofollow">https://theunitedstates.io/congress-legislators/executive.json</a> has the desired
data. For example, John Adams:</p>
<div class="highlight highlight-source-js"><pre><span class="pl-kos">{</span>
<span class="pl-s">"id"</span>: <span class="pl-kos">{</span> <span class="pl-c">/* (data omitted) */</span> <span class="pl-kos">}</span><span class="pl-kos">,</span>
<span class="pl-s">"name"</span>: <span class="pl-kos">{</span>
<span class="pl-s">"first"</span>: <span class="pl-s">"John"</span><span class="pl-kos">,</span> <span class="pl-c">// &lt;-- first name</span>
<span class="pl-s">"last"</span>: <span class="pl-s">"Adams"</span> <span class="pl-c">// &lt;-- last name</span>
<span class="pl-kos">}</span><span class="pl-kos">,</span>
<span class="pl-s">"bio"</span>: <span class="pl-kos">{</span>
<span class="pl-s">"birthday"</span>: <span class="pl-s">"1735-10-19"</span><span class="pl-kos">,</span> <span class="pl-c">// &lt;-- birthday</span>
<span class="pl-s">"gender"</span>: <span class="pl-s">"M"</span>
<span class="pl-kos">}</span><span class="pl-kos">,</span>
<span class="pl-s">"terms"</span>: <span class="pl-kos">[</span>
<span class="pl-kos">{</span> <span class="pl-s">"type"</span>: <span class="pl-s">"viceprez"</span><span class="pl-kos">,</span> <span class="pl-c">/* (other fields omitted) */</span> <span class="pl-kos">}</span><span class="pl-kos">,</span>
<span class="pl-kos">{</span> <span class="pl-s">"type"</span>: <span class="pl-s">"viceprez"</span><span class="pl-kos">,</span> <span class="pl-c">/* (other fields omitted) */</span> <span class="pl-kos">}</span><span class="pl-kos">,</span>
<span class="pl-kos">{</span> <span class="pl-s">"type"</span>: <span class="pl-s">"prez"</span><span class="pl-kos">,</span> <span class="pl-c">/* (other fields omitted) */</span> <span class="pl-kos">}</span> <span class="pl-c">// &lt;-- look for "prez"</span>
<span class="pl-kos">]</span>
<span class="pl-kos">}</span></pre></div>
<p><em>Filtering for Presidents</em></p>
<p>The dataset includes Aaron Burr, a Vice President who was never President!</p>
<p><code>Array#filter</code> creates a new array with the desired rows. A President served
at least one term with <code>type</code> set to <code>"prez"</code>. To test if a particular row has
at least one <code>"prez"</code> term, <code>Array#some</code> is another native JS function. The
complete filter would be:</p>
<div class="highlight highlight-source-js"><pre><span class="pl-k">const</span> <span class="pl-s1">prez</span> <span class="pl-c1">=</span> <span class="pl-s1">raw_data</span><span class="pl-kos">.</span><span class="pl-en">filter</span><span class="pl-kos">(</span><span class="pl-s1">row</span> <span class="pl-c1">=&gt;</span> <span class="pl-s1">row</span><span class="pl-kos">.</span><span class="pl-c1">terms</span><span class="pl-kos">.</span><span class="pl-en">some</span><span class="pl-kos">(</span><span class="pl-s1">term</span> <span class="pl-c1">=&gt;</span> <span class="pl-s1">term</span><span class="pl-kos">.</span><span class="pl-c1">type</span> <span class="pl-c1">===</span> <span class="pl-s">"prez"</span><span class="pl-kos">)</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<p><em>Lining up the data</em></p>
<p>For this example, the name will be the first name combined with the last name
(<code>row.name.first + " " + row.name.last</code>) and the birthday will be the subfield
<code>row.bio.birthday</code>. Using <code>Array#map</code>, the dataset can be massaged in one call:</p>
<div class="highlight highlight-source-js"><pre><span class="pl-k">const</span> <span class="pl-s1">rows</span> <span class="pl-c1">=</span> <span class="pl-s1">prez</span><span class="pl-kos">.</span><span class="pl-en">map</span><span class="pl-kos">(</span><span class="pl-s1">row</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">(</span><span class="pl-kos">{</span>
<span class="pl-c1">name</span>: <span class="pl-s1">row</span><span class="pl-kos">.</span><span class="pl-c1">name</span><span class="pl-kos">.</span><span class="pl-c1">first</span> <span class="pl-c1">+</span> <span class="pl-s">" "</span> <span class="pl-c1">+</span> <span class="pl-s1">row</span><span class="pl-kos">.</span><span class="pl-c1">name</span><span class="pl-kos">.</span><span class="pl-c1">last</span><span class="pl-kos">,</span>
<span class="pl-c1">birthday</span>: <span class="pl-s1">row</span><span class="pl-kos">.</span><span class="pl-c1">bio</span><span class="pl-kos">.</span><span class="pl-c1">birthday</span>
<span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<p>The result is an array of "simple" objects with no nesting:</p>
<div class="highlight highlight-source-js"><pre><span class="pl-kos">[</span>
<span class="pl-kos">{</span> <span class="pl-c1">name</span>: <span class="pl-s">"George Washington"</span><span class="pl-kos">,</span> <span class="pl-c1">birthday</span>: <span class="pl-s">"1732-02-22"</span> <span class="pl-kos">}</span><span class="pl-kos">,</span>
<span class="pl-kos">{</span> <span class="pl-c1">name</span>: <span class="pl-s">"John Adams"</span><span class="pl-kos">,</span> <span class="pl-c1">birthday</span>: <span class="pl-s">"1735-10-19"</span> <span class="pl-kos">}</span><span class="pl-kos">,</span>
<span class="pl-c">// ... one row per President</span>
<span class="pl-kos">]</span></pre></div>
<p><strong>Extract Data</strong></p>
<p>With the cleaned dataset, <code>XLSX.utils.json_to_sheet</code> generates a worksheet:</p>
<div class="highlight highlight-source-js"><pre><span class="pl-k">const</span> <span class="pl-s1">worksheet</span> <span class="pl-c1">=</span> <span class="pl-c1">XLSX</span><span class="pl-kos">.</span><span class="pl-c1">utils</span><span class="pl-kos">.</span><span class="pl-en">json_to_sheet</span><span class="pl-kos">(</span><span class="pl-s1">rows</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<p><code>XLSX.utils.book_new</code> creates a new workbook and <code>XLSX.utils.book_append_sheet</code>
appends a worksheet to the workbook. The new worksheet will be called "Dates":</p>
<div class="highlight highlight-source-js"><pre><span class="pl-k">const</span> <span class="pl-s1">workbook</span> <span class="pl-c1">=</span> <span class="pl-c1">XLSX</span><span class="pl-kos">.</span><span class="pl-c1">utils</span><span class="pl-kos">.</span><span class="pl-en">book_new</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-c1">XLSX</span><span class="pl-kos">.</span><span class="pl-c1">utils</span><span class="pl-kos">.</span><span class="pl-en">book_append_sheet</span><span class="pl-kos">(</span><span class="pl-s1">workbook</span><span class="pl-kos">,</span> <span class="pl-s1">worksheet</span><span class="pl-kos">,</span> <span class="pl-s">"Dates"</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<p><strong>Process Data</strong></p>
<p><em>Fixing headers</em></p>
<p>By default, <code>json_to_sheet</code> creates a worksheet with a header row. In this case,
the headers come from the JS object keys: "name" and "birthday".</p>
<p>The headers are in cells A1 and B1. <code>XLSX.utils.sheet_add_aoa</code> can write text
values to the existing worksheet starting at cell A1:</p>
<div class="highlight highlight-source-js"><pre><span class="pl-c1">XLSX</span><span class="pl-kos">.</span><span class="pl-c1">utils</span><span class="pl-kos">.</span><span class="pl-en">sheet_add_aoa</span><span class="pl-kos">(</span><span class="pl-s1">worksheet</span><span class="pl-kos">,</span> <span class="pl-kos">[</span><span class="pl-kos">[</span><span class="pl-s">"Name"</span><span class="pl-kos">,</span> <span class="pl-s">"Birthday"</span><span class="pl-kos">]</span><span class="pl-kos">]</span><span class="pl-kos">,</span> <span class="pl-kos">{</span> <span class="pl-c1">origin</span>: <span class="pl-s">"A1"</span> <span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<p><em>Fixing Column Widths</em></p>
<p>Some of the names are longer than the default column width. Column widths are
set by <a href="#row-and-column-properties">setting the <code>"!cols"</code> worksheet property</a>.</p>
<p>The following line sets the width of column A to approximately 10 characters:</p>
<div class="highlight highlight-source-js"><pre><span class="pl-s1">worksheet</span><span class="pl-kos">[</span><span class="pl-s">"!cols"</span><span class="pl-kos">]</span> <span class="pl-c1">=</span> <span class="pl-kos">[</span> <span class="pl-kos">{</span> <span class="pl-c1">wch</span>: <span class="pl-c1">10</span> <span class="pl-kos">}</span> <span class="pl-kos">]</span><span class="pl-kos">;</span> <span class="pl-c">// set column A width to 10 characters</span></pre></div>
<p>One <code>Array#reduce</code> call over <code>rows</code> can calculate the maximum width:</p>
<div class="highlight highlight-source-js"><pre><span class="pl-k">const</span> <span class="pl-s1">max_width</span> <span class="pl-c1">=</span> <span class="pl-s1">rows</span><span class="pl-kos">.</span><span class="pl-en">reduce</span><span class="pl-kos">(</span><span class="pl-kos">(</span><span class="pl-s1">w</span><span class="pl-kos">,</span> <span class="pl-s1">r</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-v">Math</span><span class="pl-kos">.</span><span class="pl-en">max</span><span class="pl-kos">(</span><span class="pl-s1">w</span><span class="pl-kos">,</span> <span class="pl-s1">r</span><span class="pl-kos">.</span><span class="pl-c1">name</span><span class="pl-kos">.</span><span class="pl-c1">length</span><span class="pl-kos">)</span><span class="pl-kos">,</span> <span class="pl-c1">10</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-s1">worksheet</span><span class="pl-kos">[</span><span class="pl-s">"!cols"</span><span class="pl-kos">]</span> <span class="pl-c1">=</span> <span class="pl-kos">[</span> <span class="pl-kos">{</span> <span class="pl-c1">wch</span>: <span class="pl-s1">max_width</span> <span class="pl-kos">}</span> <span class="pl-kos">]</span><span class="pl-kos">;</span></pre></div>
<p>Note: If the starting point was a file or HTML table, <code>XLSX.utils.sheet_to_json</code>
will generate an array of JS objects.</p>
<p><strong>Package and Release Data</strong></p>
<p><code>XLSX.writeFile</code> creates a spreadsheet file and tries to write it to the system.
In the browser, it will try to prompt the user to download the file. In NodeJS,
it will write to the local directory.</p>
<div class="highlight highlight-source-js"><pre><span class="pl-c1">XLSX</span><span class="pl-kos">.</span><span class="pl-en">writeFile</span><span class="pl-kos">(</span><span class="pl-s1">workbook</span><span class="pl-kos">,</span> <span class="pl-s">"Presidents.xlsx"</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<p><strong>Complete Example</strong></p>
<div class="highlight highlight-source-js"><pre><span class="pl-c">// Uncomment the next line for use in NodeJS:</span>
<span class="pl-c">// const XLSX = require("xlsx"), axios = require("axios");</span>
<span class="pl-kos">(</span><span class="pl-k">async</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
<span class="pl-c">/* fetch JSON data and parse */</span>
<span class="pl-k">const</span> <span class="pl-s1">url</span> <span class="pl-c1">=</span> <span class="pl-s">"https://theunitedstates.io/congress-legislators/executive.json"</span><span class="pl-kos">;</span>
<span class="pl-k">const</span> <span class="pl-s1">raw_data</span> <span class="pl-c1">=</span> <span class="pl-kos">(</span><span class="pl-k">await</span> <span class="pl-en">axios</span><span class="pl-kos">(</span><span class="pl-s1">url</span><span class="pl-kos">,</span> <span class="pl-kos">{</span><span class="pl-c1">responseType</span>: <span class="pl-s">"json"</span><span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-c1">data</span><span class="pl-kos">;</span>
<span class="pl-c">/* filter for the Presidents */</span>
<span class="pl-k">const</span> <span class="pl-s1">prez</span> <span class="pl-c1">=</span> <span class="pl-s1">raw_data</span><span class="pl-kos">.</span><span class="pl-en">filter</span><span class="pl-kos">(</span><span class="pl-s1">row</span> <span class="pl-c1">=&gt;</span> <span class="pl-s1">row</span><span class="pl-kos">.</span><span class="pl-c1">terms</span><span class="pl-kos">.</span><span class="pl-en">some</span><span class="pl-kos">(</span><span class="pl-s1">term</span> <span class="pl-c1">=&gt;</span> <span class="pl-s1">term</span><span class="pl-kos">.</span><span class="pl-c1">type</span> <span class="pl-c1">===</span> <span class="pl-s">"prez"</span><span class="pl-kos">)</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-c">/* flatten objects */</span>
<span class="pl-k">const</span> <span class="pl-s1">rows</span> <span class="pl-c1">=</span> <span class="pl-s1">prez</span><span class="pl-kos">.</span><span class="pl-en">map</span><span class="pl-kos">(</span><span class="pl-s1">row</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">(</span><span class="pl-kos">{</span>
<span class="pl-c1">name</span>: <span class="pl-s1">row</span><span class="pl-kos">.</span><span class="pl-c1">name</span><span class="pl-kos">.</span><span class="pl-c1">first</span> <span class="pl-c1">+</span> <span class="pl-s">" "</span> <span class="pl-c1">+</span> <span class="pl-s1">row</span><span class="pl-kos">.</span><span class="pl-c1">name</span><span class="pl-kos">.</span><span class="pl-c1">last</span><span class="pl-kos">,</span>
<span class="pl-c1">birthday</span>: <span class="pl-s1">row</span><span class="pl-kos">.</span><span class="pl-c1">bio</span><span class="pl-kos">.</span><span class="pl-c1">birthday</span>
<span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-c">/* generate worksheet and workbook */</span>
<span class="pl-k">const</span> <span class="pl-s1">worksheet</span> <span class="pl-c1">=</span> <span class="pl-c1">XLSX</span><span class="pl-kos">.</span><span class="pl-c1">utils</span><span class="pl-kos">.</span><span class="pl-en">json_to_sheet</span><span class="pl-kos">(</span><span class="pl-s1">rows</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-k">const</span> <span class="pl-s1">workbook</span> <span class="pl-c1">=</span> <span class="pl-c1">XLSX</span><span class="pl-kos">.</span><span class="pl-c1">utils</span><span class="pl-kos">.</span><span class="pl-en">book_new</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-c1">XLSX</span><span class="pl-kos">.</span><span class="pl-c1">utils</span><span class="pl-kos">.</span><span class="pl-en">book_append_sheet</span><span class="pl-kos">(</span><span class="pl-s1">workbook</span><span class="pl-kos">,</span> <span class="pl-s1">worksheet</span><span class="pl-kos">,</span> <span class="pl-s">"Dates"</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-c">/* fix headers */</span>
<span class="pl-c1">XLSX</span><span class="pl-kos">.</span><span class="pl-c1">utils</span><span class="pl-kos">.</span><span class="pl-en">sheet_add_aoa</span><span class="pl-kos">(</span><span class="pl-s1">worksheet</span><span class="pl-kos">,</span> <span class="pl-kos">[</span><span class="pl-kos">[</span><span class="pl-s">"Name"</span><span class="pl-kos">,</span> <span class="pl-s">"Birthday"</span><span class="pl-kos">]</span><span class="pl-kos">]</span><span class="pl-kos">,</span> <span class="pl-kos">{</span> <span class="pl-c1">origin</span>: <span class="pl-s">"A1"</span> <span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-c">/* calculate column width */</span>
<span class="pl-k">const</span> <span class="pl-s1">max_width</span> <span class="pl-c1">=</span> <span class="pl-s1">rows</span><span class="pl-kos">.</span><span class="pl-en">reduce</span><span class="pl-kos">(</span><span class="pl-kos">(</span><span class="pl-s1">w</span><span class="pl-kos">,</span> <span class="pl-s1">r</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-v">Math</span><span class="pl-kos">.</span><span class="pl-en">max</span><span class="pl-kos">(</span><span class="pl-s1">w</span><span class="pl-kos">,</span> <span class="pl-s1">r</span><span class="pl-kos">.</span><span class="pl-c1">name</span><span class="pl-kos">.</span><span class="pl-c1">length</span><span class="pl-kos">)</span><span class="pl-kos">,</span> <span class="pl-c1">10</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-s1">worksheet</span><span class="pl-kos">[</span><span class="pl-s">"!cols"</span><span class="pl-kos">]</span> <span class="pl-c1">=</span> <span class="pl-kos">[</span> <span class="pl-kos">{</span> <span class="pl-c1">wch</span>: <span class="pl-s1">max_width</span> <span class="pl-kos">}</span> <span class="pl-kos">]</span><span class="pl-kos">;</span>
<span class="pl-c">/* create an XLSX file and try to save to Presidents.xlsx */</span>
<span class="pl-c1">XLSX</span><span class="pl-kos">.</span><span class="pl-en">writeFile</span><span class="pl-kos">(</span><span class="pl-s1">workbook</span><span class="pl-kos">,</span> <span class="pl-s">"Presidents.xlsx"</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<p>For use in the web browser, assuming the snippet is saved to <code>snippet.js</code>,
script tags should be used to include the <code>axios</code> and <code>xlsx</code> standalone builds:</p>
2022-04-14 17:50:18 +00:00
<div class="highlight highlight-text-html-basic"><pre><span class="pl-kos">&lt;</span><span class="pl-ent">script</span> <span class="pl-c1">src</span>="<span class="pl-s">https://cdn.sheetjs.com/xlsx-latest/package/dist/xlsx.full.min.js</span>"<span class="pl-kos">&gt;</span><span class="pl-kos">&lt;/</span><span class="pl-ent">script</span><span class="pl-kos">&gt;</span>
2022-02-14 02:02:46 +00:00
<span class="pl-kos">&lt;</span><span class="pl-ent">script</span> <span class="pl-c1">src</span>="<span class="pl-s">https://unpkg.com/axios/dist/axios.min.js</span>"<span class="pl-kos">&gt;</span><span class="pl-kos">&lt;/</span><span class="pl-ent">script</span><span class="pl-kos">&gt;</span>
<span class="pl-kos">&lt;</span><span class="pl-ent">script</span> <span class="pl-c1">src</span>="<span class="pl-s">snippet.js</span>"<span class="pl-kos">&gt;</span><span class="pl-kos">&lt;/</span><span class="pl-ent">script</span><span class="pl-kos">&gt;</span></pre></div>
</details>
<p><em>File formats are implementation details</em></p>
<p>The parser covers a wide gamut of common spreadsheet file formats to ensure that
"HTML-saved-as-XLS" files work as well as actual XLS or XLSX files.</p>
<p>The writer supports a number of common output formats for broad compatibility
with the data ecosystem.</p>
<p>To the greatest extent possible, data processing code should not have to worry
about the specific file formats involved.</p>
2020-01-28 05:02:07 +00:00
<h3>
<a id="user-content-js-ecosystem-demos" class="anchor" href="#js-ecosystem-demos" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>JS Ecosystem Demos</h3>
2021-09-12 09:16:01 +00:00
<p>The <a href="https://github.com/SheetJS/SheetJS/tree/master/demos/"><code>demos</code> directory</a> includes sample projects for:</p>
2020-01-28 05:02:07 +00:00
<p><strong>Frameworks and APIs</strong></p>
<ul>
2021-09-12 09:16:01 +00:00
<li><a href="https://github.com/SheetJS/SheetJS/tree/master/demos/angular/"><code>angularjs</code></a></li>
2022-02-01 06:12:44 +00:00
<li><a href="https://github.com/SheetJS/SheetJS/tree/master/demos/angular2/"><code>angular and ionic</code></a></li>
2021-09-12 09:16:01 +00:00
<li><a href="https://github.com/SheetJS/SheetJS/tree/master/demos/knockout/"><code>knockout</code></a></li>
<li><a href="https://github.com/SheetJS/SheetJS/tree/master/demos/meteor/"><code>meteor</code></a></li>
2022-04-14 17:50:18 +00:00
<li><a href="https://github.com/SheetJS/SheetJS/tree/master/demos/react/"><code>react, react-native, next</code></a></li>
<li><a href="https://github.com/SheetJS/SheetJS/tree/master/demos/vue/"><code>vue 2.x, weex, nuxt</code></a></li>
2021-09-12 09:16:01 +00:00
<li><a href="https://github.com/SheetJS/SheetJS/tree/master/demos/xhr/"><code>XMLHttpRequest and fetch</code></a></li>
<li><a href="https://github.com/SheetJS/SheetJS/tree/master/demos/server/"><code>nodejs server</code></a></li>
<li><a href="https://github.com/SheetJS/SheetJS/tree/master/demos/database/"><code>databases and key/value stores</code></a></li>
<li><a href="https://github.com/SheetJS/SheetJS/tree/master/demos/array/"><code>typed arrays and math</code></a></li>
2020-01-28 05:02:07 +00:00
</ul>
<p><strong>Bundlers and Tooling</strong></p>
<ul>
2021-09-12 09:16:01 +00:00
<li><a href="https://github.com/SheetJS/SheetJS/tree/master/demos/browserify/"><code>browserify</code></a></li>
<li><a href="https://github.com/SheetJS/SheetJS/tree/master/demos/fusebox/"><code>fusebox</code></a></li>
<li><a href="https://github.com/SheetJS/SheetJS/tree/master/demos/parcel/"><code>parcel</code></a></li>
<li><a href="https://github.com/SheetJS/SheetJS/tree/master/demos/requirejs/"><code>requirejs</code></a></li>
<li><a href="https://github.com/SheetJS/SheetJS/tree/master/demos/rollup/"><code>rollup</code></a></li>
<li><a href="https://github.com/SheetJS/SheetJS/tree/master/demos/systemjs/"><code>systemjs</code></a></li>
<li><a href="https://github.com/SheetJS/SheetJS/tree/master/demos/typescript/"><code>typescript</code></a></li>
<li><a href="https://github.com/SheetJS/SheetJS/tree/master/demos/webpack/"><code>webpack 2.x</code></a></li>
2020-01-28 05:02:07 +00:00
</ul>
<p><strong>Platforms and Integrations</strong></p>
<ul>
2022-02-14 02:02:46 +00:00
<li><a href="https://github.com/SheetJS/SheetJS/tree/master/demos/deno/"><code>deno</code></a></li>
2021-09-12 09:16:01 +00:00
<li><a href="https://github.com/SheetJS/SheetJS/tree/master/demos/electron/"><code>electron application</code></a></li>
<li><a href="https://github.com/SheetJS/SheetJS/tree/master/demos/nwjs/"><code>nw.js application</code></a></li>
<li><a href="https://github.com/SheetJS/SheetJS/tree/master/demos/chrome/"><code>Chrome / Chromium extensions</code></a></li>
2022-02-14 02:02:46 +00:00
<li><a href="https://github.com/SheetJS/SheetJS/tree/master/demos/google-sheet/"><code>Download a Google Sheet locally</code></a