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 >
/*!
* GitHub Light v0.4.1
* Copyright (c) 2012 - 2017 GitHub, Inc.
* Licensed under MIT (https://github.com/primer/github-syntax-theme-generator/blob/master/LICENSE)
*/.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
* 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)
*/.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 */
/*!
* Primer-marketing
* http://primer.github.io
*
* Released under MIT license. Copyright (c) 2018 GitHub Inc.
2021-08-27 00:16:16 +00:00
*/.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
2020-01-28 05:02:07 +00:00
/*# sourceMappingURL=site-73680c8bae9d90e48e18affb463ea2cd.css.map */
/*!
* 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 */
< / 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 = "" >
< 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-08-27 00:16:16 +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 = "http://sheetjs.com" rel = "nofollow" > SheetJS< / a >
2020-01-28 05:02:07 +00:00
< / h1 >
< p > Parser and writer for various spreadsheet formats. Pure-JS cleanroom
implementation from official specifications, related documents, and test files.
Emphasis on parsing and writing robustness, cross-format feature compatibility
with a unified JS representation, and ES3/ES5 browser compatibility back to IE6.< / p >
< p > This is the community version. We also offer a pro version with performance
enhancements, additional features like styling, and dedicated support.< / p >
< p > < a href = "http://sheetjs.com/pro" rel = "nofollow" > < strong > Pro Version< / strong > < / a > < / p >
< p > < a href = "http://sheetjs.com/support" rel = "nofollow" > < strong > Commercial Support< / strong > < / a > < / p >
< p > < a href = "http://docs.sheetjs.com/" rel = "nofollow" > < strong > Rendered Documentation< / strong > < / a > < / p >
< p > < a href = "http://sheetjs.com/demos" rel = "nofollow" > < strong > In-Browser Demos< / strong > < / a > < / p >
< p > < a href = "http://git.io/xlsx" rel = "nofollow" > < strong > Source Code< / strong > < / a > < / p >
< p > < a href = "https://github.com/sheetjs/sheetjs/issues" > < strong > Issues and Bug Reports< / strong > < / a > < / p >
< p > < a href = "#file-formats" > < strong > File format support for known spreadsheet data formats:< / strong > < / a > < / p >
< details >
< summary > < b > Graph of supported formats< / b > (click to show)< / summary >
< 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 >
< / details >
< p > < a href = "http://oss.sheetjs.com/sheetjs/tests/" rel = "nofollow" > < strong > Browser Test< / strong > < / a > < / p >
2021-08-27 00:16:16 +00:00
< 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 > < a href = "https://semaphoreci.com/sheetjs/sheetjs" rel = "nofollow" > < img src = "https://camo.githubusercontent.com/fdf58475670abd49ba7dfd07743cc1115128591b1126c4c792feb332ba089d7e/68747470733a2f2f73656d6170686f726563692e636f6d2f6170692f76312f73686565746a732f73686565746a732f6272616e636865732f6d61737465722f736869656c64735f62616467652e737667" alt = "Build Status" data-canonical-src = "https://semaphoreci.com/api/v1/sheetjs/sheetjs/branches/master/shields_badge.svg" style = "max-width:100%;" > < / a >
< a href = "https://coveralls.io/r/SheetJS/sheetjs?branch=master" rel = "nofollow" > < img src = "https://camo.githubusercontent.com/a325eeccdc989a4c7b1d7abc6883644e385633ed3519441150e9b36ea9263d1b/687474703a2f2f696d672e736869656c64732e696f2f636f766572616c6c732f53686565744a532f73686565746a732f6d61737465722e737667" alt = "Coverage Status" data-canonical-src = "http://img.shields.io/coveralls/SheetJS/sheetjs/master.svg" style = "max-width:100%;" > < / a >
< a href = "https://david-dm.org/sheetjs/sheetjs" rel = "nofollow" > < img src = "https://camo.githubusercontent.com/4e021c513c3dfd1b88c144e855b6e3815d2bc9c93021e39e3fba1aa2d4a11e67/68747470733a2f2f64617669642d646d2e6f72672f73686565746a732f73686565746a732f7374617475732e737667" alt = "Dependencies Status" data-canonical-src = "https://david-dm.org/sheetjs/sheetjs/status.svg" style = "max-width:100%;" > < / a >
< a href = "https://npmjs.org/package/xlsx" rel = "nofollow" > < img src = "https://camo.githubusercontent.com/afba95100349a4110c4408973a3c9c3557762e14fdc9088e7ea6dd3746d2139b/68747470733a2f2f696d672e736869656c64732e696f2f6e706d2f64742f786c73782e737667" alt = "npm Downloads" data-canonical-src = "https://img.shields.io/npm/dt/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 >
2020-01-28 05:02:07 +00:00
< 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 >
< a href = "#installation" > Installation< / a >
< ul >
< li > < a href = "#js-ecosystem-demos" > JS Ecosystem Demos< / a > < / li >
< li > < a href = "#optional-modules" > Optional Modules< / a > < / li >
< li > < a href = "#ecmascript-5-compatibility" > ECMAScript 5 Compatibility< / a > < / li >
< / ul >
< / li >
< li > < a href = "#philosophy" > Philosophy< / a > < / li >
< li >
< a href = "#parsing-workbooks" > Parsing Workbooks< / a >
< ul >
< li > < a href = "#parsing-examples" > Parsing Examples< / a > < / li >
< li > < a href = "#streaming-read" > Streaming Read< / a > < / li >
< / ul >
< / li >
< li >
< a href = "#working-with-the-workbook" > Working with the Workbook< / a >
< ul >
< li > < a href = "#parsing-and-writing-examples" > Parsing and Writing Examples< / a > < / li >
< / ul >
< / li >
< li >
< a href = "#writing-workbooks" > Writing Workbooks< / a >
< ul >
< li > < a href = "#writing-examples" > Writing Examples< / a > < / li >
< li > < a href = "#streaming-write" > Streaming Write< / a > < / li >
< / 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 >
< li > < a href = "#column-properties" > Column Properties< / a > < / li >
< li > < a href = "#row-properties" > Row Properties< / a > < / li >
< 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 >
< li >
< a href = "#file-formats" > File Formats< / a >
< ul >
< li > < a href = "#excel-2007-xml-xlsxxlsm" > Excel 2007+ XML (XLSX/XLSM)< / a > < / li >
< li > < a href = "#excel-20-95-biff2biff3biff4biff5" > Excel 2.0-95 (BIFF2/BIFF3/BIFF4/BIFF5)< / a > < / li >
< li > < a href = "#excel-97-2004-binary-biff8" > Excel 97-2004 Binary (BIFF8)< / a > < / li >
< li > < a href = "#excel-2003-2004-spreadsheetml" > Excel 2003-2004 (SpreadsheetML)< / a > < / li >
< li > < a href = "#excel-2007-binary-xlsb-biff12" > Excel 2007+ Binary (XLSB, BIFF12)< / a > < / li >
< li > < a href = "#delimiter-separated-values-csvtxt" > Delimiter-Separated Values (CSV/TXT)< / a > < / li >
< li >
< a href = "#other-workbook-formats" > Other Workbook Formats< / a >
< ul >
< li > < a href = "#lotus-1-2-3-wkswk1wk2wk3wk4123" > Lotus 1-2-3 (WKS/WK1/WK2/WK3/WK4/123)< / a > < / li >
< li > < a href = "#quattro-pro-wq1wq2wb1wb2wb3qpw" > Quattro Pro (WQ1/WQ2/WB1/WB2/WB3/QPW)< / a > < / li >
< li > < a href = "#opendocument-spreadsheet-odsfods" > OpenDocument Spreadsheet (ODS/FODS)< / a > < / li >
< li > < a href = "#uniform-office-spreadsheet-uos12" > Uniform Office Spreadsheet (UOS1/2)< / a > < / li >
< / ul >
< / li >
< li >
< a href = "#other-single-worksheet-formats" > Other Single-Worksheet Formats< / a >
< ul >
< li > < a href = "#dbase-and-visual-foxpro-dbf" > dBASE and Visual FoxPro (DBF)< / a > < / li >
< li > < a href = "#symbolic-link-sylk" > Symbolic Link (SYLK)< / a > < / li >
< li > < a href = "#lotus-formatted-text-prn" > Lotus Formatted Text (PRN)< / a > < / li >
< li > < a href = "#data-interchange-format-dif" > Data Interchange Format (DIF)< / a > < / li >
< li > < a href = "#html" > HTML< / a > < / li >
< li > < a href = "#rich-text-format-rtf" > Rich Text Format (RTF)< / a > < / li >
< li > < a href = "#ethercalc-record-format-eth" > Ethercalc Record Format (ETH)< / a > < / li >
< / ul >
< / li >
< / ul >
< / li >
< 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 >
< a id = "user-content-installation" class = "anchor" href = "#installation" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > Installation< / h2 >
< p > In the browser, just add a script tag:< / p >
2021-08-27 00:16:16 +00:00
< div class = "highlight highlight-text-html-basic" > < pre > < span class = "pl-kos" > < < / 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" > dist/xlsx.full.min.js< / span > "< span class = "pl-kos" > > < / span > < span class = "pl-kos" > < /< / span > < span class = "pl-ent" > script< / span > < span class = "pl-kos" > > < / span > < / pre > < / div >
2020-01-28 05:02:07 +00:00
< details >
< summary > < b > CDN Availability< / b > (click to show)< / summary >
< table >
< thead >
< tr >
< th align = "right" > CDN< / th >
< th align = "left" > URL< / th >
< / tr >
< / thead >
< tbody >
< tr >
< td align = "right" > < code > unpkg< / code > < / td >
< td align = "left" > < a href = "https://unpkg.com/xlsx/" rel = "nofollow" > https://unpkg.com/xlsx/< / a > < / td >
< / tr >
< tr >
< td align = "right" > < code > jsDelivr< / code > < / td >
< td align = "left" > < a href = "https://jsdelivr.com/package/npm/xlsx" rel = "nofollow" > https://jsdelivr.com/package/npm/xlsx< / a > < / td >
< / tr >
< tr >
< td align = "right" > < code > CDNjs< / code > < / td >
< td align = "left" > < a href = "http://cdnjs.com/libraries/xlsx" rel = "nofollow" > http://cdnjs.com/libraries/xlsx< / a > < / td >
< / tr >
< tr >
< td align = "right" > < code > packd< / code > < / td >
< td align = "left" > < a href = "https://bundle.run/xlsx@latest?name=XLSX" rel = "nofollow" > https://bundle.run/xlsx@latest?name=XLSX< / a > < / td >
< / tr >
< / tbody >
< / table >
< p > < code > unpkg< / code > makes the latest version available at:< / p >
2021-08-27 00:16:16 +00:00
< div class = "highlight highlight-text-html-basic" > < pre > < span class = "pl-kos" > < < / span > < span class = "pl-ent" > script< / span > < span class = "pl-c1" > src< / span > ="< span class = "pl-s" > https://unpkg.com/xlsx/dist/xlsx.full.min.js< / span > "< span class = "pl-kos" > > < / span > < span class = "pl-kos" > < /< / span > < span class = "pl-ent" > script< / span > < span class = "pl-kos" > > < / span > < / pre > < / div >
2020-01-28 05:02:07 +00:00
< / details >
< p > With < a href = "https://www.npmjs.org/package/xlsx" rel = "nofollow" > npm< / a > :< / p >
< div class = "highlight highlight-source-shell" > < pre > $ npm install xlsx< / pre > < / div >
< p > With < a href = "http://bower.io/search/?q=js-xlsx" rel = "nofollow" > bower< / a > :< / p >
< div class = "highlight highlight-source-shell" > < pre > $ bower install js-xlsx< / pre > < / div >
< 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 >
< p > The < a href = "demos/" > < code > demos< / code > directory< / a > includes sample projects for:< / p >
< p > < strong > Frameworks and APIs< / strong > < / p >
< ul >
< li > < a href = "demos/angular/" > < code > angularjs< / code > < / a > < / li >
< li > < a href = "demos/angular2/" > < code > angular 2 / 4 / 5 / 6 and ionic< / code > < / a > < / li >
< li > < a href = "demos/knockout/" > < code > knockout< / code > < / a > < / li >
< li > < a href = "demos/meteor/" > < code > meteor< / code > < / a > < / li >
< li > < a href = "demos/react/" > < code > react and react-native< / code > < / a > < / li >
< li > < a href = "demos/vue/" > < code > vue 2.x and weex< / code > < / a > < / li >
< li > < a href = "demos/xhr/" > < code > XMLHttpRequest and fetch< / code > < / a > < / li >
< li > < a href = "demos/server/" > < code > nodejs server< / code > < / a > < / li >
< li > < a href = "demos/database/" > < code > databases and key/value stores< / code > < / a > < / li >
< li > < a href = "demos/array/" > < code > typed arrays and math< / code > < / a > < / li >
< / ul >
< p > < strong > Bundlers and Tooling< / strong > < / p >
< ul >
< li > < a href = "demos/browserify/" > < code > browserify< / code > < / a > < / li >
< li > < a href = "demos/fusebox/" > < code > fusebox< / code > < / a > < / li >
< li > < a href = "demos/parcel/" > < code > parcel< / code > < / a > < / li >
< li > < a href = "demos/requirejs/" > < code > requirejs< / code > < / a > < / li >
< li > < a href = "demos/rollup/" > < code > rollup< / code > < / a > < / li >
< li > < a href = "demos/systemjs/" > < code > systemjs< / code > < / a > < / li >
< li > < a href = "demos/typescript/" > < code > typescript< / code > < / a > < / li >
< li > < a href = "demos/webpack/" > < code > webpack 2.x< / code > < / a > < / li >
< / ul >
< p > < strong > Platforms and Integrations< / strong > < / p >
< ul >
< li > < a href = "demos/electron/" > < code > electron application< / code > < / a > < / li >
< li > < a href = "demos/nwjs/" > < code > nw.js application< / code > < / a > < / li >
< li > < a href = "demos/chrome/" > < code > Chrome / Chromium extensions< / code > < / a > < / li >
< li > < a href = "demos/extendscript/" > < code > Adobe ExtendScript< / code > < / a > < / li >
< li > < a href = "demos/headless/" > < code > Headless Browsers< / code > < / a > < / li >
< li > < a href = "demos/datagrid/" > < code > canvas-datagrid< / code > < / a > < / li >
2021-08-27 00:16:16 +00:00
< li > < a href = "demos/xspreadsheet/" > < code > x-spreadsheet< / code > < / a > < / li >
2020-01-28 05:02:07 +00:00
< li > < a href = "demos/altjs/" > < code > Swift JSC and other engines< / code > < / a > < / li >
< li > < a href = "demos/function/" > < code > "serverless" functions< / code > < / a > < / li >
< li > < a href = "demos/oldie/" > < code > internet explorer< / code > < / a > < / li >
< / ul >
< p > Other examples are included in the < a href = "demos/showcase/" > showcase< / a > .< / p >
< h3 >
< a id = "user-content-optional-modules" class = "anchor" href = "#optional-modules" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > Optional Modules< / h3 >
< details >
< summary > < b > Optional features< / b > (click to show)< / summary >
< p > The node version automatically requires modules for additional features. Some
of these modules are rather large in size and are only needed in special
circumstances, so they do not ship with the core. For browser use, they must
be included directly:< / p >
2021-08-27 00:16:16 +00:00
< div class = "highlight highlight-text-html-basic" > < pre > < span class = "pl-c" > < !-- international support from js-codepage --> < / span >
< span class = "pl-kos" > < < / span > < span class = "pl-ent" > script< / span > < span class = "pl-c1" > src< / span > ="< span class = "pl-s" > dist/cpexcel.js< / span > "< span class = "pl-kos" > > < / span > < span class = "pl-kos" > < /< / span > < span class = "pl-ent" > script< / span > < span class = "pl-kos" > > < / span > < / pre > < / div >
2020-01-28 05:02:07 +00:00
< p > An appropriate version for each dependency is included in the dist/ directory.< / p >
< p > The complete single-file version is generated at < code > dist/xlsx.full.min.js< / code > < / p >
< p > A slimmer build with XLSX / HTML support is generated at < code > dist/xlsx.mini.min.js< / code > < / p >
< p > Webpack and Browserify builds include optional modules by default. Webpack can
be configured to remove support with < code > resolve.alias< / code > :< / p >
2021-08-27 00:16:16 +00:00
< div class = "highlight highlight-source-js" > < pre > < span class = "pl-c" > /* uncomment the lines below to remove support */< / span >
resolve: < span class = "pl-kos" > {< / span >
< span class = "pl-c1" > alias< / span > : < span class = "pl-kos" > {< / span > < span class = "pl-s" > "./dist/cpexcel.js"< / span > : < span class = "pl-s" > ""< / span > < span class = "pl-kos" > }< / span > < span class = "pl-c" > // < -- omit international support< / span >
< span class = "pl-kos" > }< / span > < / pre > < / div >
2020-01-28 05:02:07 +00:00
< / details >
< h3 >
< a id = "user-content-ecmascript-5-compatibility" class = "anchor" href = "#ecmascript-5-compatibility" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > ECMAScript 5 Compatibility< / h3 >
< p > Since the library uses functions like < code > Array#forEach< / code > , older browsers require
2021-08-27 00:16:16 +00:00
< a href = "http://oss.sheetjs.com/sheetjs/shim.js" rel = "nofollow" > shims to provide missing functions< / a > .< / p >
2020-01-28 05:02:07 +00:00
< p > To use the shim, add the shim before the script tag that loads < code > xlsx.js< / code > :< / p >
2021-08-27 00:16:16 +00:00
< div class = "highlight highlight-text-html-basic" > < pre > < span class = "pl-c" > < !-- add the shim first --> < / span >
< span class = "pl-kos" > < < / 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" > > < / span > < span class = "pl-kos" > < /< / span > < span class = "pl-ent" > script< / span > < span class = "pl-kos" > > < / span >
< span class = "pl-c" > < !-- after the shim is referenced, add the library --> < / span >
< span class = "pl-kos" > < < / 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" > > < / span > < span class = "pl-kos" > < /< / span > < span class = "pl-ent" > script< / span > < span class = "pl-kos" > > < / span > < / pre > < / div >
2020-01-28 05:02:07 +00:00
< 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 >
< h2 >
< a id = "user-content-philosophy" class = "anchor" href = "#philosophy" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > Philosophy< / h2 >
< details >
< summary > < b > Philosophy< / b > (click to show)< / summary >
< p > Prior to SheetJS, APIs for processing spreadsheet files were format-specific.
Third-party libraries either supported one format, or they involved a separate
set of classes for each supported file type. Even though XLSB was introduced in
Excel 2007, nothing outside of SheetJS or Excel supported the format.< / p >
2021-08-27 00:16:16 +00:00
< p > To promote a format-agnostic view, SheetJS starts from a pure-JS representation
2020-01-28 05:02:07 +00:00
that we call the < a href = "#common-spreadsheet-format" > "Common Spreadsheet Format"< / a > .
Emphasizing a uniform object representation enables new features like format
2021-08-27 00:16:16 +00:00
conversion (reading an XLSX template and saving as XLS) and circumvents the mess
of classes. By abstracting the complexities of the various formats, tools
2020-01-28 05:02:07 +00:00
need not worry about the specific file type!< / p >
< p > A simple object representation combined with careful coding practices enables
use cases in older browsers and in alternative environments like ExtendScript
and Web Workers. It is always tempting to use the latest and greatest features,
but they tend to require the latest versions of browsers, limiting usability.< / p >
< p > Utility functions capture common use cases like generating JS objects or HTML.
Most simple operations should only require a few lines of code. More complex
operations generally should be straightforward to implement.< / p >
< p > Excel pushes the XLSX format as default starting in Excel 2007. However, there
are other formats with more appealing properties. For example, the XLSB format
is spiritually similar to XLSX but files often tend up taking less than half the
space and open much faster! Even though an XLSX writer is available, other
format writers are available so users can take advantage of the unique
characteristics of each format.< / p >
< p > The primary focus of the Community Edition is correct data interchange, focused
on extracting data from any compatible data representation and exporting data in
various formats suitable for any third party interface.< / p >
< / details >
< h2 >
< a id = "user-content-parsing-workbooks" class = "anchor" href = "#parsing-workbooks" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > Parsing Workbooks< / h2 >
< p > For parsing, the first step is to read the file. This involves acquiring the
data and feeding it into the library. Here are a few common scenarios:< / p >
< details >
< summary > < b > nodejs read a file< / b > (click to show)< / summary >
< p > < code > readFile< / code > is only available in server environments. Browsers have no API for
reading arbitrary files given a path, so another strategy must be used.< / p >
2021-08-27 00:16:16 +00:00
< div class = "highlight highlight-source-js" > < pre > < span class = "pl-k" > if< / span > < span class = "pl-kos" > (< / span > < span class = "pl-k" > typeof< / span > < span class = "pl-en" > require< / span > < span class = "pl-c1" > !==< / span > < span class = "pl-s" > 'undefined'< / span > < span class = "pl-kos" > )< / 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 >
< 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-en" > readFile< / span > < span class = "pl-kos" > (< / span > < span class = "pl-s" > 'test.xlsx'< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ;< / span >
< span class = "pl-c" > /* DO SOMETHING WITH workbook HERE */< / span > < / pre > < / div >
2020-01-28 05:02:07 +00:00
< / details >
< details >
< summary > < b > Photoshop ExtendScript read a file< / b > (click to show)< / summary >
< p > < code > readFile< / code > wraps the < code > File< / code > logic in Photoshop and other ExtendScript targets.
The specified path should be an absolute path:< / p >
2021-08-27 00:16:16 +00:00
< div class = "highlight highlight-source-js" > < pre > #< span class = "pl-s1" > include< / span > < span class = "pl-s" > "xlsx.extendscript.js"< / span >
< span class = "pl-c" > /* Read test.xlsx from the Documents folder */< / 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-en" > readFile< / span > < span class = "pl-kos" > (< / span > < span class = "pl-v" > Folder< / span > < span class = "pl-kos" > .< / span > < span class = "pl-c1" > myDocuments< / span > < span class = "pl-c1" > +< / span > < span class = "pl-s" > '/'< / span > < span class = "pl-c1" > +< / span > < span class = "pl-s" > 'test.xlsx'< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ;< / span >
< span class = "pl-c" > /* DO SOMETHING WITH workbook HERE */< / span > < / pre > < / div >
2020-01-28 05:02:07 +00:00
< p > The < a href = "demos/extendscript/" > < code > extendscript< / code > demo< / a > includes a more complex example.< / p >
< / details >
< details >
< summary > < b > Browser read TABLE element from page< / b > (click to show)< / summary >
< p > The < code > table_to_book< / code > and < code > table_to_sheet< / code > utility functions take a DOM TABLE
element and iterate through the child nodes.< / p >
2021-08-27 00:16:16 +00:00
< div class = "highlight highlight-source-js" > < pre > < 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-smi" > document< / span > < span class = "pl-kos" > .< / span > < span class = "pl-en" > getElementById< / span > < span class = "pl-kos" > (< / span > < span class = "pl-s" > 'tableau'< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ;< / span >
< span class = "pl-c" > /* DO SOMETHING WITH workbook HERE */< / span > < / pre > < / div >
2020-01-28 05:02:07 +00:00
< p > Multiple tables on a web page can be converted to individual worksheets:< / p >
2021-08-27 00:16:16 +00:00
< div class = "highlight highlight-source-js" > < pre > < span class = "pl-c" > /* create new workbook */< / 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" > book_new< / span > < span class = "pl-kos" > (< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ;< / span >
2020-01-28 05:02:07 +00:00
2021-08-27 00:16:16 +00:00
< span class = "pl-c" > /* convert table 'table1' to worksheet named "Sheet1" */< / span >
< span class = "pl-k" > var< / span > < span class = "pl-s1" > ws1< / 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_sheet< / span > < span class = "pl-kos" > (< / 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" > 'table1'< / 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" > ws1< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > "Sheet1"< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ;< / span >
2020-01-28 05:02:07 +00:00
2021-08-27 00:16:16 +00:00
< span class = "pl-c" > /* convert table 'table2' to worksheet named "Sheet2" */< / span >
< span class = "pl-k" > var< / span > < span class = "pl-s1" > ws2< / 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_sheet< / span > < span class = "pl-kos" > (< / 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" > 'table2'< / 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" > ws2< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > "Sheet2"< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ;< / span >
2020-01-28 05:02:07 +00:00
2021-08-27 00:16:16 +00:00
< span class = "pl-c" > /* workbook now has 2 worksheets */< / span > < / pre > < / div >
2020-01-28 05:02:07 +00:00
< p > Alternatively, the HTML code can be extracted and parsed:< / p >
2021-08-27 00:16:16 +00:00
< div class = "highlight highlight-source-js" > < pre > < span class = "pl-k" > var< / span > < span class = "pl-s1" > htmlstr< / 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" > 'tableau'< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > .< / span > < span class = "pl-c1" > outerHTML< / span > < span class = "pl-kos" > ;< / 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-en" > read< / span > < span class = "pl-kos" > (< / span > < span class = "pl-s1" > htmlstr< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-kos" > {< / span > < span class = "pl-c1" > type< / span > :< span class = "pl-s" > 'string'< / span > < span class = "pl-kos" > }< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ;< / span > < / pre > < / div >
2020-01-28 05:02:07 +00:00
< / details >
< details >
< summary > < b > Browser download file (ajax)< / b > (click to show)< / summary >
< p > Note: for a more complete example that works in older browsers, check the demo
2021-08-27 00:16:16 +00:00
at < a href = "http://oss.sheetjs.com/sheetjs/ajax.html" rel = "nofollow" > http://oss.sheetjs.com/sheetjs/ajax.html< / a > . The < a href = "demos/xhr/" > < code > xhr< / code > demo< / a >
2020-01-28 05:02:07 +00:00
includes more examples with < code > XMLHttpRequest< / code > and < code > fetch< / code > .< / p >
2021-08-27 00:16:16 +00:00
< div class = "highlight highlight-source-js" > < pre > < span class = "pl-k" > var< / span > < span class = "pl-s1" > url< / span > < span class = "pl-c1" > =< / span > < span class = "pl-s" > "http://oss.sheetjs.com/test_files/formula_stress_test.xlsx"< / span > < span class = "pl-kos" > ;< / span >
2020-01-28 05:02:07 +00:00
2021-08-27 00:16:16 +00:00
< span class = "pl-c" > /* set up async GET request */< / span >
< span class = "pl-k" > var< / span > < span class = "pl-s1" > req< / span > < span class = "pl-c1" > =< / span > < span class = "pl-k" > new< / span > < span class = "pl-v" > XMLHttpRequest< / span > < span class = "pl-kos" > (< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ;< / span >
< span class = "pl-s1" > req< / span > < span class = "pl-kos" > .< / span > < span class = "pl-en" > open< / span > < span class = "pl-kos" > (< / span > < span class = "pl-s" > "GET"< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s1" > url< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > true< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ;< / span >
< span class = "pl-s1" > req< / span > < span class = "pl-kos" > .< / span > < span class = "pl-c1" > responseType< / span > < span class = "pl-c1" > =< / span > < span class = "pl-s" > "arraybuffer"< / span > < span class = "pl-kos" > ;< / span >
2020-01-28 05:02:07 +00:00
2021-08-27 00:16:16 +00:00
< span class = "pl-s1" > req< / span > < span class = "pl-kos" > .< / span > < span class = "pl-en" > onload< / span > < span class = "pl-c1" > =< / span > < span class = "pl-k" > function< / span > < span class = "pl-kos" > (< / span > < span class = "pl-s1" > e< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > {< / span >
< span class = "pl-k" > var< / span > < span class = "pl-s1" > data< / span > < span class = "pl-c1" > =< / span > < span class = "pl-k" > new< / span > < span class = "pl-v" > Uint8Array< / span > < span class = "pl-kos" > (< / span > < span class = "pl-s1" > req< / span > < span class = "pl-kos" > .< / span > < span class = "pl-c1" > response< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ;< / 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-en" > read< / span > < span class = "pl-kos" > (< / span > < span class = "pl-s1" > data< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-kos" > {< / span > < span class = "pl-c1" > type< / span > :< span class = "pl-s" > "array"< / span > < span class = "pl-kos" > }< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ;< / span >
2020-01-28 05:02:07 +00:00
2021-08-27 00:16:16 +00:00
< span class = "pl-c" > /* DO SOMETHING WITH workbook HERE */< / span >
< span class = "pl-kos" > }< / span >
2020-01-28 05:02:07 +00:00
2021-08-27 00:16:16 +00:00
< span class = "pl-s1" > req< / span > < span class = "pl-kos" > .< / span > < span class = "pl-en" > send< / span > < span class = "pl-kos" > (< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ;< / span > < / pre > < / div >
2020-01-28 05:02:07 +00:00
< / details >
< details >
< summary > < b > Browser drag-and-drop< / b > (click to show)< / summary >
< p > Drag-and-drop uses the HTML5 < code > FileReader< / code > API.< / p >
2021-08-27 00:16:16 +00:00
< div class = "highlight highlight-source-js" > < pre > < span class = "pl-k" > function< / span > < span class = "pl-en" > handleDrop< / span > < span class = "pl-kos" > (< / span > < span class = "pl-s1" > e< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > {< / span >
< span class = "pl-s1" > e< / span > < span class = "pl-kos" > .< / span > < span class = "pl-en" > stopPropagation< / span > < span class = "pl-kos" > (< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ;< / span > < span class = "pl-s1" > e< / span > < span class = "pl-kos" > .< / span > < span class = "pl-en" > preventDefault< / span > < span class = "pl-kos" > (< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ;< / span >
< span class = "pl-k" > var< / span > < span class = "pl-s1" > files< / span > < span class = "pl-c1" > =< / span > < span class = "pl-s1" > e< / span > < span class = "pl-kos" > .< / span > < span class = "pl-c1" > dataTransfer< / span > < span class = "pl-kos" > .< / span > < span class = "pl-c1" > files< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s1" > f< / span > < span class = "pl-c1" > =< / span > < span class = "pl-s1" > files< / span > < span class = "pl-kos" > [< / span > < span class = "pl-c1" > 0< / span > < span class = "pl-kos" > ]< / span > < span class = "pl-kos" > ;< / span >
< span class = "pl-k" > var< / span > < span class = "pl-s1" > reader< / span > < span class = "pl-c1" > =< / span > < span class = "pl-k" > new< / span > < span class = "pl-v" > FileReader< / span > < span class = "pl-kos" > (< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ;< / span >
< span class = "pl-s1" > reader< / span > < span class = "pl-kos" > .< / span > < span class = "pl-en" > onload< / span > < span class = "pl-c1" > =< / span > < span class = "pl-k" > function< / span > < span class = "pl-kos" > (< / span > < span class = "pl-s1" > e< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > {< / span >
< span class = "pl-k" > var< / span > < span class = "pl-s1" > data< / span > < span class = "pl-c1" > =< / span > < span class = "pl-k" > new< / span > < span class = "pl-v" > Uint8Array< / span > < span class = "pl-kos" > (< / span > < span class = "pl-s1" > e< / span > < span class = "pl-kos" > .< / span > < span class = "pl-c1" > target< / span > < span class = "pl-kos" > .< / span > < span class = "pl-c1" > result< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ;< / 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-en" > read< / span > < span class = "pl-kos" > (< / span > < span class = "pl-s1" > data< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-kos" > {< / span > < span class = "pl-c1" > type< / span > : < span class = "pl-s" > 'array'< / span > < span class = "pl-kos" > }< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ;< / span >
2020-01-28 05:02:07 +00:00
2021-08-27 00:16:16 +00:00
< span class = "pl-c" > /* DO SOMETHING WITH workbook HERE */< / span >
< span class = "pl-kos" > }< / span > < span class = "pl-kos" > ;< / span >
< span class = "pl-s1" > reader< / span > < span class = "pl-kos" > .< / span > < span class = "pl-en" > readAsArrayBuffer< / span > < span class = "pl-kos" > (< / span > < span class = "pl-s1" > f< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ;< / span >
< span class = "pl-kos" > }< / span >
< span class = "pl-s1" > drop_dom_element< / span > < span class = "pl-kos" > .< / span > < span class = "pl-en" > addEventListener< / span > < span class = "pl-kos" > (< / span > < span class = "pl-s" > 'drop'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s1" > handleDrop< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > false< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ;< / span > < / pre > < / div >
2020-01-28 05:02:07 +00:00
< / details >
< details >
< summary > < b > Browser file upload form element< / b > (click to show)< / summary >
< p > Data from file input elements can be processed using the same < code > FileReader< / code > API
as in the drag-and-drop example:< / p >
2021-08-27 00:16:16 +00:00
< div class = "highlight highlight-source-js" > < pre > < span class = "pl-k" > function< / span > < span class = "pl-en" > handleFile< / span > < span class = "pl-kos" > (< / span > < span class = "pl-s1" > e< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > {< / span >
< span class = "pl-k" > var< / span > < span class = "pl-s1" > files< / span > < span class = "pl-c1" > =< / span > < span class = "pl-s1" > e< / span > < span class = "pl-kos" > .< / span > < span class = "pl-c1" > target< / span > < span class = "pl-kos" > .< / span > < span class = "pl-c1" > files< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s1" > f< / span > < span class = "pl-c1" > =< / span > < span class = "pl-s1" > files< / span > < span class = "pl-kos" > [< / span > < span class = "pl-c1" > 0< / span > < span class = "pl-kos" > ]< / span > < span class = "pl-kos" > ;< / span >
< span class = "pl-k" > var< / span > < span class = "pl-s1" > reader< / span > < span class = "pl-c1" > =< / span > < span class = "pl-k" > new< / span > < span class = "pl-v" > FileReader< / span > < span class = "pl-kos" > (< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ;< / span >
< span class = "pl-s1" > reader< / span > < span class = "pl-kos" > .< / span > < span class = "pl-en" > onload< / span > < span class = "pl-c1" > =< / span > < span class = "pl-k" > function< / span > < span class = "pl-kos" > (< / span > < span class = "pl-s1" > e< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > {< / span >
< span class = "pl-k" > var< / span > < span class = "pl-s1" > data< / span > < span class = "pl-c1" > =< / span > < span class = "pl-k" > new< / span > < span class = "pl-v" > Uint8Array< / span > < span class = "pl-kos" > (< / span > < span class = "pl-s1" > e< / span > < span class = "pl-kos" > .< / span > < span class = "pl-c1" > target< / span > < span class = "pl-kos" > .< / span > < span class = "pl-c1" > result< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ;< / 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-en" > read< / span > < span class = "pl-kos" > (< / span > < span class = "pl-s1" > data< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-kos" > {< / span > < span class = "pl-c1" > type< / span > : < span class = "pl-s" > 'array'< / span > < span class = "pl-kos" > }< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ;< / span >
2020-01-28 05:02:07 +00:00
2021-08-27 00:16:16 +00:00
< span class = "pl-c" > /* DO SOMETHING WITH workbook HERE */< / span >
< span class = "pl-kos" > }< / span > < span class = "pl-kos" > ;< / span >
< span class = "pl-s1" > reader< / span > < span class = "pl-kos" > .< / span > < span class = "pl-en" > readAsArrayBuffer< / span > < span class = "pl-kos" > (< / span > < span class = "pl-s1" > f< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ;< / span >
< span class = "pl-kos" > }< / span >
< span class = "pl-s1" > input_dom_element< / span > < span class = "pl-kos" > .< / span > < span class = "pl-en" > addEventListener< / span > < span class = "pl-kos" > (< / span > < span class = "pl-s" > 'change'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s1" > handleFile< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > false< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ;< / span > < / pre > < / div >
2020-01-28 05:02:07 +00:00
< p > The < a href = "demos/oldie/" > < code > oldie< / code > demo< / a > shows an IE-compatible fallback scenario.< / p >
< / details >
< p > More specialized cases, including mobile app file processing, are covered in the
< a href = "demos/" > included demos< / a > < / p >
< h3 >
< a id = "user-content-parsing-examples" class = "anchor" href = "#parsing-examples" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > Parsing Examples< / h3 >
< ul >
< li >
2021-08-27 00:16:16 +00:00
< a href = "http://oss.sheetjs.com/sheetjs/" rel = "nofollow" > http://oss.sheetjs.com/sheetjs/< / a > HTML5 File API / Base64 Text / Web Workers< / li >
2020-01-28 05:02:07 +00:00
< / ul >
< p > Note that older versions of IE do not support HTML5 File API, so the Base64 mode
is used for testing.< / p >
< details >
< summary > < b > Get Base64 encoding on OSX / Windows< / b > (click to show)< / summary >
< p > On OSX you can get the Base64 encoding with:< / p >
< div class = "highlight highlight-source-shell" > < pre > $ < span class = "pl-k" > < < / span > target_file base64 < span class = "pl-k" > |< / span > pbcopy< / pre > < / div >
< p > On Windows XP and up you can get the Base64 encoding using < code > certutil< / code > :< / p >
< div class = "highlight highlight-source-batchfile" > < pre > < span class = "pl-k" > > < / span > < span class = "pl-k" > certutil< / span > -encode target_file target_file.b64< / pre > < / div >
< p > (note: You have to open the file and remove the header and footer lines)< / p >
< / details >
< ul >
< li >
2021-08-27 00:16:16 +00:00
< a href = "http://oss.sheetjs.com/sheetjs/ajax.html" rel = "nofollow" > http://oss.sheetjs.com/sheetjs/ajax.html< / a > XMLHttpRequest< / li >
2020-01-28 05:02:07 +00:00
< / ul >
< h3 >
< a id = "user-content-streaming-read" class = "anchor" href = "#streaming-read" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > Streaming Read< / h3 >
< details >
< summary > < b > Why is there no Streaming Read API?< / b > (click to show)< / summary >
< p > The most common and interesting formats (XLS, XLSX/M, XLSB, ODS) are ultimately
ZIP or CFB containers of files. Neither format puts the directory structure at
the beginning of the file: ZIP files place the Central Directory records at the
end of the logical file, while CFB files can place the storage info anywhere in
the file! As a result, to properly handle these formats, a streaming function
would have to buffer the entire file before commencing. That belies the
expectations of streaming, so we do not provide any streaming read API.< / p >
< / details >
< p > When dealing with Readable Streams, the easiest approach is to buffer the stream
and process the whole thing at the end. This can be done with a temporary file
or by explicitly concatenating the stream:< / p >
< details >
< summary > < b > Explicitly concatenating streams< / b > (click to show)< / summary >
2021-08-27 00:16:16 +00:00
< div class = "highlight highlight-source-js" > < pre > < span class = "pl-k" > var< / span > < span class = "pl-s1" > fs< / span > < span class = "pl-c1" > =< / span > < span class = "pl-en" > require< / span > < span class = "pl-kos" > (< / span > < span class = "pl-s" > 'fs'< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ;< / span >
< 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 >
< span class = "pl-k" > function< / span > < span class = "pl-en" > process_RS< / span > < span class = "pl-kos" > (< / span > < span class = "pl-s1" > stream< / span > < span class = "pl-c" > /*:ReadStream*/< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s1" > cb< / span > < span class = "pl-c" > /*:(wb:Workbook)=> void*/< / span > < span class = "pl-kos" > )< / span > < span class = "pl-c" > /*:void*/< / span > < span class = "pl-kos" > {< / span >
< span class = "pl-k" > var< / span > < span class = "pl-s1" > buffers< / span > < span class = "pl-c1" > =< / span > < span class = "pl-kos" > [< / span > < span class = "pl-kos" > ]< / span > < span class = "pl-kos" > ;< / span >
< span class = "pl-s1" > stream< / span > < span class = "pl-kos" > .< / span > < span class = "pl-en" > on< / span > < span class = "pl-kos" > (< / span > < span class = "pl-s" > 'data'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-k" > function< / span > < span class = "pl-kos" > (< / span > < span class = "pl-s1" > data< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > {< / span > < span class = "pl-s1" > buffers< / span > < span class = "pl-kos" > .< / span > < span class = "pl-en" > push< / span > < span class = "pl-kos" > (< / span > < span class = "pl-s1" > data< / 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-s1" > stream< / span > < span class = "pl-kos" > .< / span > < span class = "pl-en" > on< / span > < span class = "pl-kos" > (< / span > < span class = "pl-s" > 'end'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-k" > function< / span > < span class = "pl-kos" > (< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > {< / span >
< span class = "pl-k" > var< / span > < span class = "pl-s1" > buffer< / span > < span class = "pl-c1" > =< / span > < span class = "pl-v" > Buffer< / span > < span class = "pl-kos" > .< / span > < span class = "pl-en" > concat< / span > < span class = "pl-kos" > (< / span > < span class = "pl-s1" > buffers< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ;< / 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-en" > read< / span > < span class = "pl-kos" > (< / span > < span class = "pl-s1" > buffer< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-kos" > {< / span > < span class = "pl-c1" > type< / span > :< span class = "pl-s" > "buffer"< / span > < span class = "pl-kos" > }< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ;< / span >
2020-01-28 05:02:07 +00:00
2021-08-27 00:16:16 +00:00
< span class = "pl-c" > /* DO SOMETHING WITH workbook IN THE CALLBACK */< / span >
< span class = "pl-s1" > cb< / span > < span class = "pl-kos" > (< / span > < span class = "pl-s1" > workbook< / 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 >
2020-01-28 05:02:07 +00:00
< p > More robust solutions are available using modules like < code > concat-stream< / code > .< / p >
< / details >
< details >
< summary > < b > Writing to filesystem first< / b > (click to show)< / summary >
< p > This example uses < a href = "https://npm.im/tempfile" rel = "nofollow" > < code > tempfile< / code > < / a > to generate file names:< / p >
2021-08-27 00:16:16 +00:00
< div class = "highlight highlight-source-js" > < pre > < span class = "pl-k" > var< / span > < span class = "pl-s1" > fs< / span > < span class = "pl-c1" > =< / span > < span class = "pl-en" > require< / span > < span class = "pl-kos" > (< / span > < span class = "pl-s" > 'fs'< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s1" > tempfile< / span > < span class = "pl-c1" > =< / span > < span class = "pl-en" > require< / span > < span class = "pl-kos" > (< / span > < span class = "pl-s" > 'tempfile'< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ;< / span >
< 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 >
< span class = "pl-k" > function< / span > < span class = "pl-en" > process_RS< / span > < span class = "pl-kos" > (< / span > < span class = "pl-s1" > stream< / span > < span class = "pl-c" > /*:ReadStream*/< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s1" > cb< / span > < span class = "pl-c" > /*:(wb:Workbook)=> void*/< / span > < span class = "pl-kos" > )< / span > < span class = "pl-c" > /*:void*/< / span > < span class = "pl-kos" > {< / span >
< span class = "pl-k" > var< / span > < span class = "pl-s1" > fname< / span > < span class = "pl-c1" > =< / span > < span class = "pl-s1" > tempfile< / span > < span class = "pl-kos" > (< / span > < span class = "pl-s" > '.sheetjs'< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ;< / span >
< span class = "pl-smi" > console< / span > < span class = "pl-kos" > .< / span > < span class = "pl-en" > log< / span > < span class = "pl-kos" > (< / span > < span class = "pl-s1" > fname< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ;< / span >
< span class = "pl-k" > var< / span > < span class = "pl-s1" > ostream< / span > < span class = "pl-c1" > =< / span > < span class = "pl-s1" > fs< / span > < span class = "pl-kos" > .< / span > < span class = "pl-en" > createWriteStream< / span > < span class = "pl-kos" > (< / span > < span class = "pl-s1" > fname< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ;< / span >
< span class = "pl-s1" > stream< / span > < span class = "pl-kos" > .< / span > < span class = "pl-en" > pipe< / span > < span class = "pl-kos" > (< / span > < span class = "pl-s1" > ostream< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ;< / span >
< span class = "pl-s1" > ostream< / span > < span class = "pl-kos" > .< / span > < span class = "pl-en" > on< / span > < span class = "pl-kos" > (< / span > < span class = "pl-s" > 'finish'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-k" > function< / span > < span class = "pl-kos" > (< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > {< / 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-en" > readFile< / span > < span class = "pl-kos" > (< / span > < span class = "pl-s1" > fname< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ;< / span >
< span class = "pl-s1" > fs< / span > < span class = "pl-kos" > .< / span > < span class = "pl-en" > unlinkSync< / span > < span class = "pl-kos" > (< / span > < span class = "pl-s1" > fname< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ;< / span >
2020-01-28 05:02:07 +00:00
2021-08-27 00:16:16 +00:00
< span class = "pl-c" > /* DO SOMETHING WITH workbook IN THE CALLBACK */< / span >
< span class = "pl-s1" > cb< / span > < span class = "pl-kos" > (< / span > < span class = "pl-s1" > workbook< / 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 >
2020-01-28 05:02:07 +00:00
< / details >
< h2 >
< a id = "user-content-working-with-the-workbook" class = "anchor" href = "#working-with-the-workbook" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > Working with the Workbook< / h2 >
< p > The full object format is described later in this README.< / p >
< details >
< summary > < b > Reading a specific cell < / b > (click to show)< / summary >
< p > This example extracts the value stored in cell A1 from the first worksheet:< / p >
2021-08-27 00:16:16 +00:00
< div class = "highlight highlight-source-js" > < pre > < span class = "pl-k" > var< / span > < span class = "pl-s1" > first_sheet_name< / span > < span class = "pl-c1" > =< / span > < span class = "pl-s1" > workbook< / span > < span class = "pl-kos" > .< / span > < span class = "pl-c1" > SheetNames< / span > < span class = "pl-kos" > [< / span > < span class = "pl-c1" > 0< / span > < span class = "pl-kos" > ]< / span > < span class = "pl-kos" > ;< / span >
< span class = "pl-k" > var< / span > < span class = "pl-s1" > address_of_cell< / span > < span class = "pl-c1" > =< / span > < span class = "pl-s" > 'A1'< / span > < span class = "pl-kos" > ;< / span >
2020-01-28 05:02:07 +00:00
2021-08-27 00:16:16 +00:00
< span class = "pl-c" > /* Get worksheet */< / span >
< span class = "pl-k" > var< / span > < span class = "pl-s1" > worksheet< / 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-s1" > first_sheet_name< / span > < span class = "pl-kos" > ]< / span > < span class = "pl-kos" > ;< / span >
2020-01-28 05:02:07 +00:00
2021-08-27 00:16:16 +00:00
< span class = "pl-c" > /* Find desired cell */< / span >
< span class = "pl-k" > var< / span > < span class = "pl-s1" > desired_cell< / span > < span class = "pl-c1" > =< / span > < span class = "pl-s1" > worksheet< / span > < span class = "pl-kos" > [< / span > < span class = "pl-s1" > address_of_cell< / span > < span class = "pl-kos" > ]< / span > < span class = "pl-kos" > ;< / span >
2020-01-28 05:02:07 +00:00
2021-08-27 00:16:16 +00:00
< span class = "pl-c" > /* Get the value */< / span >
< span class = "pl-k" > var< / span > < span class = "pl-s1" > desired_value< / span > < span class = "pl-c1" > =< / span > < span class = "pl-kos" > (< / span > < span class = "pl-s1" > desired_cell< / span > ? < span class = "pl-s1" > desired_cell< / span > < span class = "pl-kos" > .< / span > < span class = "pl-c1" > v< / span > : < span class = "pl-c1" > undefined< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ;< / span > < / pre > < / div >
2020-01-28 05:02:07 +00:00
< / details >
< details >
< summary > < b > Adding a new worksheet to a workbook< / b > (click to show)< / summary >
< p > This example uses < a href = "#array-of-arrays-input" > < code > XLSX.utils.aoa_to_sheet< / code > < / a > to make a
sheet and < code > XLSX.utils.book_append_sheet< / code > to append the sheet to the workbook:< / p >
2021-08-27 00:16:16 +00:00
< div class = "highlight highlight-source-js" > < pre > < span class = "pl-k" > var< / span > < span class = "pl-s1" > ws_name< / span > < span class = "pl-c1" > =< / span > < span class = "pl-s" > "SheetJS"< / span > < span class = "pl-kos" > ;< / span >
2020-01-28 05:02:07 +00:00
2021-08-27 00:16:16 +00:00
< span class = "pl-c" > /* make worksheet */< / span >
< span class = "pl-k" > var< / span > < span class = "pl-s1" > ws_data< / span > < span class = "pl-c1" > =< / span > < span class = "pl-kos" > [< / span >
< span class = "pl-kos" > [< / span > < span class = "pl-s" > "S"< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > "h"< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > "e"< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > "e"< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > "t"< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > "J"< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > "S"< / span > < span class = "pl-kos" > ]< / span > < span class = "pl-kos" > ,< / span >
< span class = "pl-kos" > [< / span > < span class = "pl-c1" > 1< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > 2< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > 3< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > 4< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > 5< / span > < span class = "pl-kos" > ]< / span >
< span class = "pl-kos" > ]< / span > < span class = "pl-kos" > ;< / span >
< span class = "pl-k" > var< / span > < span class = "pl-s1" > ws< / 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" > aoa_to_sheet< / span > < span class = "pl-kos" > (< / span > < span class = "pl-s1" > ws_data< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ;< / span >
2020-01-28 05:02:07 +00:00
2021-08-27 00:16:16 +00:00
< span class = "pl-c" > /* Add the worksheet to the workbook */< / 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" > wb< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s1" > ws< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s1" > ws_name< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ;< / span > < / pre > < / div >
2020-01-28 05:02:07 +00:00
< / details >
< details >
< summary > < b > Creating a new workbook from scratch< / b > (click to show)< / summary >
< p > The workbook object contains a < code > SheetNames< / code > array of names and a < code > Sheets< / code > object
mapping sheet names to sheet objects. The < code > XLSX.utils.book_new< / code > utility function
creates a new workbook object:< / p >
2021-08-27 00:16:16 +00:00
< div class = "highlight highlight-source-js" > < pre > < span class = "pl-c" > /* create a new blank workbook */< / span >
< span class = "pl-k" > var< / span > < span class = "pl-s1" > wb< / 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 > < / pre > < / div >
2020-01-28 05:02:07 +00:00
< p > The new workbook is blank and contains no worksheets. The write functions will
error if the workbook is empty.< / p >
< / details >
< h3 >
< a id = "user-content-parsing-and-writing-examples" class = "anchor" href = "#parsing-and-writing-examples" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > Parsing and Writing Examples< / h3 >
< ul >
< li >
< p > < a href = "http://sheetjs.com/demos/modify.html" rel = "nofollow" > http://sheetjs.com/demos/modify.html< / a > read + modify + write files< / p >
< / li >
< li >
2021-08-27 00:16:16 +00:00
< p > < a href = "https://github.com/SheetJS/sheetjs/blob/HEAD/bin/xlsx.njs" > https://github.com/SheetJS/sheetjs/blob/HEAD/bin/xlsx.njs< / a > node< / p >
2020-01-28 05:02:07 +00:00
< / li >
< / ul >
< p > The node version installs a command line tool < code > xlsx< / code > which can read spreadsheet
files and output the contents in various formats. The source is available at
< code > xlsx.njs< / code > in the bin directory.< / p >
< p > Some helper functions in < code > XLSX.utils< / code > generate different views of the sheets:< / p >
< ul >
< li >
< code > XLSX.utils.sheet_to_csv< / code > generates CSV< / li >
< li >
< code > XLSX.utils.sheet_to_txt< / code > generates UTF16 Formatted Text< / li >
< li >
< code > XLSX.utils.sheet_to_html< / code > generates HTML< / li >
< li >
< code > XLSX.utils.sheet_to_json< / code > generates an array of objects< / li >
< li >
< code > XLSX.utils.sheet_to_formulae< / code > generates a list of formulae< / li >
< / ul >
< h2 >
< a id = "user-content-writing-workbooks" class = "anchor" href = "#writing-workbooks" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > Writing Workbooks< / h2 >
< p > For writing, the first step is to generate output data. The helper functions
< code > write< / code > and < code > writeFile< / code > will produce the data in various formats suitable for
dissemination. The second step is to actual share the data with the end point.
Assuming < code > workbook< / code > is a workbook object:< / p >
< details >
< summary > < b > nodejs write a file< / b > (click to show)< / summary >
< p > < code > XLSX.writeFile< / code > uses < code > fs.writeFileSync< / code > in server environments:< / p >
2021-08-27 00:16:16 +00:00
< div class = "highlight highlight-source-js" > < pre > < span class = "pl-k" > if< / span > < span class = "pl-kos" > (< / span > < span class = "pl-k" > typeof< / span > < span class = "pl-en" > require< / span > < span class = "pl-c1" > !==< / span > < span class = "pl-s" > 'undefined'< / span > < span class = "pl-kos" > )< / 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 >
< span class = "pl-c" > /* output format determined by filename */< / 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" > 'out.xlsb'< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ;< / span >
< span class = "pl-c" > /* at this point, out.xlsb is a file that you can distribute */< / span > < / pre > < / div >
2020-01-28 05:02:07 +00:00
< / details >
< details >
< summary > < b > Photoshop ExtendScript write a file< / b > (click to show)< / summary >
< p > < code > writeFile< / code > wraps the < code > File< / code > logic in Photoshop and other ExtendScript targets.
The specified path should be an absolute path:< / p >
2021-08-27 00:16:16 +00:00
< div class = "highlight highlight-source-js" > < pre > #< span class = "pl-s1" > include< / span > < span class = "pl-s" > "xlsx.extendscript.js"< / span >
< span class = "pl-c" > /* output format determined by filename */< / 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" > 'out.xlsx'< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ;< / span >
< span class = "pl-c" > /* at this point, out.xlsx is a file that you can distribute */< / span > < / pre > < / div >
2020-01-28 05:02:07 +00:00
< p > The < a href = "demos/extendscript/" > < code > extendscript< / code > demo< / a > includes a more complex example.< / p >
< / details >
< details >
< summary > < b > Browser add TABLE element to page< / b > (click to show)< / summary >
< p > The < code > sheet_to_html< / code > utility function generates HTML code that can be added to
any DOM element.< / p >
2021-08-27 00:16:16 +00:00
< div class = "highlight highlight-source-js" > < pre > < span class = "pl-k" > var< / span > < span class = "pl-s1" > worksheet< / 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-s1" > workbook< / span > < span class = "pl-kos" > .< / span > < span class = "pl-c1" > SheetNames< / span > < span class = "pl-kos" > [< / span > < span class = "pl-c1" > 0< / span > < span class = "pl-kos" > ]< / span > < span class = "pl-kos" > ]< / span > < span class = "pl-kos" > ;< / span >
< span class = "pl-k" > var< / span > < span class = "pl-s1" > container< / 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" > 'tableau'< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ;< / span >
< span class = "pl-s1" > container< / span > < span class = "pl-kos" > .< / span > < span class = "pl-c1" > innerHTML< / 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" > sheet_to_html< / span > < span class = "pl-kos" > (< / span > < span class = "pl-s1" > worksheet< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ;< / span > < / pre > < / div >
2020-01-28 05:02:07 +00:00
< / details >
< details >
< summary > < b > Browser upload file (ajax)< / b > (click to show)< / summary >
< p > A complete example using XHR is < a href = "demos/xhr/" > included in the XHR demo< / a > , along
with examples for fetch and wrapper libraries. This example assumes the server
can handle Base64-encoded files (see the demo for a basic nodejs server):< / p >
2021-08-27 00:16:16 +00:00
< div class = "highlight highlight-source-js" > < pre > < span class = "pl-c" > /* in this example, send a base64 string to the server */< / span >
< span class = "pl-k" > var< / span > < span class = "pl-s1" > wopts< / span > < span class = "pl-c1" > =< / span > < span class = "pl-kos" > {< / span > < span class = "pl-c1" > bookType< / span > :< span class = "pl-s" > 'xlsx'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > bookSST< / span > :< span class = "pl-c1" > false< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > type< / span > :< span class = "pl-s" > 'base64'< / span > < span class = "pl-kos" > }< / span > < span class = "pl-kos" > ;< / span >
2020-01-28 05:02:07 +00:00
2021-08-27 00:16:16 +00:00
< span class = "pl-k" > var< / span > < span class = "pl-s1" > wbout< / span > < span class = "pl-c1" > =< / span > < span class = "pl-c1" > XLSX< / span > < span class = "pl-kos" > .< / span > < span class = "pl-en" > write< / span > < span class = "pl-kos" > (< / span > < span class = "pl-s1" > workbook< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s1" > wopts< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ;< / span >
2020-01-28 05:02:07 +00:00
2021-08-27 00:16:16 +00:00
< span class = "pl-k" > var< / span > < span class = "pl-s1" > req< / span > < span class = "pl-c1" > =< / span > < span class = "pl-k" > new< / span > < span class = "pl-v" > XMLHttpRequest< / span > < span class = "pl-kos" > (< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ;< / span >
< span class = "pl-s1" > req< / span > < span class = "pl-kos" > .< / span > < span class = "pl-en" > open< / span > < span class = "pl-kos" > (< / span > < span class = "pl-s" > "POST"< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > "/upload"< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > true< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ;< / span >
< span class = "pl-k" > var< / span > < span class = "pl-s1" > formdata< / span > < span class = "pl-c1" > =< / span > < span class = "pl-k" > new< / span > < span class = "pl-v" > FormData< / span > < span class = "pl-kos" > (< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ;< / span >
< span class = "pl-s1" > formdata< / span > < span class = "pl-kos" > .< / span > < span class = "pl-en" > append< / span > < span class = "pl-kos" > (< / span > < span class = "pl-s" > 'file'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > 'test.xlsx'< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ;< / span > < span class = "pl-c" > // < -- server expects `file` to hold name< / span >
< span class = "pl-s1" > formdata< / span > < span class = "pl-kos" > .< / span > < span class = "pl-en" > append< / span > < span class = "pl-kos" > (< / span > < span class = "pl-s" > 'data'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s1" > wbout< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ;< / span > < span class = "pl-c" > // < -- `data` holds the base64-encoded data< / span >
< span class = "pl-s1" > req< / span > < span class = "pl-kos" > .< / span > < span class = "pl-en" > send< / span > < span class = "pl-kos" > (< / span > < span class = "pl-s1" > formdata< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ;< / span > < / pre > < / div >
2020-01-28 05:02:07 +00:00
< / details >
< details >
< summary > < b > Browser save file< / b > (click to show)< / summary >
< p > < code > XLSX.writeFile< / code > wraps a few techniques for triggering a file save:< / p >
< ul >
< li >
< code > URL< / code > browser API creates an object URL for the file, which the library uses
by creating a link and forcing a click. It is supported in modern browsers.< / li >
< li >
< code > msSaveBlob< / code > is an IE10+ API for triggering a file save.< / li >
< li >
< code > IE_FileSave< / code > uses VBScript and ActiveX to write a file in IE6+ for Windows
XP and Windows 7. The shim must be included in the containing HTML page.< / li >
< / ul >
< p > There is no standard way to determine if the actual file has been downloaded.< / p >
2021-08-27 00:16:16 +00:00
< div class = "highlight highlight-source-js" > < pre > < span class = "pl-c" > /* output format determined by filename */< / 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" > 'out.xlsb'< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ;< / span >
< span class = "pl-c" > /* at this point, out.xlsb will have been downloaded */< / span > < / pre > < / div >
2020-01-28 05:02:07 +00:00
< / details >
< details >
< summary > < b > Browser save file (compatibility)< / b > (click to show)< / summary >
< p > < code > XLSX.writeFile< / code > techniques work for most modern browsers as well as older IE.
For much older browsers, there are workarounds implemented by wrapper libraries.< / p >
< p > < a href = "https://github.com/eligrey/FileSaver.js/" > < code > FileSaver.js< / code > < / a > implements < code > saveAs< / code > .
Note: < code > XLSX.writeFile< / code > will automatically call < code > saveAs< / code > if available.< / p >
2021-08-27 00:16:16 +00:00
< div class = "highlight highlight-source-js" > < pre > < span class = "pl-c" > /* bookType can be any supported output type */< / span >
< span class = "pl-k" > var< / span > < span class = "pl-s1" > wopts< / span > < span class = "pl-c1" > =< / span > < span class = "pl-kos" > {< / span > < span class = "pl-c1" > bookType< / span > :< span class = "pl-s" > 'xlsx'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > bookSST< / span > :< span class = "pl-c1" > false< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > type< / span > :< span class = "pl-s" > 'array'< / span > < span class = "pl-kos" > }< / span > < span class = "pl-kos" > ;< / span >
2020-01-28 05:02:07 +00:00
2021-08-27 00:16:16 +00:00
< span class = "pl-k" > var< / span > < span class = "pl-s1" > wbout< / span > < span class = "pl-c1" > =< / span > < span class = "pl-c1" > XLSX< / span > < span class = "pl-kos" > .< / span > < span class = "pl-en" > write< / span > < span class = "pl-kos" > (< / span > < span class = "pl-s1" > workbook< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s1" > wopts< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ;< / span >
2020-01-28 05:02:07 +00:00
2021-08-27 00:16:16 +00:00
< span class = "pl-c" > /* the saveAs call downloads a file on the local machine */< / span >
< span class = "pl-en" > saveAs< / span > < span class = "pl-kos" > (< / span > < span class = "pl-k" > new< / span > < span class = "pl-v" > Blob< / span > < span class = "pl-kos" > (< / span > < span class = "pl-kos" > [< / span > < span class = "pl-s1" > wbout< / span > < span class = "pl-kos" > ]< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-kos" > {< / span > < span class = "pl-c1" > type< / span > :< span class = "pl-s" > "application/octet-stream"< / span > < span class = "pl-kos" > }< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > "test.xlsx"< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ;< / span > < / pre > < / div >
2020-01-28 05:02:07 +00:00
< p > < a href = "https://github.com/dcneiner/downloadify" > < code > Downloadify< / code > < / a > uses a Flash SWF button
to generate local files, suitable for environments where ActiveX is unavailable:< / p >
2021-08-27 00:16:16 +00:00
< div class = "highlight highlight-source-js" > < pre > < span class = "pl-v" > Downloadify< / span > < span class = "pl-kos" > .< / span > < span class = "pl-en" > create< / span > < span class = "pl-kos" > (< / span > < span class = "pl-s1" > id< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-kos" > {< / span >
< span class = "pl-c" > /* other options are required! read the downloadify docs for more info */< / span >
< span class = "pl-c1" > filename< / span > : < span class = "pl-s" > "test.xlsx"< / span > < span class = "pl-kos" > ,< / span >
< span class = "pl-en" > data< / span > : < span class = "pl-k" > function< / span > < span class = "pl-kos" > (< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > {< / span > < span class = "pl-k" > return< / span > < span class = "pl-c1" > XLSX< / span > < span class = "pl-kos" > .< / span > < span class = "pl-en" > write< / span > < span class = "pl-kos" > (< / span > < span class = "pl-s1" > wb< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-kos" > {< / span > < span class = "pl-c1" > bookType< / span > :< span class = "pl-s" > "xlsx"< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > type< / span > :< span class = "pl-s" > 'base64'< / 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" > append< / span > : < span class = "pl-c1" > false< / span > < span class = "pl-kos" > ,< / span >
< span class = "pl-c1" > dataType< / span > : < span class = "pl-s" > 'base64'< / span >
< span class = "pl-kos" > }< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ;< / span > < / pre > < / div >
2020-01-28 05:02:07 +00:00
< p > The < a href = "demos/oldie/" > < code > oldie< / code > demo< / a > shows an IE-compatible fallback scenario.< / p >
< / details >
< p > The < a href = "demos/" > included demos< / a > cover mobile apps and other special deployments.< / p >
< h3 >
< a id = "user-content-writing-examples" class = "anchor" href = "#writing-examples" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > Writing Examples< / h3 >
< ul >
< li >
< a href = "http://sheetjs.com/demos/table.html" rel = "nofollow" > http://sheetjs.com/demos/table.html< / a > exporting an HTML table< / li >
< li >
< a href = "http://sheetjs.com/demos/writexlsx.html" rel = "nofollow" > http://sheetjs.com/demos/writexlsx.html< / a > generates a simple file< / li >
< / ul >
< h3 >
< a id = "user-content-streaming-write" class = "anchor" href = "#streaming-write" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > Streaming Write< / h3 >
< p > The streaming write functions are available in the < code > XLSX.stream< / code > object. They
take the same arguments as the normal write functions but return a Readable
Stream. They are only exposed in NodeJS.< / p >
< ul >
< li >
< code > XLSX.stream.to_csv< / code > is the streaming version of < code > XLSX.utils.sheet_to_csv< / code > .< / li >
< li >
< code > XLSX.stream.to_html< / code > is the streaming version of < code > XLSX.utils.sheet_to_html< / code > .< / li >
< li >
< code > XLSX.stream.to_json< / code > is the streaming version of < code > XLSX.utils.sheet_to_json< / code > .< / li >
< / ul >
< details >
< summary > < b > nodejs convert to CSV and write file< / b > (click to show)< / summary >
2021-08-27 00:16:16 +00:00
< div class = "highlight highlight-source-js" > < pre > < span class = "pl-k" > var< / span > < span class = "pl-s1" > output_file_name< / span > < span class = "pl-c1" > =< / span > < span class = "pl-s" > "out.csv"< / span > < span class = "pl-kos" > ;< / span >
< span class = "pl-k" > var< / span > < span class = "pl-s1" > stream< / span > < span class = "pl-c1" > =< / 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" > to_csv< / 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-s1" > stream< / span > < span class = "pl-kos" > .< / span > < span class = "pl-en" > pipe< / span > < span class = "pl-kos" > (< / span > < span class = "pl-s1" > fs< / span > < span class = "pl-kos" > .< / span > < span class = "pl-en" > createWriteStream< / span > < span class = "pl-kos" > (< / span > < span class = "pl-s1" > output_file_name< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ;< / span > < / pre > < / div >
2020-01-28 05:02:07 +00:00
< / details >
< details >
< summary > < b > nodejs write JSON stream to screen< / b > (click to show)< / summary >
2021-08-27 00:16:16 +00:00
< div class = "highlight highlight-source-js" > < pre > < span class = "pl-c" > /* to_json returns an object-mode stream */< / span >
< span class = "pl-k" > var< / span > < span class = "pl-s1" > stream< / span > < span class = "pl-c1" > =< / 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" > to_json< / 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-c1" > raw< / span > :< span class = "pl-c1" > true< / span > < span class = "pl-kos" > }< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ;< / span >
2020-01-28 05:02:07 +00:00
2021-08-27 00:16:16 +00:00
< span class = "pl-c" > /* the following stream converts JS objects to text via JSON.stringify */< / span >
< span class = "pl-k" > var< / span > < span class = "pl-s1" > conv< / span > < span class = "pl-c1" > =< / span > < span class = "pl-k" > new< / span > < span class = "pl-v" > Transform< / span > < span class = "pl-kos" > (< / span > < span class = "pl-kos" > {< / span > < span class = "pl-c1" > writableObjectMode< / span > :< span class = "pl-c1" > true< / span > < span class = "pl-kos" > }< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ;< / span >
< span class = "pl-s1" > conv< / span > < span class = "pl-kos" > .< / span > < span class = "pl-en" > _transform< / span > < span class = "pl-c1" > =< / span > < span class = "pl-k" > function< / span > < span class = "pl-kos" > (< / span > < span class = "pl-s1" > obj< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s1" > e< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s1" > cb< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > {< / span > < span class = "pl-s1" > cb< / span > < span class = "pl-kos" > (< / span > < span class = "pl-c1" > null< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > JSON< / span > < span class = "pl-kos" > .< / span > < span class = "pl-en" > stringify< / span > < span class = "pl-kos" > (< / span > < span class = "pl-s1" > obj< / span > < span class = "pl-kos" > )< / span > < span class = "pl-c1" > +< / span > < span class = "pl-s" > "\n"< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ;< / span > < span class = "pl-kos" > }< / span > < span class = "pl-kos" > ;< / span >
2020-01-28 05:02:07 +00:00
2021-08-27 00:16:16 +00:00
< span class = "pl-s1" > stream< / span > < span class = "pl-kos" > .< / span > < span class = "pl-en" > pipe< / span > < span class = "pl-kos" > (< / span > < span class = "pl-s1" > conv< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ;< / span > < span class = "pl-s1" > conv< / span > < span class = "pl-kos" > .< / span > < span class = "pl-en" > pipe< / span > < span class = "pl-kos" > (< / span > < span class = "pl-s1" > process< / span > < span class = "pl-kos" > .< / span > < span class = "pl-c1" > stdout< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ;< / span > < / pre > < / div >
2020-01-28 05:02:07 +00:00
< / details >
< p > < a href = "https://github.com/sheetjs/sheetaki" > https://github.com/sheetjs/sheetaki< / a > pipes write streams to nodejs response.< / p >
< h2 >
< a id = "user-content-interface" class = "anchor" href = "#interface" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > Interface< / h2 >
< p > < code > XLSX< / code > is the exposed variable in the browser and the exported node variable< / p >
< p > < code > XLSX.version< / code > is the version of the library (added by the build script).< / p >
< p > < code > XLSX.SSF< / code > is an embedded version of the < a href = "http://git.io/ssf" rel = "nofollow" > format library< / a > .< / p >
< h3 >
< a id = "user-content-parsing-functions" class = "anchor" href = "#parsing-functions" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > Parsing functions< / h3 >
< p > < code > XLSX.read(data, read_opts)< / code > attempts to parse < code > data< / code > .< / p >
< p > < code > XLSX.readFile(filename, read_opts)< / code > attempts to read < code > filename< / code > and parse.< / p >
< p > Parse options are described in the < a href = "#parsing-options" > Parsing Options< / a > section.< / p >
< h3 >
< a id = "user-content-writing-functions" class = "anchor" href = "#writing-functions" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > Writing functions< / h3 >
< p > < code > XLSX.write(wb, write_opts)< / code > attempts to write the workbook < code > wb< / code > < / p >
< p > < code > XLSX.writeFile(wb, filename, write_opts)< / code > attempts to write < code > wb< / code > to < code > filename< / code > .
In browser-based environments, it will attempt to force a client-side download.< / p >
< p > < code > XLSX.writeFileAsync(filename, wb, o, cb)< / code > attempts to write < code > wb< / code > to < code > filename< / code > .
If < code > o< / code > is omitted, the writer will use the third argument as the callback.< / p >
< p > < code > XLSX.stream< / code > contains a set of streaming write functions.< / p >
< p > Write options are described in the < a href = "#writing-options" > Writing Options< / a > section.< / p >
< h3 >
< a id = "user-content-utilities" class = "anchor" href = "#utilities" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > Utilities< / h3 >
< p > Utilities are available in the < code > XLSX.utils< / code > object and are described in the
< a href = "#utility-functions" > Utility Functions< / a > section:< / p >
< p > < strong > Importing:< / strong > < / p >
< ul >
< li >
< code > aoa_to_sheet< / code > converts an array of arrays of JS data to a worksheet.< / li >
< li >
< code > json_to_sheet< / code > converts an array of JS objects to a worksheet.< / li >
< li >
< code > table_to_sheet< / code > converts a DOM TABLE element to a worksheet.< / li >
< li >
< code > sheet_add_aoa< / code > adds an array of arrays of JS data to an existing worksheet.< / li >
< li >
< code > sheet_add_json< / code > adds an array of JS objects to an existing worksheet.< / li >
< / ul >
< p > < strong > Exporting:< / strong > < / p >
< ul >
< li >
< code > sheet_to_json< / code > converts a worksheet object to an array of JSON objects.< / li >
< li >
< code > sheet_to_csv< / code > generates delimiter-separated-values output.< / li >
< li >
< code > sheet_to_txt< / code > generates UTF16 formatted text.< / li >
< li >
< code > sheet_to_html< / code > generates HTML output.< / li >
< li >
< code > sheet_to_formulae< / code > generates a list of the formulae (with value fallbacks).< / li >
< / ul >
< p > < strong > Cell and cell address manipulation:< / strong > < / p >
< ul >
< li >
< code > format_cell< / code > generates the text value for a cell (using number formats).< / li >
< li >
< code > encode_row / decode_row< / code > converts between 0-indexed rows and 1-indexed rows.< / li >
< li >
< code > encode_col / decode_col< / code > converts between 0-indexed columns and column names.< / li >
< li >
< code > encode_cell / decode_cell< / code > converts cell addresses.< / li >
< li >
< code > encode_range / decode_range< / code > converts cell ranges.< / li >
< / ul >
< h2 >
< a id = "user-content-common-spreadsheet-format" class = "anchor" href = "#common-spreadsheet-format" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > Common Spreadsheet Format< / h2 >
2021-08-27 00:16:16 +00:00
< p > SheetJS conforms to the Common Spreadsheet Format (CSF):< / p >
2020-01-28 05:02:07 +00:00
< h3 >
< a id = "user-content-general-structures" class = "anchor" href = "#general-structures" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > General Structures< / h3 >
< p > Cell address objects are stored as < code > {c:C, r:R}< / code > where < code > C< / code > and < code > R< / code > are 0-indexed
column and row numbers, respectively. For example, the cell address < code > B5< / code > is
represented by the object < code > {c:1, r:4}< / code > .< / p >
< p > Cell range objects are stored as < code > {s:S, e:E}< / code > where < code > S< / code > is the first cell and
< code > E< / code > is the last cell in the range. The ranges are inclusive. For example, the
range < code > A3:B7< / code > is represented by the object < code > {s:{c:0, r:2}, e:{c:1, r:6}}< / code > .
Utility functions perform a row-major order walk traversal of a sheet range:< / p >
2021-08-27 00:16:16 +00:00
< div class = "highlight highlight-source-js" > < pre > < span class = "pl-k" > for< / span > < span class = "pl-kos" > (< / span > < span class = "pl-k" > var< / span > < span class = "pl-v" > R< / span > < span class = "pl-c1" > =< / span > < span class = "pl-s1" > range< / span > < span class = "pl-kos" > .< / span > < span class = "pl-c1" > s< / span > < span class = "pl-kos" > .< / span > < span class = "pl-c1" > r< / span > < span class = "pl-kos" > ;< / span > < span class = "pl-v" > R< / span > < span class = "pl-c1" > < =< / span > < span class = "pl-s1" > range< / span > < span class = "pl-kos" > .< / span > < span class = "pl-c1" > e< / span > < span class = "pl-kos" > .< / span > < span class = "pl-c1" > r< / span > < span class = "pl-kos" > ;< / span > < span class = "pl-c1" > ++< / span > < span class = "pl-v" > R< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > {< / span >
< span class = "pl-k" > for< / span > < span class = "pl-kos" > (< / span > < span class = "pl-k" > var< / span > < span class = "pl-v" > C< / span > < span class = "pl-c1" > =< / span > < span class = "pl-s1" > range< / span > < span class = "pl-kos" > .< / span > < span class = "pl-c1" > s< / span > < span class = "pl-kos" > .< / span > < span class = "pl-c1" > c< / span > < span class = "pl-kos" > ;< / span > < span class = "pl-v" > C< / span > < span class = "pl-c1" > < =< / span > < span class = "pl-s1" > range< / span > < span class = "pl-kos" > .< / span > < span class = "pl-c1" > e< / span > < span class = "pl-kos" > .< / span > < span class = "pl-c1" > c< / span > < span class = "pl-kos" > ;< / span > < span class = "pl-c1" > ++< / span > < span class = "pl-v" > C< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > {< / span >
< span class = "pl-k" > var< / span > < span class = "pl-s1" > cell_address< / span > < span class = "pl-c1" > =< / span > < span class = "pl-kos" > {< / span > < span class = "pl-c1" > c< / span > :< span class = "pl-v" > C< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > r< / span > :< span class = "pl-v" > R< / span > < span class = "pl-kos" > }< / span > < span class = "pl-kos" > ;< / span >
< span class = "pl-c" > /* if an A1-style address is needed, encode the address */< / span >
< span class = "pl-k" > var< / span > < span class = "pl-s1" > cell_ref< / 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" > encode_cell< / span > < span class = "pl-kos" > (< / span > < span class = "pl-s1" > cell_address< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ;< / span >
< span class = "pl-kos" > }< / span >
< span class = "pl-kos" > }< / span > < / pre > < / div >
2020-01-28 05:02:07 +00:00
< h3 >
< a id = "user-content-cell-object" class = "anchor" href = "#cell-object" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > Cell Object< / h3 >
< p > Cell objects are plain JS objects with keys and values following the convention:< / p >
< table >
< thead >
< tr >
< th > Key< / th >
< th > Description< / th >
< / tr >
< / thead >
< tbody >
< tr >
< td > < code > v< / code > < / td >
< td > raw value (see Data Types section for more info)< / td >
< / tr >
< tr >
< td > < code > w< / code > < / td >
< td > formatted text (if applicable)< / td >
< / tr >
< tr >
< td > < code > t< / code > < / td >
< td > type: < code > b< / code > Boolean, < code > e< / code > Error, < code > n< / code > Number, < code > d< / code > Date, < code > s< / code > Text, < code > z< / code > Stub< / td >
< / tr >
< tr >
< td > < code > f< / code > < / td >
< td > cell formula encoded as an A1-style string (if applicable)< / td >
< / tr >
< tr >
< td > < code > F< / code > < / td >
< td > range of enclosing array if formula is array formula (if applicable)< / td >
< / tr >
< tr >
< td > < code > r< / code > < / td >
< td > rich text encoding (if applicable)< / td >
< / tr >
< tr >
< td > < code > h< / code > < / td >
< td > HTML rendering of the rich text (if applicable)< / td >
< / tr >
< tr >
< td > < code > c< / code > < / td >
< td > comments associated with the cell< / td >
< / tr >
< tr >
< td > < code > z< / code > < / td >
< td > number format string associated with the cell (if requested)< / td >
< / tr >
< tr >
< td > < code > l< / code > < / td >
< td > cell hyperlink object (< code > .Target< / code > holds link, < code > .Tooltip< / code > is tooltip)< / td >
< / tr >
< tr >
< td > < code > s< / code > < / td >
< td > the style/theme of the cell (if applicable)< / td >
< / tr >
< / tbody >
< / table >
< p > Built-in export utilities (such as the CSV exporter) will use the < code > w< / code > text if it
is available. To change a value, be sure to delete < code > cell.w< / code > (or set it to
< code > undefined< / code > ) before attempting to export. The utilities will regenerate the < code > w< / code >
text from the number format (< code > cell.z< / code > ) and the raw value if possible.< / p >
< p > The actual array formula is stored in the < code > f< / code > field of the first cell in the
array range. Other cells in the range will omit the < code > f< / code > field.< / p >
< h4 >
< a id = "user-content-data-types" class = "anchor" href = "#data-types" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > Data Types< / h4 >
< p > The raw value is stored in the < code > v< / code > value property, interpreted based on the < code > t< / code >
type property. This separation allows for representation of numbers as well as
numeric text. There are 6 valid cell types:< / p >
< table >
< thead >
< tr >
< th align = "center" > Type< / th >
< th align = "left" > Description< / th >
< / tr >
< / thead >
< tbody >
< tr >
< td align = "center" > < code > b< / code > < / td >
< td align = "left" > Boolean: value interpreted as JS < code > boolean< / code >
< / td >
< / tr >
< tr >
< td align = "center" > < code > e< / code > < / td >
< td align = "left" > Error: value is a numeric code and < code > w< / code > property stores common name **< / td >
< / tr >
< tr >
< td align = "center" > < code > n< / code > < / td >
< td align = "left" > Number: value is a JS < code > number< / code > **< / td >
< / tr >
< tr >
< td align = "center" > < code > d< / code > < / td >
< td align = "left" > Date: value is a JS < code > Date< / code > object or string to be parsed as Date **< / td >
< / tr >
< tr >
< td align = "center" > < code > s< / code > < / td >
< td align = "left" > Text: value interpreted as JS < code > string< / code > and written as text **< / td >
< / tr >
< tr >
< td align = "center" > < code > z< / code > < / td >
< td align = "left" > Stub: blank stub cell that is ignored by data processing utilities **< / td >
< / tr >
< / tbody >
< / table >
< details >
< summary > < b > Error values and interpretation< / b > (click to show)< / summary >
< table >
< thead >
< tr >
< th align = "right" > Value< / th >
< th align = "left" > Error Meaning< / th >
< / tr >
< / thead >
< tbody >
< tr >
< td align = "right" > < code > 0x00< / code > < / td >
< td align = "left" > < code > #NULL!< / code > < / td >
< / tr >
< tr >
< td align = "right" > < code > 0x07< / code > < / td >
< td align = "left" > < code > #DIV/0!< / code > < / td >
< / tr >
< tr >
< td align = "right" > < code > 0x0F< / code > < / td >
< td align = "left" > < code > #VALUE!< / code > < / td >
< / tr >
< tr >
< td align = "right" > < code > 0x17< / code > < / td >
< td align = "left" > < code > #REF!< / code > < / td >
< / tr >
< tr >
< td align = "right" > < code > 0x1D< / code > < / td >
< td align = "left" > < code > #NAME?< / code > < / td >
< / tr >
< tr >
< td align = "right" > < code > 0x24< / code > < / td >
< td align = "left" > < code > #NUM!< / code > < / td >
< / tr >
< tr >
< td align = "right" > < code > 0x2A< / code > < / td >
< td align = "left" > < code > #N/A< / code > < / td >
< / tr >
< tr >
< td align = "right" > < code > 0x2B< / code > < / td >
< td align = "left" > < code > #GETTING_DATA< / code > < / td >
< / tr >
< / tbody >
< / table >
< / details >
< p > Type < code > n< / code > is the Number type. This includes all forms of data that Excel stores
as numbers, such as dates/times and Boolean fields. Excel exclusively uses data
that can be fit in an IEEE754 floating point number, just like JS Number, so the
< code > v< / code > field holds the raw number. The < code > w< / code > field holds formatted text. Dates are
stored as numbers by default and converted with < code > XLSX.SSF.parse_date_code< / code > .< / p >
< p > Type < code > d< / code > is the Date type, generated only when the option < code > cellDates< / code > is passed.
Since JSON does not have a natural Date type, parsers are generally expected to
store ISO 8601 Date strings like you would get from < code > date.toISOString()< / code > . On
the other hand, writers and exporters should be able to handle date strings and
JS Date objects. Note that Excel disregards timezone modifiers and treats all
dates in the local timezone. The library does not correct for this error.< / p >
< p > Type < code > s< / code > is the String type. Values are explicitly stored as text. Excel will
interpret these cells as "number stored as text". Generated Excel files
automatically suppress that class of error, but other formats may elicit errors.< / p >
< p > Type < code > z< / code > represents blank stub cells. They are generated in cases where cells
have no assigned value but hold comments or other metadata. They are ignored by
the core library data processing utility functions. By default these cells are
not generated; the parser < code > sheetStubs< / code > option must be set to < code > true< / code > .< / p >
< h4 >
< a id = "user-content-dates" class = "anchor" href = "#dates" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > Dates< / h4 >
< details >
< summary > < b > Excel Date Code details< / b > (click to show)< / summary >
< p > By default, Excel stores dates as numbers with a format code that specifies date
processing. For example, the date < code > 19-Feb-17< / code > is stored as the number < code > 42785< / code >
with a number format of < code > d-mmm-yy< / code > . The < code > SSF< / code > module understands number formats
and performs the appropriate conversion.< / p >
< p > XLSX also supports a special date type < code > d< / code > where the data is an ISO 8601 date
string. The formatter converts the date back to a number.< / p >
< p > The default behavior for all parsers is to generate number cells. Setting
< code > cellDates< / code > to true will force the generators to store dates.< / p >
< / details >
< details >
< summary > < b > Time Zones and Dates< / b > (click to show)< / summary >
< p > Excel has no native concept of universal time. All times are specified in the
local time zone. Excel limitations prevent specifying true absolute dates.< / p >
< p > Following Excel, this library treats all dates as relative to local time zone.< / p >
< / details >
< details >
< summary > < b > Epochs: 1900 and 1904< / b > (click to show)< / summary >
< p > Excel supports two epochs (January 1 1900 and January 1 1904), see
< a href = "http://support2.microsoft.com/kb/180162" rel = "nofollow" > "1900 vs. 1904 Date System" article< / a > .
The workbook's epoch can be determined by examining the workbook's
< code > wb.Workbook.WBProps.date1904< / code > property:< / p >
2021-08-27 00:16:16 +00:00
< div class = "highlight highlight-source-js" > < pre > < span class = "pl-c1" > !< / span > < span class = "pl-c1" > !< / span > < span class = "pl-kos" > (< / span > < span class = "pl-kos" > (< / span > < span class = "pl-kos" > (< / span > < span class = "pl-s1" > wb< / span > < span class = "pl-kos" > .< / span > < span class = "pl-c1" > Workbook< / span > < span class = "pl-c1" > ||< / 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" > WBProps< / span > < span class = "pl-c1" > ||< / 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" > date1904< / span > < span class = "pl-kos" > )< / span > < / pre > < / div >
2020-01-28 05:02:07 +00:00
< / details >
< h3 >
< a id = "user-content-sheet-objects" class = "anchor" href = "#sheet-objects" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > Sheet Objects< / h3 >
< p > Each key that does not start with < code > !< / code > maps to a cell (using < code > A-1< / code > notation)< / p >
< p > < code > sheet[address]< / code > returns the cell object for the specified address.< / p >
< p > < strong > Special sheet keys (accessible as < code > sheet[key]< / code > , each starting with < code > !< / code > ):< / strong > < / p >
< ul >
< li >
< p > < code > sheet['!ref']< / code > : A-1 based range representing the sheet range. Functions that
work with sheets should use this parameter to determine the range. Cells that
are assigned outside of the range are not processed. In particular, when
writing a sheet by hand, cells outside of the range are not included< / p >
< p > Functions that handle sheets should test for the presence of < code > !ref< / code > field.
If the < code > !ref< / code > is omitted or is not a valid range, functions are free to treat
the sheet as empty or attempt to guess the range. The standard utilities that
ship with this library treat sheets as empty (for example, the CSV output is
empty string).< / p >
< p > When reading a worksheet with the < code > sheetRows< / code > property set, the ref parameter
will use the restricted range. The original range is set at < code > ws['!fullref']< / code > < / p >
< / li >
< li >
< p > < code > sheet['!margins']< / code > : Object representing the page margins. The default values
follow Excel's "normal" preset. Excel also has a "wide" and a "narrow" preset
but they are stored as raw measurements. The main properties are listed below:< / p >
< / li >
< / ul >
< details >
< summary > < b > Page margin details< / b > (click to show)< / summary >
< table >
< thead >
< tr >
< th > key< / th >
< th > description< / th >
< th align = "left" > "normal"< / th >
< th align = "left" > "wide"< / th >
< th align = "left" > "narrow"< / th >
< / tr >
< / thead >
< tbody >
< tr >
< td > < code > left< / code > < / td >
< td > left margin (inches)< / td >
< td align = "left" > < code > 0.7< / code > < / td >
< td align = "left" > < code > 1.0< / code > < / td >
< td align = "left" > < code > 0.25< / code > < / td >
< / tr >
< tr >
< td > < code > right< / code > < / td >
< td > right margin (inches)< / td >
< td align = "left" > < code > 0.7< / code > < / td >
< td align = "left" > < code > 1.0< / code > < / td >
< td align = "left" > < code > 0.25< / code > < / td >
< / tr >
< tr >
< td > < code > top< / code > < / td >
< td > top margin (inches)< / td >
< td align = "left" > < code > 0.75< / code > < / td >
< td align = "left" > < code > 1.0< / code > < / td >
< td align = "left" > < code > 0.75< / code > < / td >
< / tr >
< tr >
< td > < code > bottom< / code > < / td >
< td > bottom margin (inches)< / td >
< td align = "left" > < code > 0.75< / code > < / td >
< td align = "left" > < code > 1.0< / code > < / td >
< td align = "left" > < code > 0.75< / code > < / td >
< / tr >
< tr >
< td > < code > header< / code > < / td >
< td > header margin (inches)< / td >
< td align = "left" > < code > 0.3< / code > < / td >
< td align = "left" > < code > 0.5< / code > < / td >
< td align = "left" > < code > 0.3< / code > < / td >
< / tr >
< tr >
< td > < code > footer< / code > < / td >
< td > footer margin (inches)< / td >
< td align = "left" > < code > 0.3< / code > < / td >
< td align = "left" > < code > 0.5< / code > < / td >
< td align = "left" > < code > 0.3< / code > < / td >
< / tr >
< / tbody >
< / table >
2021-08-27 00:16:16 +00:00
< div class = "highlight highlight-source-js" > < pre > < span class = "pl-c" > /* Set worksheet sheet to "normal" */< / span >
< span class = "pl-s1" > ws< / span > < span class = "pl-kos" > [< / span > < span class = "pl-s" > "!margins"< / span > < span class = "pl-kos" > ]< / span > < span class = "pl-c1" > =< / span > < span class = "pl-kos" > {< / span > < span class = "pl-c1" > left< / span > :< span class = "pl-c1" > 0.7< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > right< / span > :< span class = "pl-c1" > 0.7< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > top< / span > :< span class = "pl-c1" > 0.75< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > bottom< / span > :< span class = "pl-c1" > 0.75< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > header< / span > :< span class = "pl-c1" > 0.3< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > footer< / span > :< span class = "pl-c1" > 0.3< / span > < span class = "pl-kos" > }< / span >
< span class = "pl-c" > /* Set worksheet sheet to "wide" */< / span >
< span class = "pl-s1" > ws< / span > < span class = "pl-kos" > [< / span > < span class = "pl-s" > "!margins"< / span > < span class = "pl-kos" > ]< / span > < span class = "pl-c1" > =< / span > < span class = "pl-kos" > {< / span > < span class = "pl-c1" > left< / span > :< span class = "pl-c1" > 1.0< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > right< / span > :< span class = "pl-c1" > 1.0< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > top< / span > :< span class = "pl-c1" > 1.0< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > bottom< / span > :< span class = "pl-c1" > 1.0< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > header< / span > :< span class = "pl-c1" > 0.5< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > footer< / span > :< span class = "pl-c1" > 0.5< / span > < span class = "pl-kos" > }< / span >
< span class = "pl-c" > /* Set worksheet sheet to "narrow" */< / span >
< span class = "pl-s1" > ws< / span > < span class = "pl-kos" > [< / span > < span class = "pl-s" > "!margins"< / span > < span class = "pl-kos" > ]< / span > < span class = "pl-c1" > =< / span > < span class = "pl-kos" > {< / span > < span class = "pl-c1" > left< / span > :< span class = "pl-c1" > 0.25< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > right< / span > :< span class = "pl-c1" > 0.25< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > top< / span > :< span class = "pl-c1" > 0.75< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > bottom< / span > :< span class = "pl-c1" > 0.75< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > header< / span > :< span class = "pl-c1" > 0.3< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > footer< / span > :< span class = "pl-c1" > 0.3< / span > < span class = "pl-kos" > }< / span > < / pre > < / div >
2020-01-28 05:02:07 +00:00
< / details >
< h4 >
< a id = "user-content-worksheet-object" class = "anchor" href = "#worksheet-object" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > Worksheet Object< / h4 >
< p > In addition to the base sheet keys, worksheets also add:< / p >
< ul >
< li >
< p > < code > ws['!cols']< / code > : array of column properties objects. Column widths are actually
stored in files in a normalized manner, measured in terms of the "Maximum
Digit Width" (the largest width of the rendered digits 0-9, in pixels). When
parsed, the column objects store the pixel width in the < code > wpx< / code > field, character
width in the < code > wch< / code > field, and the maximum digit width in the < code > MDW< / code > field.< / p >
< / li >
< li >
< p > < code > ws['!rows']< / code > : array of row properties objects as explained later in the docs.
Each row object encodes properties including row height and visibility.< / p >
< / li >
< li >
< p > < code > ws['!merges']< / code > : array of range objects corresponding to the merged cells in
the worksheet. Plain text formats do not support merge cells. CSV export
will write all cells in the merge range if they exist, so be sure that only
the first cell (upper-left) in the range is set.< / p >
< / li >
< li >
2021-08-27 00:16:16 +00:00
< p > < code > ws['!outline']< / code > : configure how outlines should behave. Options default to
the default settings in Excel 2019:< / p >
< / li >
< / ul >
< table >
< thead >
< tr >
< th align = "left" > key< / th >
< th align = "left" > Excel feature< / th >
< th align = "left" > default< / th >
< / tr >
< / thead >
< tbody >
< tr >
< td align = "left" > < code > above< / code > < / td >
< td align = "left" > Uncheck "Summary rows below detail"< / td >
< td align = "left" > < code > false< / code > < / td >
< / tr >
< tr >
< td align = "left" > < code > left< / code > < / td >
< td align = "left" > Uncheck "Summary rows to the right of detail"< / td >
< td align = "left" > < code > false< / code > < / td >
< / tr >
< / tbody >
< / table >
< ul >
< li >
< code > ws['!protect']< / code > : object of write sheet protection properties. The < code > password< / code >
2020-01-28 05:02:07 +00:00
key specifies the password for formats that support password-protected sheets
(XLSX/XLSB/XLS). The writer uses the XOR obfuscation method. The following
keys control the sheet protection -- set to < code > false< / code > to enable a feature when
2021-08-27 00:16:16 +00:00
sheet is locked or set to < code > true< / code > to disable a feature:< / li >
2020-01-28 05:02:07 +00:00
< / ul >
< details >
< summary > < b > Worksheet Protection Details< / b > (click to show)< / summary >
< table >
< thead >
< tr >
< th align = "left" > key< / th >
< th align = "left" > feature (true=disabled / false=enabled)< / th >
< th align = "left" > default< / th >
< / tr >
< / thead >
< tbody >
< tr >
< td align = "left" > < code > selectLockedCells< / code > < / td >
< td align = "left" > Select locked cells< / td >
< td align = "left" > enabled< / td >
< / tr >
< tr >
< td align = "left" > < code > selectUnlockedCells< / code > < / td >
< td align = "left" > Select unlocked cells< / td >
< td align = "left" > enabled< / td >
< / tr >
< tr >
< td align = "left" > < code > formatCells< / code > < / td >
< td align = "left" > Format cells< / td >
< td align = "left" > disabled< / td >
< / tr >
< tr >
< td align = "left" > < code > formatColumns< / code > < / td >
< td align = "left" > Format columns< / td >
< td align = "left" > disabled< / td >
< / tr >
< tr >
< td align = "left" > < code > formatRows< / code > < / td >
< td align = "left" > Format rows< / td >
< td align = "left" > disabled< / td >
< / tr >
< tr >
< td align = "left" > < code > insertColumns< / code > < / td >
< td align = "left" > Insert columns< / td >
< td align = "left" > disabled< / td >
< / tr >
< tr >
< td align = "left" > < code > insertRows< / code > < / td >
< td align = "left" > Insert rows< / td >
< td align = "left" > disabled< / td >
< / tr >
< tr >
< td align = "left" > < code > insertHyperlinks< / code > < / td >
< td align = "left" > Insert hyperlinks< / td >
< td align = "left" > disabled< / td >
< / tr >
< tr >
< td align = "left" > < code > deleteColumns< / code > < / td >
< td align = "left" > Delete columns< / td >
< td align = "left" > disabled< / td >
< / tr >
< tr >
< td align = "left" > < code > deleteRows< / code > < / td >
< td align = "left" > Delete rows< / td >
< td align = "left" > disabled< / td >
< / tr >
< tr >
< td align = "left" > < code > sort< / code > < / td >
< td align = "left" > Sort< / td >
< td align = "left" > disabled< / td >
< / tr >
< tr >
< td align = "left" > < code > autoFilter< / code > < / td >
< td align = "left" > Filter< / td >
< td align = "left" > disabled< / td >
< / tr >
< tr >
< td align = "left" > < code > pivotTables< / code > < / td >
< td align = "left" > Use PivotTable reports< / td >
< td align = "left" > disabled< / td >
< / tr >
< tr >
< td align = "left" > < code > objects< / code > < / td >
< td align = "left" > Edit objects< / td >
< td align = "left" > enabled< / td >
< / tr >
< tr >
< td align = "left" > < code > scenarios< / code > < / td >
< td align = "left" > Edit scenarios< / td >
< td align = "left" > enabled< / td >
< / tr >
< / tbody >
< / table >
< / details >
< ul >
< li >
< code > ws['!autofilter']< / code > : AutoFilter object following the schema:< / li >
< / ul >
2021-08-27 00:16:16 +00:00
< div class = "highlight highlight-source-ts" > < pre > < span class = "pl-k" > type< / span > < span class = "pl-smi" > AutoFilter< / span > < span class = "pl-c1" > =< / span > < span class = "pl-kos" > {< / span >
< span class = "pl-c1" > ref< / span > :< span class = "pl-smi" > string< / span > < span class = "pl-kos" > ;< / span > < span class = "pl-c" > // A-1 based range representing the AutoFilter table range< / span >
< span class = "pl-kos" > }< / span > < / pre > < / div >
2020-01-28 05:02:07 +00:00
< h4 >
< a id = "user-content-chartsheet-object" class = "anchor" href = "#chartsheet-object" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > Chartsheet Object< / h4 >
< p > Chartsheets are represented as standard sheets. They are distinguished with the
< code > !type< / code > property set to < code > "chart"< / code > .< / p >
< p > The underlying data and < code > !ref< / code > refer to the cached data in the chartsheet. The
first row of the chartsheet is the underlying header.< / p >
< h4 >
< a id = "user-content-macrosheet-object" class = "anchor" href = "#macrosheet-object" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > Macrosheet Object< / h4 >
< p > Macrosheets are represented as standard sheets. They are distinguished with the
< code > !type< / code > property set to < code > "macro"< / code > .< / p >
< h4 >
< a id = "user-content-dialogsheet-object" class = "anchor" href = "#dialogsheet-object" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > Dialogsheet Object< / h4 >
< p > Dialogsheets are represented as standard sheets. They are distinguished with the
< code > !type< / code > property set to < code > "dialog"< / code > .< / p >
< h3 >
< a id = "user-content-workbook-object" class = "anchor" href = "#workbook-object" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > Workbook Object< / h3 >
< p > < code > workbook.SheetNames< / code > is an ordered list of the sheets in the workbook< / p >
< p > < code > wb.Sheets[sheetname]< / code > returns an object representing the worksheet.< / p >
< p > < code > wb.Props< / code > is an object storing the standard properties. < code > wb.Custprops< / code > stores
custom properties. Since the XLS standard properties deviate from the XLSX
standard, XLS parsing stores core properties in both places.< / p >
< p > < code > wb.Workbook< / code > stores < a href = "#workbook-level-attributes" > workbook-level attributes< / a > .< / p >
< h4 >
< a id = "user-content-workbook-file-properties" class = "anchor" href = "#workbook-file-properties" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > Workbook File Properties< / h4 >
< p > The various file formats use different internal names for file properties. The
workbook < code > Props< / code > object normalizes the names:< / p >
< details >
< summary > < b > File Properties< / b > (click to show)< / summary >
< table >
< thead >
< tr >
< th align = "left" > JS Name< / th >
< th align = "left" > Excel Description< / th >
< / tr >
< / thead >
< tbody >
< tr >
< td align = "left" > < code > Title< / code > < / td >
< td align = "left" > Summary tab "Title"< / td >
< / tr >
< tr >
< td align = "left" > < code > Subject< / code > < / td >
< td align = "left" > Summary tab "Subject"< / td >
< / tr >
< tr >
< td align = "left" > < code > Author< / code > < / td >
< td align = "left" > Summary tab "Author"< / td >
< / tr >
< tr >
< td align = "left" > < code > Manager< / code > < / td >
< td align = "left" > Summary tab "Manager"< / td >
< / tr >
< tr >
< td align = "left" > < code > Company< / code > < / td >
< td align = "left" > Summary tab "Company"< / td >
< / tr >
< tr >
< td align = "left" > < code > Category< / code > < / td >
< td align = "left" > Summary tab "Category"< / td >
< / tr >
< tr >
< td align = "left" > < code > Keywords< / code > < / td >
< td align = "left" > Summary tab "Keywords"< / td >
< / tr >
< tr >
< td align = "left" > < code > Comments< / code > < / td >
< td align = "left" > Summary tab "Comments"< / td >
< / tr >
< tr >
< td align = "left" > < code > LastAuthor< / code > < / td >
< td align = "left" > Statistics tab "Last saved by"< / td >
< / tr >
< tr >
< td align = "left" > < code > CreatedDate< / code > < / td >
< td align = "left" > Statistics tab "Created"< / td >
< / tr >
< / tbody >
< / table >
< / details >
< p > For example, to set the workbook title property:< / p >
2021-08-27 00:16:16 +00:00
< div class = "highlight highlight-source-js" > < pre > < span class = "pl-k" > if< / span > < span class = "pl-kos" > (< / span > < span class = "pl-c1" > !< / span > < span class = "pl-s1" > wb< / span > < span class = "pl-kos" > .< / span > < span class = "pl-c1" > Props< / span > < span class = "pl-kos" > )< / span > < span class = "pl-s1" > wb< / span > < span class = "pl-kos" > .< / span > < span class = "pl-c1" > Props< / span > < span class = "pl-c1" > =< / span > < span class = "pl-kos" > {< / span > < span class = "pl-kos" > }< / span > < span class = "pl-kos" > ;< / span >
< span class = "pl-s1" > wb< / span > < span class = "pl-kos" > .< / span > < span class = "pl-c1" > Props< / span > < span class = "pl-kos" > .< / span > < span class = "pl-c1" > Title< / span > < span class = "pl-c1" > =< / span > < span class = "pl-s" > "Insert Title Here"< / span > < span class = "pl-kos" > ;< / span > < / pre > < / div >
2020-01-28 05:02:07 +00:00
< p > Custom properties are added in the workbook < code > Custprops< / code > object:< / p >
2021-08-27 00:16:16 +00:00
< div class = "highlight highlight-source-js" > < pre > < span class = "pl-k" > if< / span > < span class = "pl-kos" > (< / span > < span class = "pl-c1" > !< / span > < span class = "pl-s1" > wb< / span > < span class = "pl-kos" > .< / span > < span class = "pl-c1" > Custprops< / span > < span class = "pl-kos" > )< / span > < span class = "pl-s1" > wb< / span > < span class = "pl-kos" > .< / span > < span class = "pl-c1" > Custprops< / span > < span class = "pl-c1" > =< / span > < span class = "pl-kos" > {< / span > < span class = "pl-kos" > }< / span > < span class = "pl-kos" > ;< / span >
< span class = "pl-s1" > wb< / span > < span class = "pl-kos" > .< / span > < span class = "pl-c1" > Custprops< / span > < span class = "pl-kos" > [< / span > < span class = "pl-s" > "Custom Property"< / span > < span class = "pl-kos" > ]< / span > < span class = "pl-c1" > =< / span > < span class = "pl-s" > "Custom Value"< / span > < span class = "pl-kos" > ;< / span > < / pre > < / div >
2020-01-28 05:02:07 +00:00
< p > Writers will process the < code > Props< / code > key of the options object:< / p >
2021-08-27 00:16:16 +00:00
< div class = "highlight highlight-source-js" > < pre > < span class = "pl-c" > /* force the Author to be "SheetJS" */< / span >
< span class = "pl-c1" > XLSX< / span > < span class = "pl-kos" > .< / span > < span class = "pl-en" > write< / span > < span class = "pl-kos" > (< / span > < span class = "pl-s1" > wb< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-kos" > {< / span > < span class = "pl-c1" > Props< / span > :< span class = "pl-kos" > {< / span > < span class = "pl-c1" > Author< / span > :< span class = "pl-s" > "SheetJS"< / span > < span class = "pl-kos" > }< / span > < span class = "pl-kos" > }< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ;< / span > < / pre > < / div >
2020-01-28 05:02:07 +00:00
< h3 >
< a id = "user-content-workbook-level-attributes" class = "anchor" href = "#workbook-level-attributes" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > Workbook-Level Attributes< / h3 >
< p > < code > wb.Workbook< / code > stores workbook-level attributes.< / p >
< h4 >
< a id = "user-content-defined-names" class = "anchor" href = "#defined-names" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > Defined Names< / h4 >
< p > < code > wb.Workbook.Names< / code > is an array of defined name objects which have the keys:< / p >
< details >
< summary > < b > Defined Name Properties< / b > (click to show)< / summary >
< table >
< thead >
< tr >
< th align = "left" > Key< / th >
< th align = "left" > Description< / th >
< / tr >
< / thead >
< tbody >
< tr >
< td align = "left" > < code > Sheet< / code > < / td >
< td align = "left" > Name scope. Sheet Index (0 = first sheet) or < code > null< / code > (Workbook)< / td >
< / tr >
< tr >
< td align = "left" > < code > Name< / code > < / td >
< td align = "left" > Case-sensitive name. Standard rules apply **< / td >
< / tr >
< tr >
< td align = "left" > < code > Ref< / code > < / td >
< td align = "left" > A1-style Reference (< code > "Sheet1!$A$1:$D$20"< / code > )< / td >
< / tr >
< tr >
< td align = "left" > < code > Comment< / code > < / td >
< td align = "left" > Comment (only applicable for XLS/XLSX/XLSB)< / td >
< / tr >
< / tbody >
< / table >
< / details >
< p > Excel allows two sheet-scoped defined names to share the same name. However, a
sheet-scoped name cannot collide with a workbook-scope name. Workbook writers
may not enforce this constraint.< / p >
< h4 >
< a id = "user-content-workbook-views" class = "anchor" href = "#workbook-views" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > Workbook Views< / h4 >
< p > < code > wb.Workbook.Views< / code > is an array of workbook view objects which have the keys:< / p >
< table >
< thead >
< tr >
< th align = "left" > Key< / th >
< th align = "left" > Description< / th >
< / tr >
< / thead >
< tbody >
< tr >
< td align = "left" > < code > RTL< / code > < / td >
< td align = "left" > If true, display right-to-left< / td >
< / tr >
< / tbody >
< / table >
< h4 >
< a id = "user-content-miscellaneous-workbook-properties" class = "anchor" href = "#miscellaneous-workbook-properties" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > Miscellaneous Workbook Properties< / h4 >
< p > < code > wb.Workbook.WBProps< / code > holds other workbook properties:< / p >
< table >
< thead >
< tr >
< th align = "left" > Key< / th >
< th align = "left" > Description< / th >
< / tr >
< / thead >
< tbody >
< tr >
< td align = "left" > < code > CodeName< / code > < / td >
< td align = "left" > < a href = "#vba-and-macros" > VBA Project Workbook Code Name< / a > < / td >
< / tr >
< tr >
< td align = "left" > < code > date1904< / code > < / td >
< td align = "left" > epoch: 0/false for 1900 system, 1/true for 1904< / td >
< / tr >
< tr >
< td align = "left" > < code > filterPrivacy< / code > < / td >
< td align = "left" > Warn or strip personally identifying info on save< / td >
< / tr >
< / tbody >
< / table >
< h3 >
< a id = "user-content-document-features" class = "anchor" href = "#document-features" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > Document Features< / h3 >
< p > Even for basic features like date storage, the official Excel formats store the
same content in different ways. The parsers are expected to convert from the
underlying file format representation to the Common Spreadsheet Format. Writers
are expected to convert from CSF back to the underlying file format.< / p >
< h4 >
< a id = "user-content-formulae" class = "anchor" href = "#formulae" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > Formulae< / h4 >
< p > The A1-style formula string is stored in the < code > f< / code > field. Even though different
file formats store the formulae in different ways, the formats are translated.
Even though some formats store formulae with a leading equal sign, CSF formulae
do not start with < code > =< / code > .< / p >
< details >
< summary > < b > Representation of A1=1, A2=2, A3=A1+A2< / b > (click to show)< / summary >
2021-08-27 00:16:16 +00:00
< div class = "highlight highlight-source-js" > < pre > < span class = "pl-kos" > {< / span >
< span class = "pl-s" > "!ref"< / span > : < span class = "pl-s" > "A1:A3"< / span > < span class = "pl-kos" > ,< / span >
< span class = "pl-c1" > A1< / span > : < span class = "pl-kos" > {< / span > < span class = "pl-c1" > t< / span > :< span class = "pl-s" > 'n'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > v< / span > :< span class = "pl-c1" > 1< / span > < span class = "pl-kos" > }< / span > < span class = "pl-kos" > ,< / span >
< span class = "pl-c1" > A2< / span > : < span class = "pl-kos" > {< / span > < span class = "pl-c1" > t< / span > :< span class = "pl-s" > 'n'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > v< / span > :< span class = "pl-c1" > 2< / span > < span class = "pl-kos" > }< / span > < span class = "pl-kos" > ,< / span >
< span class = "pl-c1" > A3< / span > : < span class = "pl-kos" > {< / span > < span class = "pl-c1" > t< / span > :< span class = "pl-s" > 'n'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > v< / span > :< span class = "pl-c1" > 3< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > f< / span > :< span class = "pl-s" > 'A1+A2'< / span > < span class = "pl-kos" > }< / span >
< span class = "pl-kos" > }< / span > < / pre > < / div >
2020-01-28 05:02:07 +00:00
< / details >
< p > Shared formulae are decompressed and each cell has the formula corresponding to
its cell. Writers generally do not attempt to generate shared formulae.< / p >
< p > Cells with formula entries but no value will be serialized in a way that Excel
and other spreadsheet tools will recognize. This library will not automatically
compute formula results! For example, to compute < code > BESSELJ< / code > in a worksheet:< / p >
< details >
< summary > < b > Formula without known value< / b > (click to show)< / summary >
2021-08-27 00:16:16 +00:00
< div class = "highlight highlight-source-js" > < pre > < span class = "pl-kos" > {< / span >
< span class = "pl-s" > "!ref"< / span > : < span class = "pl-s" > "A1:A3"< / span > < span class = "pl-kos" > ,< / span >
< span class = "pl-c1" > A1< / span > : < span class = "pl-kos" > {< / span > < span class = "pl-c1" > t< / span > :< span class = "pl-s" > 'n'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > v< / span > :< span class = "pl-c1" > 3.14159< / span > < span class = "pl-kos" > }< / span > < span class = "pl-kos" > ,< / span >
< span class = "pl-c1" > A2< / span > : < span class = "pl-kos" > {< / span > < span class = "pl-c1" > t< / span > :< span class = "pl-s" > 'n'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > v< / span > :< span class = "pl-c1" > 2< / span > < span class = "pl-kos" > }< / span > < span class = "pl-kos" > ,< / span >
< span class = "pl-c1" > A3< / span > : < span class = "pl-kos" > {< / span > < span class = "pl-c1" > t< / span > :< span class = "pl-s" > 'n'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > f< / span > :< span class = "pl-s" > 'BESSELJ(A1,A2)'< / span > < span class = "pl-kos" > }< / span >
< span class = "pl-kos" > }< / span > < / pre > < / div >
2020-01-28 05:02:07 +00:00
< / details >
< p > < strong > Array Formulae< / strong > < / p >
< p > Array formulae are stored in the top-left cell of the array block. All cells
of an array formula have a < code > F< / code > field corresponding to the range. A single-cell
formula can be distinguished from a plain formula by the presence of < code > F< / code > field.< / p >
< details >
< summary > < b > Array Formula examples< / b > (click to show)< / summary >
< p > For example, setting the cell < code > C1< / code > to the array formula < code > {=SUM(A1:A3*B1:B3)}< / code > :< / p >
2021-08-27 00:16:16 +00:00
< div class = "highlight highlight-source-js" > < pre > < span class = "pl-s1" > worksheet< / span > < span class = "pl-kos" > [< / span > < span class = "pl-s" > 'C1'< / span > < span class = "pl-kos" > ]< / span > < span class = "pl-c1" > =< / span > < span class = "pl-kos" > {< / span > < span class = "pl-c1" > t< / span > :< span class = "pl-s" > 'n'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > f< / span > : < span class = "pl-s" > "SUM(A1:A3*B1:B3)"< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > F< / span > :< span class = "pl-s" > "C1:C1"< / span > < span class = "pl-kos" > }< / span > < span class = "pl-kos" > ;< / span > < / pre > < / div >
2020-01-28 05:02:07 +00:00
< p > For a multi-cell array formula, every cell has the same array range but only the
first cell specifies the formula. Consider < code > D1:D3=A1:A3*B1:B3< / code > :< / p >
2021-08-27 00:16:16 +00:00
< div class = "highlight highlight-source-js" > < pre > < span class = "pl-s1" > worksheet< / span > < span class = "pl-kos" > [< / span > < span class = "pl-s" > 'D1'< / span > < span class = "pl-kos" > ]< / span > < span class = "pl-c1" > =< / span > < span class = "pl-kos" > {< / span > < span class = "pl-c1" > t< / span > :< span class = "pl-s" > 'n'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > F< / span > :< span class = "pl-s" > "D1:D3"< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > f< / span > :< span class = "pl-s" > "A1:A3*B1:B3"< / 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" > 'D2'< / span > < span class = "pl-kos" > ]< / span > < span class = "pl-c1" > =< / span > < span class = "pl-kos" > {< / span > < span class = "pl-c1" > t< / span > :< span class = "pl-s" > 'n'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > F< / span > :< span class = "pl-s" > "D1:D3"< / 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" > 'D3'< / span > < span class = "pl-kos" > ]< / span > < span class = "pl-c1" > =< / span > < span class = "pl-kos" > {< / span > < span class = "pl-c1" > t< / span > :< span class = "pl-s" > 'n'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > F< / span > :< span class = "pl-s" > "D1:D3"< / span > < span class = "pl-kos" > }< / span > < span class = "pl-kos" > ;< / span > < / pre > < / div >
2020-01-28 05:02:07 +00:00
< / details >
< p > Utilities and writers are expected to check for the presence of a < code > F< / code > field and
ignore any possible formula element < code > f< / code > in cells other than the starting cell.
They are not expected to perform validation of the formulae!< / p >
< details >
< summary > < b > Formula Output Utility Function< / b > (click to show)< / summary >
< p > The < code > sheet_to_formulae< / code > method generates one line per formula or array formula.
Array formulae are rendered in the form < code > range=formula< / code > while plain cells are
rendered in the form < code > cell=formula or value< / code > . Note that string literals are
prefixed with an apostrophe < code > '< / code > , consistent with Excel's formula bar display.< / p >
< / details >
< details >
< summary > < b > Formulae File Format Details< / b > (click to show)< / summary >
< table >
< thead >
< tr >
< th align = "left" > Storage Representation< / th >
< th align = "left" > Formats< / th >
< th align = "center" > Read< / th >
< th align = "center" > Write< / th >
< / tr >
< / thead >
< tbody >
< tr >
< td align = "left" > A1-style strings< / td >
< td align = "left" > XLSX< / td >
2021-08-27 00:16:16 +00:00
< td align = "center" > < g-emoji class = "g-emoji" alias = "o" fallback-src = "https://github.githubassets.com/images/icons/emoji/unicode/2b55.png" > ⭕< / g-emoji > < / td >
< td align = "center" > < g-emoji class = "g-emoji" alias = "o" fallback-src = "https://github.githubassets.com/images/icons/emoji/unicode/2b55.png" > ⭕< / g-emoji > < / td >
2020-01-28 05:02:07 +00:00
< / tr >
< tr >
< td align = "left" > RC-style strings< / td >
< td align = "left" > XLML and plain text< / td >
2021-08-27 00:16:16 +00:00
< td align = "center" > < g-emoji class = "g-emoji" alias = "o" fallback-src = "https://github.githubassets.com/images/icons/emoji/unicode/2b55.png" > ⭕< / g-emoji > < / td >
< td align = "center" > < g-emoji class = "g-emoji" alias = "o" fallback-src = "https://github.githubassets.com/images/icons/emoji/unicode/2b55.png" > ⭕< / g-emoji > < / td >
2020-01-28 05:02:07 +00:00
< / tr >
< tr >
< td align = "left" > BIFF Parsed formulae< / td >
< td align = "left" > XLSB and all XLS formats< / td >
2021-08-27 00:16:16 +00:00
< td align = "center" > < g-emoji class = "g-emoji" alias = "o" fallback-src = "https://github.githubassets.com/images/icons/emoji/unicode/2b55.png" > ⭕< / g-emoji > < / td >
2020-01-28 05:02:07 +00:00
< td align = "center" > < / td >
< / tr >
< tr >
< td align = "left" > OpenFormula formulae< / td >
< td align = "left" > ODS/FODS/UOS< / td >
2021-08-27 00:16:16 +00:00
< td align = "center" > < g-emoji class = "g-emoji" alias = "o" fallback-src = "https://github.githubassets.com/images/icons/emoji/unicode/2b55.png" > ⭕< / g-emoji > < / td >
< td align = "center" > < g-emoji class = "g-emoji" alias = "o" fallback-src = "https://github.githubassets.com/images/icons/emoji/unicode/2b55.png" > ⭕< / g-emoji > < / td >
2020-01-28 05:02:07 +00:00
< / tr >
< / tbody >
< / table >
< p > Since Excel prohibits named cells from colliding with names of A1 or RC style
cell references, a (not-so-simple) regex conversion is possible. BIFF Parsed
formulae have to be explicitly unwound. OpenFormula formulae can be converted
with regular expressions.< / p >
< / details >
< h4 >
< a id = "user-content-column-properties" class = "anchor" href = "#column-properties" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > Column Properties< / h4 >
< p > The < code > !cols< / code > array in each worksheet, if present, is a collection of < code > ColInfo< / code >
objects which have the following properties:< / p >
2021-08-27 00:16:16 +00:00
< div class = "highlight highlight-source-ts" > < pre > < span class = "pl-k" > type< / span > < span class = "pl-smi" > ColInfo< / span > < span class = "pl-c1" > =< / span > < span class = "pl-kos" > {< / span >
< span class = "pl-c" > /* visibility */< / span >
< span class = "pl-c1" > hidden< / span > ?: < span class = "pl-smi" > boolean< / span > < span class = "pl-kos" > ;< / span > < span class = "pl-c" > // if true, the column is hidden< / span >
2020-01-28 05:02:07 +00:00
2021-08-27 00:16:16 +00:00
< span class = "pl-c" > /* column width is specified in one of the following ways: */< / span >
< span class = "pl-c1" > wpx< / span > ?: < span class = "pl-smi" > number< / span > < span class = "pl-kos" > ;< / span > < span class = "pl-c" > // width in screen pixels< / span >
< span class = "pl-c1" > width< / span > ?: < span class = "pl-smi" > number< / span > < span class = "pl-kos" > ;< / span > < span class = "pl-c" > // width in Excel's "Max Digit Width", width*256 is integral< / span >
< span class = "pl-c1" > wch< / span > ?: < span class = "pl-smi" > number< / span > < span class = "pl-kos" > ;< / span > < span class = "pl-c" > // width in characters< / span >
2020-01-28 05:02:07 +00:00
2021-08-27 00:16:16 +00:00
< span class = "pl-c" > /* other fields for preserving features from files */< / span >
< span class = "pl-c1" > MDW< / span > ?: < span class = "pl-smi" > number< / span > < span class = "pl-kos" > ;< / span > < span class = "pl-c" > // Excel's "Max Digit Width" unit, always integral< / span >
< span class = "pl-kos" > }< / span > < span class = "pl-kos" > ;< / span > < / pre > < / div >
2020-01-28 05:02:07 +00:00
< details >
< summary > < b > Why are there three width types?< / b > (click to show)< / summary >
< p > There are three different width types corresponding to the three different ways
spreadsheets store column widths:< / p >
< p > SYLK and other plain text formats use raw character count. Contemporaneous tools
like Visicalc and Multiplan were character based. Since the characters had the
same width, it sufficed to store a count. This tradition was continued into the
BIFF formats.< / p >
< p > SpreadsheetML (2003) tried to align with HTML by standardizing on screen pixel
count throughout the file. Column widths, row heights, and other measures use
pixels. When the pixel and character counts do not align, Excel rounds values.< / p >
< p > XLSX internally stores column widths in a nebulous "Max Digit Width" form. The
Max Digit Width is the width of the largest digit when rendered (generally the
"0" character is the widest). The internal width must be an integer multiple of
the the width divided by 256. ECMA-376 describes a formula for converting
between pixels and the internal width. This represents a hybrid approach.< / p >
< p > Read functions attempt to populate all three properties. Write functions will
try to cycle specified values to the desired type. In order to avoid potential
conflicts, manipulation should delete the other properties first. For example,
when changing the pixel width, delete the < code > wch< / code > and < code > width< / code > properties.< / p >
< / details >
< details >
< summary > < b > Implementation details< / b > (click to show)< / summary >
< p > Given the constraints, it is possible to determine the MDW without actually
inspecting the font! The parsers guess the pixel width by converting from width
to pixels and back, repeating for all possible MDW and selecting the MDW that
minimizes the error. XLML actually stores the pixel width, so the guess works
in the opposite direction.< / p >
< p > Even though all of the information is made available, writers are expected to
follow the priority order:< / p >
< ol >
< li > use < code > width< / code > field if available< / li >
< li > use < code > wpx< / code > pixel width if available< / li >
< li > use < code > wch< / code > character count if available< / li >
< / ol >
< / details >
< h4 >
< a id = "user-content-row-properties" class = "anchor" href = "#row-properties" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > Row Properties< / h4 >
< p > The < code > !rows< / code > array in each worksheet, if present, is a collection of < code > RowInfo< / code >
objects which have the following properties:< / p >
2021-08-27 00:16:16 +00:00
< div class = "highlight highlight-source-ts" > < pre > < span class = "pl-k" > type< / span > < span class = "pl-smi" > RowInfo< / span > < span class = "pl-c1" > =< / span > < span class = "pl-kos" > {< / span >
< span class = "pl-c" > /* visibility */< / span >
< span class = "pl-c1" > hidden< / span > ?: < span class = "pl-smi" > boolean< / span > < span class = "pl-kos" > ;< / span > < span class = "pl-c" > // if true, the row is hidden< / span >
2020-01-28 05:02:07 +00:00
2021-08-27 00:16:16 +00:00
< span class = "pl-c" > /* row height is specified in one of the following ways: */< / span >
< span class = "pl-c1" > hpx< / span > ?: < span class = "pl-smi" > number< / span > < span class = "pl-kos" > ;< / span > < span class = "pl-c" > // height in screen pixels< / span >
< span class = "pl-c1" > hpt< / span > ?: < span class = "pl-smi" > number< / span > < span class = "pl-kos" > ;< / span > < span class = "pl-c" > // height in points< / span >
2020-01-28 05:02:07 +00:00
2021-08-27 00:16:16 +00:00
< span class = "pl-c1" > level< / span > ?: < span class = "pl-smi" > number< / span > < span class = "pl-kos" > ;< / span > < span class = "pl-c" > // 0-indexed outline / group level< / span >
< span class = "pl-kos" > }< / span > < span class = "pl-kos" > ;< / span > < / pre > < / div >
2020-01-28 05:02:07 +00:00
< p > Note: Excel UI displays the base outline level as < code > 1< / code > and the max level as < code > 8< / code > .
The < code > level< / code > field stores the base outline as < code > 0< / code > and the max level as < code > 7< / code > .< / p >
< details >
< summary > < b > Implementation details< / b > (click to show)< / summary >
< p > Excel internally stores row heights in points. The default resolution is 72 DPI
or 96 PPI, so the pixel and point size should agree. For different resolutions
they may not agree, so the library separates the concepts.< / p >
< p > Even though all of the information is made available, writers are expected to
follow the priority order:< / p >
< ol >
< li > use < code > hpx< / code > pixel height if available< / li >
< li > use < code > hpt< / code > point height if available< / li >
< / ol >
< / details >
< h4 >
< a id = "user-content-number-formats" class = "anchor" href = "#number-formats" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > Number Formats< / h4 >
< p > The < code > cell.w< / code > formatted text for each cell is produced from < code > cell.v< / code > and < code > cell.z< / code >
format. If the format is not specified, the Excel < code > General< / code > format is used.
The format can either be specified as a string or as an index into the format
table. Parsers are expected to populate < code > workbook.SSF< / code > with the number format
table. Writers are expected to serialize the table.< / p >
< p > Custom tools should ensure that the local table has each used format string
somewhere in the table. Excel convention mandates that the custom formats start
at index 164. The following example creates a custom format from scratch:< / p >
< details >
< summary > < b > New worksheet with custom format< / b > (click to show)< / summary >
2021-08-27 00:16:16 +00:00
< div class = "highlight highlight-source-js" > < pre > < span class = "pl-k" > var< / span > < span class = "pl-s1" > wb< / span > < span class = "pl-c1" > =< / span > < span class = "pl-kos" > {< / span >
< span class = "pl-c1" > SheetNames< / 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" > Sheets< / span > : < span class = "pl-kos" > {< / span >
< span class = "pl-c1" > Sheet1< / span > : < span class = "pl-kos" > {< / span >
< span class = "pl-s" > "!ref"< / span > :< span class = "pl-s" > "A1:C1"< / span > < span class = "pl-kos" > ,< / span >
< span class = "pl-c1" > A1< / span > : < span class = "pl-kos" > {< / span > < span class = "pl-c1" > t< / span > :< span class = "pl-s" > "n"< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > v< / span > :< span class = "pl-c1" > 10000< / span > < span class = "pl-kos" > }< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c" > // < -- General format< / span >
< span class = "pl-c1" > B1< / span > : < span class = "pl-kos" > {< / span > < span class = "pl-c1" > t< / span > :< span class = "pl-s" > "n"< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > v< / span > :< span class = "pl-c1" > 10000< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > z< / span > : < span class = "pl-s" > "0%"< / span > < span class = "pl-kos" > }< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c" > // < -- Builtin format< / span >
< span class = "pl-c1" > C1< / span > : < span class = "pl-kos" > {< / span > < span class = "pl-c1" > t< / span > :< span class = "pl-s" > "n"< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > v< / span > :< span class = "pl-c1" > 10000< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > z< / span > : < span class = "pl-s" > "\"T\"\ #0.00"< / span > < span class = "pl-kos" > }< / span > < span class = "pl-c" > // < -- Custom format< / span >
< span class = "pl-kos" > }< / span >
< span class = "pl-kos" > }< / span >
< span class = "pl-kos" > }< / span > < / pre > < / div >
2020-01-28 05:02:07 +00:00
< / details >
< p > The rules are slightly different from how Excel displays custom number formats.
In particular, literal characters must be wrapped in double quotes or preceded
by a backslash. For more info, see the Excel documentation article
< code > Create or delete a custom number format< / code > or ECMA-376 18.8.31 (Number Formats)< / p >
< details >
< summary > < b > Default Number Formats< / b > (click to show)< / summary >
< p > The default formats are listed in ECMA-376 18.8.30:< / p >
< table >
< thead >
< tr >
< th align = "right" > ID< / th >
< th align = "left" > Format< / th >
< / tr >
< / thead >
< tbody >
< tr >
< td align = "right" > 0< / td >
< td align = "left" > < code > General< / code > < / td >
< / tr >
< tr >
< td align = "right" > 1< / td >
< td align = "left" > < code > 0< / code > < / td >
< / tr >
< tr >
< td align = "right" > 2< / td >
< td align = "left" > < code > 0.00< / code > < / td >
< / tr >
< tr >
< td align = "right" > 3< / td >
< td align = "left" > < code > #,##0< / code > < / td >
< / tr >
< tr >
< td align = "right" > 4< / td >
< td align = "left" > < code > #,##0.00< / code > < / td >
< / tr >
< tr >
< td align = "right" > 9< / td >
< td align = "left" > < code > 0%< / code > < / td >
< / tr >
< tr >
< td align = "right" > 10< / td >
< td align = "left" > < code > 0.00%< / code > < / td >
< / tr >
< tr >
< td align = "right" > 11< / td >
< td align = "left" > < code > 0.00E+00< / code > < / td >
< / tr >
< tr >
< td align = "right" > 12< / td >
< td align = "left" > < code > # ?/?< / code > < / td >
< / tr >
< tr >
< td align = "right" > 13< / td >
< td align = "left" > < code > # ??/??< / code > < / td >
< / tr >
< tr >
< td align = "right" > 14< / td >
< td align = "left" >
< code > m/d/yy< / code > (see below)< / td >
< / tr >
< tr >
< td align = "right" > 15< / td >
< td align = "left" > < code > d-mmm-yy< / code > < / td >
< / tr >
< tr >
< td align = "right" > 16< / td >
< td align = "left" > < code > d-mmm< / code > < / td >
< / tr >
< tr >
< td align = "right" > 17< / td >
< td align = "left" > < code > mmm-yy< / code > < / td >
< / tr >
< tr >
< td align = "right" > 18< / td >
< td align = "left" > < code > h:mm AM/PM< / code > < / td >
< / tr >
< tr >
< td align = "right" > 19< / td >
< td align = "left" > < code > h:mm:ss AM/PM< / code > < / td >
< / tr >
< tr >
< td align = "right" > 20< / td >
< td align = "left" > < code > h:mm< / code > < / td >
< / tr >
< tr >
< td align = "right" > 21< / td >
< td align = "left" > < code > h:mm:ss< / code > < / td >
< / tr >
< tr >
< td align = "right" > 22< / td >
< td align = "left" > < code > m/d/yy h:mm< / code > < / td >
< / tr >
< tr >
< td align = "right" > 37< / td >
< td align = "left" > < code > #,##0 ;(#,##0)< / code > < / td >
< / tr >
< tr >
< td align = "right" > 38< / td >
< td align = "left" > < code > #,##0 ;[Red](#,##0)< / code > < / td >
< / tr >
< tr >
< td align = "right" > 39< / td >
< td align = "left" > < code > #,##0.00;(#,##0.00)< / code > < / td >
< / tr >
< tr >
< td align = "right" > 40< / td >
< td align = "left" > < code > #,##0.00;[Red](#,##0.00)< / code > < / td >
< / tr >
< tr >
< td align = "right" > 45< / td >
< td align = "left" > < code > mm:ss< / code > < / td >
< / tr >
< tr >
< td align = "right" > 46< / td >
< td align = "left" > < code > [h]:mm:ss< / code > < / td >
< / tr >
< tr >
< td align = "right" > 47< / td >
< td align = "left" > < code > mmss.0< / code > < / td >
< / tr >
< tr >
< td align = "right" > 48< / td >
< td align = "left" > < code > ##0.0E+0< / code > < / td >
< / tr >
< tr >
< td align = "right" > 49< / td >
< td align = "left" > < code > @< / code > < / td >
< / tr >
< / tbody >
< / table >
< / details >
< p > Format 14 (< code > m/d/yy< / code > ) is localized by Excel: even though the file specifies that
number format, it will be drawn differently based on system settings. It makes
sense when the producer and consumer of files are in the same locale, but that
is not always the case over the Internet. To get around this ambiguity, parse
functions accept the < code > dateNF< / code > option to override the interpretation of that
specific format string.< / p >
< h4 >
< a id = "user-content-hyperlinks" class = "anchor" href = "#hyperlinks" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > Hyperlinks< / h4 >
< p > Hyperlinks are stored in the < code > l< / code > key of cell objects. The < code > Target< / code > field of the
hyperlink object is the target of the link, including the URI fragment. Tooltips
are stored in the < code > Tooltip< / code > field and are displayed when you move your mouse
over the text.< / p >
< p > For example, the following snippet creates a link from cell < code > A3< / code > to
< a href = "http://sheetjs.com" rel = "nofollow" > http://sheetjs.com< / a > with the tip < code > "Find us @ SheetJS.com!"< / code > :< / p >
2021-08-27 00:16:16 +00:00
< div class = "highlight highlight-source-js" > < pre > < span class = "pl-s1" > ws< / span > < span class = "pl-kos" > [< / span > < span class = "pl-s" > 'A3'< / span > < span class = "pl-kos" > ]< / span > < span class = "pl-kos" > .< / span > < span class = "pl-c1" > l< / span > < span class = "pl-c1" > =< / span > < span class = "pl-kos" > {< / span > < span class = "pl-c1" > Target< / span > :< span class = "pl-s" > "http://sheetjs.com"< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > Tooltip< / span > :< span class = "pl-s" > "Find us @ SheetJS.com!"< / span > < span class = "pl-kos" > }< / span > < span class = "pl-kos" > ;< / span > < / pre > < / div >
2020-01-28 05:02:07 +00:00
< p > Note that Excel does not automatically style hyperlinks -- they will generally
be displayed as normal text.< / p >
< p > Links where the target is a cell or range or defined name in the same workbook
("Internal Links") are marked with a leading hash character:< / p >
2021-08-27 00:16:16 +00:00
< div class = "highlight highlight-source-js" > < pre > < span class = "pl-s1" > ws< / span > < span class = "pl-kos" > [< / span > < span class = "pl-s" > 'A2'< / span > < span class = "pl-kos" > ]< / span > < span class = "pl-kos" > .< / span > < span class = "pl-c1" > l< / span > < span class = "pl-c1" > =< / span > < span class = "pl-kos" > {< / span > < span class = "pl-c1" > Target< / span > :< span class = "pl-s" > "#E2"< / span > < span class = "pl-kos" > }< / span > < span class = "pl-kos" > ;< / span > < span class = "pl-c" > /* link to cell E2 */< / span > < / pre > < / div >
2020-01-28 05:02:07 +00:00
< h4 >
< a id = "user-content-cell-comments" class = "anchor" href = "#cell-comments" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > Cell Comments< / h4 >
< p > Cell comments are objects stored in the < code > c< / code > array of cell objects. The actual
contents of the comment are split into blocks based on the comment author. The
< code > a< / code > field of each comment object is the author of the comment and the < code > t< / code > field
is the plain text representation.< / p >
< p > For example, the following snippet appends a cell comment into cell < code > A1< / code > :< / p >
2021-08-27 00:16:16 +00:00
< div class = "highlight highlight-source-js" > < pre > < span class = "pl-k" > if< / span > < span class = "pl-kos" > (< / span > < span class = "pl-c1" > !< / span > < span class = "pl-s1" > ws< / span > < span class = "pl-kos" > .< / span > < span class = "pl-c1" > A1< / span > < span class = "pl-kos" > .< / span > < span class = "pl-c1" > c< / span > < span class = "pl-kos" > )< / span > < span class = "pl-s1" > ws< / span > < span class = "pl-kos" > .< / span > < span class = "pl-c1" > A1< / span > < span class = "pl-kos" > .< / span > < span class = "pl-c1" > c< / span > < span class = "pl-c1" > =< / span > < span class = "pl-kos" > [< / span > < span class = "pl-kos" > ]< / span > < span class = "pl-kos" > ;< / span >
< span class = "pl-s1" > ws< / span > < span class = "pl-kos" > .< / span > < span class = "pl-c1" > A1< / span > < span class = "pl-kos" > .< / span > < span class = "pl-c1" > c< / span > < span class = "pl-kos" > .< / span > < span class = "pl-en" > push< / span > < span class = "pl-kos" > (< / span > < span class = "pl-kos" > {< / span > < span class = "pl-c1" > a< / span > :< span class = "pl-s" > "SheetJS"< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > t< / span > :< span class = "pl-s" > "I'm a little comment, short and stout!"< / span > < span class = "pl-kos" > }< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ;< / span > < / pre > < / div >
2020-01-28 05:02:07 +00:00
< p > Note: XLSB enforces a 54 character limit on the Author name. Names longer than
54 characters may cause issues with other formats.< / p >
< p > To mark a comment as normally hidden, set the < code > hidden< / code > property:< / p >
2021-08-27 00:16:16 +00:00
< div class = "highlight highlight-source-js" > < pre > < span class = "pl-k" > if< / span > < span class = "pl-kos" > (< / span > < span class = "pl-c1" > !< / span > < span class = "pl-s1" > ws< / span > < span class = "pl-kos" > .< / span > < span class = "pl-c1" > A1< / span > < span class = "pl-kos" > .< / span > < span class = "pl-c1" > c< / span > < span class = "pl-kos" > )< / span > < span class = "pl-s1" > ws< / span > < span class = "pl-kos" > .< / span > < span class = "pl-c1" > A1< / span > < span class = "pl-kos" > .< / span > < span class = "pl-c1" > c< / span > < span class = "pl-c1" > =< / span > < span class = "pl-kos" > [< / span > < span class = "pl-kos" > ]< / span > < span class = "pl-kos" > ;< / span >
< span class = "pl-s1" > ws< / span > < span class = "pl-kos" > .< / span > < span class = "pl-c1" > A1< / span > < span class = "pl-kos" > .< / span > < span class = "pl-c1" > c< / span > < span class = "pl-kos" > .< / span > < span class = "pl-en" > push< / span > < span class = "pl-kos" > (< / span > < span class = "pl-kos" > {< / span > < span class = "pl-c1" > a< / span > :< span class = "pl-s" > "SheetJS"< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > t< / span > :< span class = "pl-s" > "This comment is visible"< / span > < span class = "pl-kos" > }< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ;< / span >
2020-01-28 05:02:07 +00:00
2021-08-27 00:16:16 +00:00
< span class = "pl-k" > if< / span > < span class = "pl-kos" > (< / span > < span class = "pl-c1" > !< / span > < span class = "pl-s1" > ws< / span > < span class = "pl-kos" > .< / span > < span class = "pl-c1" > A2< / span > < span class = "pl-kos" > .< / span > < span class = "pl-c1" > c< / span > < span class = "pl-kos" > )< / span > < span class = "pl-s1" > ws< / span > < span class = "pl-kos" > .< / span > < span class = "pl-c1" > A2< / span > < span class = "pl-kos" > .< / span > < span class = "pl-c1" > c< / span > < span class = "pl-c1" > =< / span > < span class = "pl-kos" > [< / span > < span class = "pl-kos" > ]< / span > < span class = "pl-kos" > ;< / span >
< span class = "pl-s1" > ws< / span > < span class = "pl-kos" > .< / span > < span class = "pl-c1" > A2< / span > < span class = "pl-kos" > .< / span > < span class = "pl-c1" > c< / span > < span class = "pl-kos" > .< / span > < span class = "pl-c1" > hidden< / span > < span class = "pl-c1" > =< / span > < span class = "pl-c1" > true< / span > < span class = "pl-kos" > ;< / span >
< span class = "pl-s1" > ws< / span > < span class = "pl-kos" > .< / span > < span class = "pl-c1" > A2< / span > < span class = "pl-kos" > .< / span > < span class = "pl-c1" > c< / span > < span class = "pl-kos" > .< / span > < span class = "pl-en" > push< / span > < span class = "pl-kos" > (< / span > < span class = "pl-kos" > {< / span > < span class = "pl-c1" > a< / span > :< span class = "pl-s" > "SheetJS"< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > t< / span > :< span class = "pl-s" > "This comment will be hidden"< / span > < span class = "pl-kos" > }< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ;< / span > < / pre > < / div >
2020-01-28 05:02:07 +00:00
< h4 >
< a id = "user-content-sheet-visibility" class = "anchor" href = "#sheet-visibility" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > Sheet Visibility< / h4 >
< p > Excel enables hiding sheets in the lower tab bar. The sheet data is stored in
the file but the UI does not readily make it available. Standard hidden sheets
are revealed in the "Unhide" menu. Excel also has "very hidden" sheets which
cannot be revealed in the menu. It is only accessible in the VB Editor!< / p >
< p > The visibility setting is stored in the < code > Hidden< / code > property of sheet props array.< / p >
< details >
< summary > < b > More details< / b > (click to show)< / summary >
< table >
< thead >
< tr >
< th align = "center" > Value< / th >
< th align = "left" > Definition< / th >
< / tr >
< / thead >
< tbody >
< tr >
< td align = "center" > 0< / td >
< td align = "left" > Visible< / td >
< / tr >
< tr >
< td align = "center" > 1< / td >
< td align = "left" > Hidden< / td >
< / tr >
< tr >
< td align = "center" > 2< / td >
< td align = "left" > Very Hidden< / td >
< / tr >
< / tbody >
< / table >
2021-08-27 00:16:16 +00:00
< p > With < a href = "https://rawgit.com/SheetJS/test_files/HEAD/sheet_visibility.xlsx" rel = "nofollow" > https://rawgit.com/SheetJS/test_files/HEAD/sheet_visibility.xlsx< / a > :< / p >
< div class = "highlight highlight-source-js" > < pre > < span class = "pl-c1" > > < / span > < span class = "pl-s1" > wb< / span > < span class = "pl-kos" > .< / span > < span class = "pl-c1" > Workbook< / span > < span class = "pl-kos" > .< / span > < span class = "pl-c1" > Sheets< / span > < span class = "pl-kos" > .< / span > < span class = "pl-en" > map< / span > < span class = "pl-kos" > (< / span > < span class = "pl-k" > function< / span > < span class = "pl-kos" > (< / span > < span class = "pl-s1" > x< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > {< / span > < span class = "pl-k" > return< / span > < span class = "pl-kos" > [< / span > < span class = "pl-s1" > x< / span > < span class = "pl-kos" > .< / span > < span class = "pl-c1" > name< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s1" > x< / span > < span class = "pl-kos" > .< / span > < span class = "pl-c1" > Hidden< / 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-s" > 'Visible'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > 0< / span > < span class = "pl-kos" > ]< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-kos" > [< / span > < span class = "pl-s" > 'Hidden'< / span > < span class = "pl-kos" > ,< / 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-s" > 'VeryHidden'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > 2< / span > < span class = "pl-kos" > ]< / span > < span class = "pl-kos" > ]< / span > < / pre > < / div >
2020-01-28 05:02:07 +00:00
< p > Non-Excel formats do not support the Very Hidden state. The best way to test
if a sheet is visible is to check if the < code > Hidden< / code > property is logical truth:< / p >
2021-08-27 00:16:16 +00:00
< div class = "highlight highlight-source-js" > < pre > < span class = "pl-c1" > > < / span > < span class = "pl-s1" > wb< / span > < span class = "pl-kos" > .< / span > < span class = "pl-c1" > Workbook< / span > < span class = "pl-kos" > .< / span > < span class = "pl-c1" > Sheets< / span > < span class = "pl-kos" > .< / span > < span class = "pl-en" > map< / span > < span class = "pl-kos" > (< / span > < span class = "pl-k" > function< / span > < span class = "pl-kos" > (< / span > < span class = "pl-s1" > x< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > {< / span > < span class = "pl-k" > return< / span > < span class = "pl-kos" > [< / span > < span class = "pl-s1" > x< / span > < span class = "pl-kos" > .< / span > < span class = "pl-c1" > name< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > !< / span > < span class = "pl-s1" > x< / span > < span class = "pl-kos" > .< / span > < span class = "pl-c1" > Hidden< / 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-s" > 'Visible'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > true< / span > < span class = "pl-kos" > ]< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-kos" > [< / span > < span class = "pl-s" > 'Hidden'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > false< / span > < span class = "pl-kos" > ]< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-kos" > [< / span > < span class = "pl-s" > 'VeryHidden'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > false< / span > < span class = "pl-kos" > ]< / span > < span class = "pl-kos" > ]< / span > < / pre > < / div >
2020-01-28 05:02:07 +00:00
< / details >
< h4 >
< a id = "user-content-vba-and-macros" class = "anchor" href = "#vba-and-macros" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > VBA and Macros< / h4 >
< p > VBA Macros are stored in a special data blob that is exposed in the < code > vbaraw< / code >
property of the workbook object when the < code > bookVBA< / code > option is < code > true< / code > . They are
supported in < code > XLSM< / code > , < code > XLSB< / code > , and < code > BIFF8 XLS< / code > formats. The supported format
writers automatically insert the data blobs if it is present in the workbook and
associate with the worksheet names.< / p >
< details >
< summary > < b > Custom Code Names< / b > (click to show)< / summary >
< p > The workbook code name is stored in < code > wb.Workbook.WBProps.CodeName< / code > . By default,
Excel will write < code > ThisWorkbook< / code > or a translated phrase like < code > DieseArbeitsmappe< / code > .
Worksheet and Chartsheet code names are in the worksheet properties object at
< code > wb.Workbook.Sheets[i].CodeName< / code > . Macrosheets and Dialogsheets are ignored.< / p >
< p > The readers and writers preserve the code names, but they have to be manually
set when adding a VBA blob to a different workbook.< / p >
< / details >
< details >
< summary > < b > Macrosheets< / b > (click to show)< / summary >
< p > Older versions of Excel also supported a non-VBA "macrosheet" sheet type that
stored automation commands. These are exposed in objects with the < code > !type< / code >
property set to < code > "macro"< / code > .< / p >
< / details >
< details >
< summary > < b > Detecting macros in workbooks< / b > (click to show)< / summary >
< p > The < code > vbaraw< / code > field will only be set if macros are present, so testing is simple:< / p >
2021-08-27 00:16:16 +00:00
< div class = "highlight highlight-source-js" > < pre > < span class = "pl-k" > function< / span > < span class = "pl-en" > wb_has_macro< / span > < span class = "pl-kos" > (< / span > < span class = "pl-s1" > wb< / span > < span class = "pl-c" > /*:workbook*/< / span > < span class = "pl-kos" > )< / span > < span class = "pl-c" > /*:boolean*/< / span > < span class = "pl-kos" > {< / span >
< span class = "pl-k" > if< / span > < span class = "pl-kos" > (< / span > < span class = "pl-c1" > !< / span > < span class = "pl-c1" > !< / span > < span class = "pl-s1" > wb< / span > < span class = "pl-kos" > .< / span > < span class = "pl-c1" > vbaraw< / span > < span class = "pl-kos" > )< / span > < span class = "pl-k" > return< / span > < span class = "pl-c1" > true< / span > < span class = "pl-kos" > ;< / span >
< span class = "pl-k" > const< / span > < span class = "pl-s1" > sheets< / span > < span class = "pl-c1" > =< / span > < span class = "pl-s1" > wb< / span > < span class = "pl-kos" > .< / span > < span class = "pl-c1" > SheetNames< / span > < span class = "pl-kos" > .< / span > < span class = "pl-en" > map< / span > < span class = "pl-kos" > (< / span > < span class = "pl-kos" > (< / span > < span class = "pl-s1" > n< / span > < span class = "pl-kos" > )< / span > < span class = "pl-c1" > => < / span > < span class = "pl-s1" > wb< / span > < span class = "pl-kos" > .< / span > < span class = "pl-c1" > Sheets< / span > < span class = "pl-kos" > [< / span > < span class = "pl-s1" > n< / span > < span class = "pl-kos" > ]< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ;< / span >
< span class = "pl-k" > return< / span > < span class = "pl-s1" > sheets< / span > < span class = "pl-kos" > .< / span > < span class = "pl-en" > some< / span > < span class = "pl-kos" > (< / span > < span class = "pl-kos" > (< / span > < span class = "pl-s1" > ws< / span > < span class = "pl-kos" > )< / span > < span class = "pl-c1" > => < / span > < span class = "pl-c1" > !< / span > < span class = "pl-c1" > !< / span > < span class = "pl-s1" > ws< / span > < span class = "pl-c1" > & & < / span > < span class = "pl-s1" > ws< / span > < span class = "pl-kos" > [< / span > < span class = "pl-s" > '!type'< / span > < span class = "pl-kos" > ]< / span > < span class = "pl-c1" > ==< / span > < span class = "pl-s" > 'macro'< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ;< / span >
< span class = "pl-kos" > }< / span > < / pre > < / div >
2020-01-28 05:02:07 +00:00
< / details >
< h2 >
< a id = "user-content-parsing-options" class = "anchor" href = "#parsing-options" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > Parsing Options< / h2 >
< p > The exported < code > read< / code > and < code > readFile< / code > functions accept an options argument:< / p >
< table >
< thead >
< tr >
< th align = "left" > Option Name< / th >
< th align = "right" > Default< / th >
< th align = "left" > Description< / th >
< / tr >
< / thead >
< tbody >
< tr >
< td align = "left" > < code > type< / code > < / td >
< td align = "right" > < / td >
< td align = "left" > Input data encoding (see Input Type below)< / td >
< / tr >
< tr >
< td align = "left" > < code > raw< / code > < / td >
< td align = "right" > false< / td >
< td align = "left" > If true, plain text parsing will not parse values **< / td >
< / tr >
< tr >
< td align = "left" > < code > codepage< / code > < / td >
< td align = "right" > < / td >
< td align = "left" > If specified, use code page when appropriate **< / td >
< / tr >
< tr >
< td align = "left" > < code > cellFormula< / code > < / td >
< td align = "right" > true< / td >
< td align = "left" > Save formulae to the .f field< / td >
< / tr >
< tr >
< td align = "left" > < code > cellHTML< / code > < / td >
< td align = "right" > true< / td >
< td align = "left" > Parse rich text and save HTML to the < code > .h< / code > field< / td >
< / tr >
< tr >
< td align = "left" > < code > cellNF< / code > < / td >
< td align = "right" > false< / td >
< td align = "left" > Save number format string to the < code > .z< / code > field< / td >
< / tr >
< tr >
< td align = "left" > < code > cellStyles< / code > < / td >
< td align = "right" > false< / td >
< td align = "left" > Save style/theme info to the < code > .s< / code > field< / td >
< / tr >
< tr >
< td align = "left" > < code > cellText< / code > < / td >
< td align = "right" > true< / td >
< td align = "left" > Generated formatted text to the < code > .w< / code > field< / td >
< / tr >
< tr >
< td align = "left" > < code > cellDates< / code > < / td >
< td align = "right" > false< / td >
< td align = "left" > Store dates as type < code > d< / code > (default is < code > n< / code > )< / td >
< / tr >
< tr >
< td align = "left" > < code > dateNF< / code > < / td >
< td align = "right" > < / td >
< td align = "left" > If specified, use the string for date code 14 **< / td >
< / tr >
< tr >
< td align = "left" > < code > sheetStubs< / code > < / td >
< td align = "right" > false< / td >
< td align = "left" > Create cell objects of type < code > z< / code > for stub cells< / td >
< / tr >
< tr >
< td align = "left" > < code > sheetRows< / code > < / td >
< td align = "right" > 0< / td >
< td align = "left" > If > 0, read the first < code > sheetRows< / code > rows **< / td >
< / tr >
< tr >
< td align = "left" > < code > bookDeps< / code > < / td >
< td align = "right" > false< / td >
< td align = "left" > If true, parse calculation chains< / td >
< / tr >
< tr >
< td align = "left" > < code > bookFiles< / code > < / td >
< td align = "right" > false< / td >
< td align = "left" > If true, add raw files to book object **< / td >
< / tr >
< tr >
< td align = "left" > < code > bookProps< / code > < / td >
< td align = "right" > false< / td >
< td align = "left" > If true, only parse enough to get book metadata **< / td >
< / tr >
< tr >
< td align = "left" > < code > bookSheets< / code > < / td >
< td align = "right" > false< / td >
< td align = "left" > If true, only parse enough to get the sheet names< / td >
< / tr >
< tr >
< td align = "left" > < code > bookVBA< / code > < / td >
< td align = "right" > false< / td >
< td align = "left" > If true, copy VBA blob to < code > vbaraw< / code > field **< / td >
< / tr >
< tr >
< td align = "left" > < code > password< / code > < / td >
< td align = "right" > ""< / td >
< td align = "left" > If defined and file is encrypted, use password **< / td >
< / tr >
< tr >
< td align = "left" > < code > WTF< / code > < / td >
< td align = "right" > false< / td >
< td align = "left" > If true, throw errors on unexpected file features **< / td >
< / tr >
< tr >
< td align = "left" > < code > sheets< / code > < / td >
< td align = "right" > < / td >
< td align = "left" > If specified, only parse specified sheets **< / td >
< / tr >
2021-08-27 00:16:16 +00:00
< tr >
< td align = "left" > < code > PRN< / code > < / td >
< td align = "right" > false< / td >
< td align = "left" > If true, allow parsing of PRN files **< / td >
< / tr >
< tr >
< td align = "left" > < code > xlfn< / code > < / td >
< td align = "right" > false< / td >
< td align = "left" > If true, preserve < code > _xlfn.< / code > prefixes in formulae **< / td >
< / tr >
2020-01-28 05:02:07 +00:00
< / tbody >
< / table >
< ul >
< li > Even if < code > cellNF< / code > is false, formatted text will be generated and saved to < code > .w< / code >
< / li >
< li > In some cases, sheets may be parsed even if < code > bookSheets< / code > is false.< / li >
< li > Excel aggressively tries to interpret values from CSV and other plain text.
This leads to surprising behavior! The < code > raw< / code > option suppresses value parsing.< / li >
< li >
< code > bookSheets< / code > and < code > bookProps< / code > combine to give both sets of information< / li >
< li >
< code > Deps< / code > will be an empty object if < code > bookDeps< / code > is false< / li >
< li >
< code > bookFiles< / code > behavior depends on file type:
< ul >
< li >
< code > keys< / code > array (paths in the ZIP) for ZIP-based formats< / li >
< li >
< code > files< / code > hash (mapping paths to objects representing the files) for ZIP< / li >
< li >
< code > cfb< / code > object for formats using CFB containers< / li >
< / ul >
< / li >
< li >
< code > sheetRows-1< / code > rows will be generated when looking at the JSON object output
(since the header row is counted as a row when parsing the data)< / li >
< li > By default all worksheets are parsed. < code > sheets< / code > restricts based on input type:
< ul >
< li > number: zero-based index of worksheet to parse (< code > 0< / code > is first worksheet)< / li >
< li > string: name of worksheet to parse (case insensitive)< / li >
< li > array of numbers and strings to select multiple worksheets.< / li >
< / ul >
< / li >
< li >
< code > bookVBA< / code > merely exposes the raw VBA CFB object. It does not parse the data.
XLSM and XLSB store the VBA CFB object in < code > xl/vbaProject.bin< / code > . BIFF8 XLS mixes
the VBA entries alongside the core Workbook entry, so the library generates a
new XLSB-compatible blob from the XLS CFB container.< / li >
< li >
< code > codepage< / code > is applied to BIFF2 - BIFF5 files without < code > CodePage< / code > records and to
CSV files without BOM in < code > type:"binary"< / code > . BIFF8 XLS always defaults to 1200.< / li >
2021-08-27 00:16:16 +00:00
< li >
< code > PRN< / code > affects parsing of text files without a common delimiter character.< / li >
2020-01-28 05:02:07 +00:00
< li > Currently only XOR encryption is supported. Unsupported error will be thrown
for files employing other encryption methods.< / li >
2021-08-27 00:16:16 +00:00
< li > Newer Excel functions are serialized with the < code > _xlfn.< / code > prefix, hidden from the
user. SheetJS will strip < code > _xlfn.< / code > normally. The < code > xlfn< / code > option preserves them.< / li >
2020-01-28 05:02:07 +00:00
< li > WTF is mainly for development. By default, the parser will suppress read
errors on single worksheets, allowing you to read from the worksheets that do
2021-08-27 00:16:16 +00:00
parse properly. Setting < code > WTF:true< / code > forces those errors to be thrown.< / li >
2020-01-28 05:02:07 +00:00
< / ul >
< h3 >
< a id = "user-content-input-type" class = "anchor" href = "#input-type" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > Input Type< / h3 >
< p > Strings can be interpreted in multiple ways. The < code > type< / code > parameter for < code > read< / code >
tells the library how to parse the data argument:< / p >
< table >
< thead >
< tr >
< th > < code > type< / code > < / th >
< th > expected input< / th >
< / tr >
< / thead >
< tbody >
< tr >
< td > < code > "base64"< / code > < / td >
< td > string: Base64 encoding of the file< / td >
< / tr >
< tr >
< td > < code > "binary"< / code > < / td >
< td > string: binary string (byte < code > n< / code > is < code > data.charCodeAt(n)< / code > )< / td >
< / tr >
< tr >
< td > < code > "string"< / code > < / td >
< td > string: JS string (characters interpreted as UTF8)< / td >
< / tr >
< tr >
< td > < code > "buffer"< / code > < / td >
< td > nodejs Buffer< / td >
< / tr >
< tr >
< td > < code > "array"< / code > < / td >
< td > array: array of 8-bit unsigned int (byte < code > n< / code > is < code > data[n]< / code > )< / td >
< / tr >
< tr >
< td > < code > "file"< / code > < / td >
< td > string: path of file that will be read (nodejs only)< / td >
< / tr >
< / tbody >
< / table >
< h3 >
< a id = "user-content-guessing-file-type" class = "anchor" href = "#guessing-file-type" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > Guessing File Type< / h3 >
< details >
< summary > < b > Implementation Details< / b > (click to show)< / summary >
< p > Excel and other spreadsheet tools read the first few bytes and apply other
heuristics to determine a file type. This enables file type punning: renaming
files with the < code > .xls< / code > extension will tell your computer to use Excel to open the
file but Excel will know how to handle it. This library applies similar logic:< / p >
< table >
< thead >
< tr >
< th align = "left" > Byte 0< / th >
< th align = "left" > Raw File Type< / th >
< th align = "left" > Spreadsheet Types< / th >
< / tr >
< / thead >
< tbody >
< tr >
< td align = "left" > < code > 0xD0< / code > < / td >
< td align = "left" > CFB Container< / td >
< td align = "left" > BIFF 5/8 or password-protected XLSX/XLSB or WQ3/QPW< / td >
< / tr >
< tr >
< td align = "left" > < code > 0x09< / code > < / td >
< td align = "left" > BIFF Stream< / td >
< td align = "left" > BIFF 2/3/4/5< / td >
< / tr >
< tr >
< td align = "left" > < code > 0x3C< / code > < / td >
< td align = "left" > XML/HTML< / td >
< td align = "left" > SpreadsheetML / Flat ODS / UOS1 / HTML / plain text< / td >
< / tr >
< tr >
< td align = "left" > < code > 0x50< / code > < / td >
< td align = "left" > ZIP Archive< / td >
< td align = "left" > XLSB or XLSX/M or ODS or UOS2 or plain text< / td >
< / tr >
< tr >
< td align = "left" > < code > 0x49< / code > < / td >
< td align = "left" > Plain Text< / td >
< td align = "left" > SYLK or plain text< / td >
< / tr >
< tr >
< td align = "left" > < code > 0x54< / code > < / td >
< td align = "left" > Plain Text< / td >
< td align = "left" > DIF or plain text< / td >
< / tr >
< tr >
< td align = "left" > < code > 0xEF< / code > < / td >
< td align = "left" > UTF8 Encoded< / td >
< td align = "left" > SpreadsheetML / Flat ODS / UOS1 / HTML / plain text< / td >
< / tr >
< tr >
< td align = "left" > < code > 0xFF< / code > < / td >
< td align = "left" > UTF16 Encoded< / td >
< td align = "left" > SpreadsheetML / Flat ODS / UOS1 / HTML / plain text< / td >
< / tr >
< tr >
< td align = "left" > < code > 0x00< / code > < / td >
< td align = "left" > Record Stream< / td >
< td align = "left" > Lotus WK* or Quattro Pro or plain text< / td >
< / tr >
< tr >
< td align = "left" > < code > 0x7B< / code > < / td >
< td align = "left" > Plain text< / td >
< td align = "left" > RTF or plain text< / td >
< / tr >
< tr >
< td align = "left" > < code > 0x0A< / code > < / td >
< td align = "left" > Plain text< / td >
< td align = "left" > SpreadsheetML / Flat ODS / UOS1 / HTML / plain text< / td >
< / tr >
< tr >
< td align = "left" > < code > 0x0D< / code > < / td >
< td align = "left" > Plain text< / td >
< td align = "left" > SpreadsheetML / Flat ODS / UOS1 / HTML / plain text< / td >
< / tr >
< tr >
< td align = "left" > < code > 0x20< / code > < / td >
< td align = "left" > Plain text< / td >
< td align = "left" > SpreadsheetML / Flat ODS / UOS1 / HTML / plain text< / td >
< / tr >
< / tbody >
< / table >
< p > DBF files are detected based on the first byte as well as the third and fourth
bytes (corresponding to month and day of the file date)< / p >
< p > Plain text format guessing follows the priority order:< / p >
< table >
< thead >
< tr >
< th align = "left" > Format< / th >
< th align = "left" > Test< / th >
< / tr >
< / thead >
< tbody >
< tr >
< td align = "left" > XML< / td >
< td align = "left" >
< code > < ?xml< / code > appears in the first 1024 characters< / td >
< / tr >
< tr >
< td align = "left" > HTML< / td >
< td align = "left" > starts with < code > < < / code > and HTML tags appear in the first 1024 characters *< / td >
< / tr >
< tr >
< td align = "left" > XML< / td >
< td align = "left" > starts with < code > < < / code >
< / td >
< / tr >
< tr >
< td align = "left" > RTF< / td >
< td align = "left" > starts with < code > {\rt< / code >
< / td >
< / tr >
< tr >
< td align = "left" > DSV< / td >
< td align = "left" > starts with < code > /sep=.$/< / code > , separator is the specified character< / td >
< / tr >
< tr >
< td align = "left" > DSV< / td >
< td align = "left" > more unquoted < code > ";"< / code > chars than < code > "\t"< / code > or < code > ","< / code > in the first 1024< / td >
< / tr >
< tr >
< td align = "left" > TSV< / td >
< td align = "left" > more unquoted < code > "\t"< / code > chars than < code > ","< / code > chars in the first 1024< / td >
< / tr >
< tr >
< td align = "left" > CSV< / td >
< td align = "left" > one of the first 1024 characters is a comma < code > ","< / code >
< / td >
< / tr >
< tr >
< td align = "left" > ETH< / td >
< td align = "left" > starts with < code > socialcalc:version:< / code >
< / td >
< / tr >
< tr >
< td align = "left" > PRN< / td >
< td align = "left" > (default)< / td >
< / tr >
< / tbody >
< / table >
< ul >
< li > HTML tags include: < code > html< / code > , < code > table< / code > , < code > head< / code > , < code > meta< / code > , < code > script< / code > , < code > style< / code > , < code > div< / code >
< / li >
< / ul >
< / details >
< details >
< summary > < b > Why are random text files valid?< / b > (click to show)< / summary >
< p > Excel is extremely aggressive in reading files. Adding an XLS extension to any
display text file (where the only characters are ANSI display chars) tricks
Excel into thinking that the file is potentially a CSV or TSV file, even if it
is only one column! This library attempts to replicate that behavior.< / p >
< p > The best approach is to validate the desired worksheet and ensure it has the
expected number of rows or columns. Extracting the range is extremely simple:< / p >
2021-08-27 00:16:16 +00:00
< div class = "highlight highlight-source-js" > < pre > < span class = "pl-k" > var< / span > < span class = "pl-s1" > range< / 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" > decode_range< / span > < span class = "pl-kos" > (< / span > < span class = "pl-s1" > worksheet< / span > < span class = "pl-kos" > [< / span > < span class = "pl-s" > '!ref'< / span > < span class = "pl-kos" > ]< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ;< / span >
< span class = "pl-k" > var< / span > < span class = "pl-s1" > ncols< / span > < span class = "pl-c1" > =< / span > < span class = "pl-s1" > range< / span > < span class = "pl-kos" > .< / span > < span class = "pl-c1" > e< / span > < span class = "pl-kos" > .< / span > < span class = "pl-c1" > c< / span > < span class = "pl-c1" > -< / span > < span class = "pl-s1" > range< / span > < span class = "pl-kos" > .< / span > < span class = "pl-c1" > s< / span > < span class = "pl-kos" > .< / span > < span class = "pl-c1" > c< / span > < span class = "pl-c1" > +< / span > < span class = "pl-c1" > 1< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s1" > nrows< / span > < span class = "pl-c1" > =< / span > < span class = "pl-s1" > range< / span > < span class = "pl-kos" > .< / span > < span class = "pl-c1" > e< / span > < span class = "pl-kos" > .< / span > < span class = "pl-c1" > r< / span > < span class = "pl-c1" > -< / span > < span class = "pl-s1" > range< / span > < span class = "pl-kos" > .< / span > < span class = "pl-c1" > s< / span > < span class = "pl-kos" > .< / span > < span class = "pl-c1" > r< / span > < span class = "pl-c1" > +< / span > < span class = "pl-c1" > 1< / span > < span class = "pl-kos" > ;< / span > < / pre > < / div >
2020-01-28 05:02:07 +00:00
< / details >
< h2 >
< a id = "user-content-writing-options" class = "anchor" href = "#writing-options" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > Writing Options< / h2 >
< p > The exported < code > write< / code > and < code > writeFile< / code > functions accept an options argument:< / p >
< table >
< thead >
< tr >
< th align = "left" > Option Name< / th >
< th align = "right" > Default< / th >
< th align = "left" > Description< / th >
< / tr >
< / thead >
< tbody >
< tr >
< td align = "left" > < code > type< / code > < / td >
< td align = "right" > < / td >
< td align = "left" > Output data encoding (see Output Type below)< / td >
< / tr >
< tr >
< td align = "left" > < code > cellDates< / code > < / td >
< td align = "right" > < code > false< / code > < / td >
< td align = "left" > Store dates as type < code > d< / code > (default is < code > n< / code > )< / td >
< / tr >
< tr >
< td align = "left" > < code > bookSST< / code > < / td >
< td align = "right" > < code > false< / code > < / td >
< td align = "left" > Generate Shared String Table **< / td >
< / tr >
< tr >
< td align = "left" > < code > bookType< / code > < / td >
< td align = "right" > < code > "xlsx"< / code > < / td >
< td align = "left" > Type of Workbook (see below for supported formats)< / td >
< / tr >
< tr >
< td align = "left" > < code > sheet< / code > < / td >
< td align = "right" > < code > ""< / code > < / td >
< td align = "left" > Name of Worksheet for single-sheet formats **< / td >
< / tr >
< tr >
< td align = "left" > < code > compression< / code > < / td >
< td align = "right" > < code > false< / code > < / td >
< td align = "left" > Use ZIP compression for ZIP-based formats **< / td >
< / tr >
< tr >
< td align = "left" > < code > Props< / code > < / td >
< td align = "right" > < / td >
< td align = "left" > Override workbook properties when writing **< / td >
< / tr >
< tr >
< td align = "left" > < code > themeXLSX< / code > < / td >
< td align = "right" > < / td >
< td align = "left" > Override theme XML when writing XLSX/XLSB/XLSM **< / td >
< / tr >
< tr >
< td align = "left" > < code > ignoreEC< / code > < / td >
< td align = "right" > < code > true< / code > < / td >
< td align = "left" > Suppress "number as text" errors **< / td >
< / tr >
< / tbody >
< / table >
< ul >
< li >
< code > bookSST< / code > is slower and more memory intensive, but has better compatibility
with older versions of iOS Numbers< / li >
< li > The raw data is the only thing guaranteed to be saved. Features not described
in this README may not be serialized.< / li >
< li >
< code > cellDates< / code > only applies to XLSX output and is not guaranteed to work with
third-party readers. Excel itself does not usually write cells with type < code > d< / code >
so non-Excel tools may ignore the data or error in the presence of dates.< / li >
< li >
< code > Props< / code > is an object mirroring the workbook < code > Props< / code > field. See the table from
the < a href = "#workbook-file-properties" > Workbook File Properties< / a > section.< / li >
< li > if specified, the string from < code > themeXLSX< / code > will be saved as the primary theme
for XLSX/XLSB/XLSM files (to < code > xl/theme/theme1.xml< / code > in the ZIP)< / li >
< li > Due to a bug in the program, some features like "Text to Columns" will crash
Excel on worksheets where error conditions are ignored. The writer will mark
files to ignore the error by default. Set < code > ignoreEC< / code > to < code > false< / code > to suppress.< / li >
< / ul >
< h3 >
< a id = "user-content-supported-output-formats" class = "anchor" href = "#supported-output-formats" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > Supported Output Formats< / h3 >
< p > For broad compatibility with third-party tools, this library supports many
output formats. The specific file type is controlled with < code > bookType< / code > option:< / p >
< table >
< thead >
< tr >
< th align = "left" > < code > bookType< / code > < / th >
< th align = "right" > file ext< / th >
< th align = "center" > container< / th >
< th align = "left" > sheets< / th >
< th align = "left" > Description< / th >
< / tr >
< / thead >
< tbody >
< tr >
< td align = "left" > < code > xlsx< / code > < / td >
< td align = "right" > < code > .xlsx< / code > < / td >
< td align = "center" > ZIP< / td >
< td align = "left" > multi< / td >
< td align = "left" > Excel 2007+ XML Format< / td >
< / tr >
< tr >
< td align = "left" > < code > xlsm< / code > < / td >
< td align = "right" > < code > .xlsm< / code > < / td >
< td align = "center" > ZIP< / td >
< td align = "left" > multi< / td >
< td align = "left" > Excel 2007+ Macro XML Format< / td >
< / tr >
< tr >
< td align = "left" > < code > xlsb< / code > < / td >
< td align = "right" > < code > .xlsb< / code > < / td >
< td align = "center" > ZIP< / td >
< td align = "left" > multi< / td >
< td align = "left" > Excel 2007+ Binary Format< / td >
< / tr >
< tr >
< td align = "left" > < code > biff8< / code > < / td >
< td align = "right" > < code > .xls< / code > < / td >
< td align = "center" > CFB< / td >
< td align = "left" > multi< / td >
< td align = "left" > Excel 97-2004 Workbook Format< / td >
< / tr >
< tr >
< td align = "left" > < code > biff5< / code > < / td >
< td align = "right" > < code > .xls< / code > < / td >
< td align = "center" > CFB< / td >
< td align = "left" > multi< / td >
< td align = "left" > Excel 5.0/95 Workbook Format< / td >
< / tr >
< tr >
< td align = "left" > < code > biff2< / code > < / td >
< td align = "right" > < code > .xls< / code > < / td >
< td align = "center" > none< / td >
< td align = "left" > single< / td >
< td align = "left" > Excel 2.0 Worksheet Format< / td >
< / tr >
< tr >
< td align = "left" > < code > xlml< / code > < / td >
< td align = "right" > < code > .xls< / code > < / td >
< td align = "center" > none< / td >
< td align = "left" > multi< / td >
< td align = "left" > Excel 2003-2004 (SpreadsheetML)< / td >
< / tr >
< tr >
< td align = "left" > < code > ods< / code > < / td >
< td align = "right" > < code > .ods< / code > < / td >
< td align = "center" > ZIP< / td >
< td align = "left" > multi< / td >
< td align = "left" > OpenDocument Spreadsheet< / td >
< / tr >
< tr >
< td align = "left" > < code > fods< / code > < / td >
< td align = "right" > < code > .fods< / code > < / td >
< td align = "center" > none< / td >
< td align = "left" > multi< / td >
< td align = "left" > Flat OpenDocument Spreadsheet< / td >
< / tr >
< tr >
< td align = "left" > < code > csv< / code > < / td >
< td align = "right" > < code > .csv< / code > < / td >
< td align = "center" > none< / td >
< td align = "left" > single< / td >
< td align = "left" > Comma Separated Values< / td >
< / tr >
< tr >
< td align = "left" > < code > txt< / code > < / td >
< td align = "right" > < code > .txt< / code > < / td >
< td align = "center" > none< / td >
< td align = "left" > single< / td >
< td align = "left" > UTF-16 Unicode Text (TXT)< / td >
< / tr >
< tr >
< td align = "left" > < code > sylk< / code > < / td >
< td align = "right" > < code > .sylk< / code > < / td >
< td align = "center" > none< / td >
< td align = "left" > single< / td >
< td align = "left" > Symbolic Link (SYLK)< / td >
< / tr >
< tr >
< td align = "left" > < code > html< / code > < / td >
< td align = "right" > < code > .html< / code > < / td >
< td align = "center" > none< / td >
< td align = "left" > single< / td >
< td align = "left" > HTML Document< / td >
< / tr >
< tr >
< td align = "left" > < code > dif< / code > < / td >
< td align = "right" > < code > .dif< / code > < / td >
< td align = "center" > none< / td >
< td align = "left" > single< / td >
< td align = "left" > Data Interchange Format (DIF)< / td >
< / tr >
< tr >
< td align = "left" > < code > dbf< / code > < / td >
< td align = "right" > < code > .dbf< / code > < / td >
< td align = "center" > none< / td >
< td align = "left" > single< / td >
< td align = "left" > dBASE II + VFP Extensions (DBF)< / td >
< / tr >
< tr >
< td align = "left" > < code > rtf< / code > < / td >
< td align = "right" > < code > .rtf< / code > < / td >
< td align = "center" > none< / td >
< td align = "left" > single< / td >
< td align = "left" > Rich Text Format (RTF)< / td >
< / tr >
< tr >
< td align = "left" > < code > prn< / code > < / td >
< td align = "right" > < code > .prn< / code > < / td >
< td align = "center" > none< / td >
< td align = "left" > single< / td >
< td align = "left" > Lotus Formatted Text< / td >
< / tr >
< tr >
< td align = "left" > < code > eth< / code > < / td >
< td align = "right" > < code > .eth< / code > < / td >
< td align = "center" > none< / td >
< td align = "left" > single< / td >
< td align = "left" > Ethercalc Record Format (ETH)< / td >
< / tr >
< / tbody >
< / table >
< ul >
< li >
< code > compression< / code > only applies to formats with ZIP containers.< / li >
< li > Formats that only support a single sheet require a < code > sheet< / code > option specifying
the worksheet. If the string is empty, the first worksheet is used.< / li >
< li >
< code > writeFile< / code > will automatically guess the output file format based on the file
extension if < code > bookType< / code > is not specified. It will choose the first format in
the aforementioned table that matches the extension.< / li >
< / ul >
< h3 >
< a id = "user-content-output-type" class = "anchor" href = "#output-type" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > Output Type< / h3 >
< p > The < code > type< / code > argument for < code > write< / code > mirrors the < code > type< / code > argument for < code > read< / code > :< / p >
< table >
< thead >
< tr >
< th > < code > type< / code > < / th >
< th > output< / th >
< / tr >
< / thead >
< tbody >
< tr >
< td > < code > "base64"< / code > < / td >
< td > string: Base64 encoding of the file< / td >
< / tr >
< tr >
< td > < code > "binary"< / code > < / td >
< td > string: binary string (byte < code > n< / code > is < code > data.charCodeAt(n)< / code > )< / td >
< / tr >
< tr >
< td > < code > "string"< / code > < / td >
< td > string: JS string (characters interpreted as UTF8)< / td >
< / tr >
< tr >
< td > < code > "buffer"< / code > < / td >
< td > nodejs Buffer< / td >
< / tr >
< tr >
< td > < code > "array"< / code > < / td >
< td > ArrayBuffer, fallback array of 8-bit unsigned int< / td >
< / tr >
< tr >
< td > < code > "file"< / code > < / td >
< td > string: path of file that will be created (nodejs only)< / td >
< / tr >
< / tbody >
< / table >
< h2 >
< a id = "user-content-utility-functions" class = "anchor" href = "#utility-functions" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > Utility Functions< / h2 >
< p > The < code > sheet_to_*< / code > functions accept a worksheet and an optional options object.< / p >
< p > The < code > *_to_sheet< / code > functions accept a data object and an optional options object.< / p >
< p > The examples are based on the following worksheet:< / p >
< pre > < code > XXX| A | B | C | D | E | F | G |
---+---+---+---+---+---+---+---+
1 | S | h | e | e | t | J | S |
2 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
3 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
< / code > < / pre >
< h3 >
< a id = "user-content-array-of-arrays-input" class = "anchor" href = "#array-of-arrays-input" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > Array of Arrays Input< / h3 >
< p > < code > XLSX.utils.aoa_to_sheet< / code > takes an array of arrays of JS values and returns a
worksheet resembling the input data. Numbers, Booleans and Strings are stored
as the corresponding styles. Dates are stored as date or numbers. Array holes
and explicit < code > undefined< / code > values are skipped. < code > null< / code > values may be stubbed. All
other values are stored as strings. The function takes an options argument:< / p >
< table >
< thead >
< tr >
< th align = "left" > Option Name< / th >
< th align = "center" > Default< / th >
< th align = "left" > Description< / th >
< / tr >
< / thead >
< tbody >
< tr >
< td align = "left" > < code > dateNF< / code > < / td >
< td align = "center" > FMT 14< / td >
< td align = "left" > Use specified date format in string output< / td >
< / tr >
< tr >
< td align = "left" > < code > cellDates< / code > < / td >
< td align = "center" > false< / td >
< td align = "left" > Store dates as type < code > d< / code > (default is < code > n< / code > )< / td >
< / tr >
< tr >
< td align = "left" > < code > sheetStubs< / code > < / td >
< td align = "center" > false< / td >
< td align = "left" > Create cell objects of type < code > z< / code > for < code > null< / code > values< / td >
< / tr >
< / tbody >
< / table >
< details >
< summary > < b > Examples< / b > (click to show)< / summary >
< p > To generate the example sheet:< / p >
2021-08-27 00:16:16 +00:00
< div class = "highlight highlight-source-js" > < pre > < span class = "pl-k" > var< / span > < span class = "pl-s1" > ws< / 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" > aoa_to_sheet< / span > < span class = "pl-kos" > (< / span > < span class = "pl-kos" > [< / span >
< span class = "pl-s" > "SheetJS"< / span > < span class = "pl-kos" > .< / span > < span class = "pl-en" > split< / span > < span class = "pl-kos" > (< / span > < span class = "pl-s" > ""< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ,< / span >
< span class = "pl-kos" > [< / span > < span class = "pl-c1" > 1< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > 2< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > 3< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > 4< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > 5< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > 6< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > 7< / span > < span class = "pl-kos" > ]< / span > < span class = "pl-kos" > ,< / span >
< span class = "pl-kos" > [< / span > < span class = "pl-c1" > 2< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > 3< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > 4< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > 5< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > 6< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > 7< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > 8< / span > < span class = "pl-kos" > ]< / span >
< span class = "pl-kos" > ]< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ;< / span > < / pre > < / div >
2020-01-28 05:02:07 +00:00
< / details >
< p > < code > XLSX.utils.sheet_add_aoa< / code > takes an array of arrays of JS values and updates an
existing worksheet object. It follows the same process as < code > aoa_to_sheet< / code > and
accepts an options argument:< / p >
< table >
< thead >
< tr >
< th align = "left" > Option Name< / th >
< th align = "center" > Default< / th >
< th align = "left" > Description< / th >
< / tr >
< / thead >
< tbody >
< tr >
< td align = "left" > < code > dateNF< / code > < / td >
< td align = "center" > FMT 14< / td >
< td align = "left" > Use specified date format in string output< / td >
< / tr >
< tr >
< td align = "left" > < code > cellDates< / code > < / td >
< td align = "center" > false< / td >
< td align = "left" > Store dates as type < code > d< / code > (default is < code > n< / code > )< / td >
< / tr >
< tr >
< td align = "left" > < code > sheetStubs< / code > < / td >
< td align = "center" > false< / td >
< td align = "left" > Create cell objects of type < code > z< / code > for < code > null< / code > values< / td >
< / tr >
< tr >
< td align = "left" > < code > origin< / code > < / td >
< td align = "center" > < / td >
< td align = "left" > Use specified cell as starting point (see below)< / td >
< / tr >
< / tbody >
< / table >
< p > < code > origin< / code > is expected to be one of:< / p >
< table >
< thead >
< tr >
< th align = "left" > < code > origin< / code > < / th >
< th align = "left" > Description< / th >
< / tr >
< / thead >
< tbody >
< tr >
< td align = "left" > (cell object)< / td >
< td align = "left" > Use specified cell (cell object)< / td >
< / tr >
< tr >
< td align = "left" > (string)< / td >
< td align = "left" > Use specified cell (A1-style cell)< / td >
< / tr >
< tr >
< td align = "left" > (number > = 0)< / td >
< td align = "left" > Start from the first column at specified row (0-indexed)< / td >
< / tr >
< tr >
< td align = "left" > -1< / td >
< td align = "left" > Append to bottom of worksheet starting on first column< / td >
< / tr >
< tr >
< td align = "left" > (default)< / td >
< td align = "left" > Start from cell A1< / td >
< / tr >
< / tbody >
< / table >
< details >
< summary > < b > Examples< / b > (click to show)< / summary >
< p > Consider the worksheet:< / p >
< pre > < code > XXX| A | B | C | D | E | F | G |
---+---+---+---+---+---+---+---+
1 | S | h | e | e | t | J | S |
2 | 1 | 2 | | | 5 | 6 | 7 |
3 | 2 | 3 | | | 6 | 7 | 8 |
4 | 3 | 4 | | | 7 | 8 | 9 |
5 | 4 | 5 | 6 | 7 | 8 | 9 | 0 |
< / code > < / pre >
< p > This worksheet can be built up in the order < code > A1:G1, A2:B4, E2:G4, A5:G5< / code > :< / p >
2021-08-27 00:16:16 +00:00
< div class = "highlight highlight-source-js" > < pre > < span class = "pl-c" > /* Initial row */< / span >
< span class = "pl-k" > var< / span > < span class = "pl-s1" > ws< / 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" > aoa_to_sheet< / span > < span class = "pl-kos" > (< / span > < span class = "pl-kos" > [< / span > < span class = "pl-s" > "SheetJS"< / span > < span class = "pl-kos" > .< / span > < span class = "pl-en" > split< / span > < span class = "pl-kos" > (< / span > < span class = "pl-s" > ""< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ]< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ;< / span >
2020-01-28 05:02:07 +00:00
2021-08-27 00:16:16 +00:00
< span class = "pl-c" > /* Write data starting at A2 */< / 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-c1" > 1< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > 2< / span > < span class = "pl-kos" > ]< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-kos" > [< / span > < span class = "pl-c1" > 2< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > 3< / span > < span class = "pl-kos" > ]< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-kos" > [< / span > < span class = "pl-c1" > 3< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > 4< / 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" > "A2"< / span > < span class = "pl-kos" > }< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ;< / span >
2020-01-28 05:02:07 +00:00
2021-08-27 00:16:16 +00:00
< span class = "pl-c" > /* Write data starting at E2 */< / 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-c1" > 5< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > 6< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > 7< / span > < span class = "pl-kos" > ]< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-kos" > [< / span > < span class = "pl-c1" > 6< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > 7< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > 8< / span > < span class = "pl-kos" > ]< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-kos" > [< / span > < span class = "pl-c1" > 7< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > 8< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > 9< / 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-kos" > {< / span > < span class = "pl-c1" > r< / span > :< span class = "pl-c1" > 1< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > c< / span > :< span class = "pl-c1" > 4< / span > < span class = "pl-kos" > }< / span > < span class = "pl-kos" > }< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ;< / span >
2020-01-28 05:02:07 +00:00
2021-08-27 00:16:16 +00:00
< span class = "pl-c" > /* Append row */< / 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-c1" > 4< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > 5< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > 6< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > 7< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > 8< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > 9< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > 0< / 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 > < / pre > < / div >
2020-01-28 05:02:07 +00:00
< / details >
< h3 >
< a id = "user-content-array-of-objects-input" class = "anchor" href = "#array-of-objects-input" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > Array of Objects Input< / h3 >
< p > < code > XLSX.utils.json_to_sheet< / code > takes an array of objects and returns a worksheet
with automatically-generated "headers" based on the keys of the objects. The
default column order is determined by the first appearance of the field using
< code > Object.keys< / code > , but can be overridden using the options argument:< / p >
< table >
< thead >
< tr >
< th align = "left" > Option Name< / th >
< th align = "center" > Default< / th >
< th align = "left" > Description< / th >
< / tr >
< / thead >
< tbody >
< tr >
< td align = "left" > < code > header< / code > < / td >
< td align = "center" > < / td >
< td align = "left" > Use specified column order (default < code > Object.keys< / code > )< / td >
< / tr >
< tr >
< td align = "left" > < code > dateNF< / code > < / td >
< td align = "center" > FMT 14< / td >
< td align = "left" > Use specified date format in string output< / td >
< / tr >
< tr >
< td align = "left" > < code > cellDates< / code > < / td >
< td align = "center" > false< / td >
< td align = "left" > Store dates as type < code > d< / code > (default is < code > n< / code > )< / td >
< / tr >
< tr >
< td align = "left" > < code > skipHeader< / code > < / td >
< td align = "center" > false< / td >
< td align = "left" > If true, do not include header row in output< / td >
< / tr >
< / tbody >
< / table >
< details >
< summary > < b > Examples< / b > (click to show)< / summary >
< p > The original sheet cannot be reproduced using plain objects since JS object keys
must be unique. After replacing the second < code > e< / code > and < code > S< / code > with < code > e_1< / code > and < code > S_1< / code > :< / p >
2021-08-27 00:16:16 +00:00
< div class = "highlight highlight-source-js" > < pre > < span class = "pl-k" > var< / span > < span class = "pl-s1" > ws< / 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-kos" > [< / span >
< span class = "pl-kos" > {< / span > < span class = "pl-c1" > S< / span > :< span class = "pl-c1" > 1< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > h< / span > :< span class = "pl-c1" > 2< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > e< / span > :< span class = "pl-c1" > 3< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > e_1< / span > :< span class = "pl-c1" > 4< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > t< / span > :< span class = "pl-c1" > 5< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > J< / span > :< span class = "pl-c1" > 6< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > S_1< / span > :< span class = "pl-c1" > 7< / span > < span class = "pl-kos" > }< / span > < span class = "pl-kos" > ,< / span >
< span class = "pl-kos" > {< / span > < span class = "pl-c1" > S< / span > :< span class = "pl-c1" > 2< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > h< / span > :< span class = "pl-c1" > 3< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > e< / span > :< span class = "pl-c1" > 4< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > e_1< / span > :< span class = "pl-c1" > 5< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > t< / span > :< span class = "pl-c1" > 6< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > J< / span > :< span class = "pl-c1" > 7< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > S_1< / span > :< span class = "pl-c1" > 8< / 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" > header< / span > :< span class = "pl-kos" > [< / span > < span class = "pl-s" > "S"< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > "h"< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > "e"< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > "e_1"< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > "t"< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > "J"< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > "S_1"< / span > < span class = "pl-kos" > ]< / span > < span class = "pl-kos" > }< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ;< / span > < / pre > < / div >
2020-01-28 05:02:07 +00:00
< p > Alternatively, the header row can be skipped:< / p >
2021-08-27 00:16:16 +00:00
< div class = "highlight highlight-source-js" > < pre > < span class = "pl-k" > var< / span > < span class = "pl-s1" > ws< / 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-kos" > [< / span >
< span class = "pl-kos" > {< / span > < span class = "pl-c1" > A< / span > :< span class = "pl-s" > "S"< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > B< / span > :< span class = "pl-s" > "h"< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > C< / span > :< span class = "pl-s" > "e"< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > D< / span > :< span class = "pl-s" > "e"< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > E< / span > :< span class = "pl-s" > "t"< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > F< / span > :< span class = "pl-s" > "J"< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > G< / span > :< span class = "pl-s" > "S"< / span > < span class = "pl-kos" > }< / span > < span class = "pl-kos" > ,< / span >
< span class = "pl-kos" > {< / span > < span class = "pl-c1" > A< / span > : < span class = "pl-c1" > 1< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > B< / span > : < span class = "pl-c1" > 2< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > C< / span > : < span class = "pl-c1" > 3< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > D< / span > : < span class = "pl-c1" > 4< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > E< / span > : < span class = "pl-c1" > 5< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > F< / span > : < span class = "pl-c1" > 6< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > G< / span > : < span class = "pl-c1" > 7< / span > < span class = "pl-kos" > }< / span > < span class = "pl-kos" > ,< / span >
< span class = "pl-kos" > {< / span > < span class = "pl-c1" > A< / span > : < span class = "pl-c1" > 2< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > B< / span > : < span class = "pl-c1" > 3< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > C< / span > : < span class = "pl-c1" > 4< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > D< / span > : < span class = "pl-c1" > 5< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > E< / span > : < span class = "pl-c1" > 6< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > F< / span > : < span class = "pl-c1" > 7< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > G< / span > : < span class = "pl-c1" > 8< / 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" > header< / span > :< span class = "pl-kos" > [< / span > < span class = "pl-s" > "A"< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > "B"< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > "C"< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > "D"< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > "E"< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > "F"< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > "G"< / span > < span class = "pl-kos" > ]< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > skipHeader< / span > :< span class = "pl-c1" > true< / span > < span class = "pl-kos" > }< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ;< / span > < / pre > < / div >
2020-01-28 05:02:07 +00:00
< / details >
< p > < code > XLSX.utils.sheet_add_json< / code > takes an array of objects and updates an existing
worksheet object. It follows the same process as < code > json_to_sheet< / code > and accepts
an options argument:< / p >
< table >
< thead >
< tr >
< th align = "left" > Option Name< / th >
< th align = "center" > Default< / th >
< th align = "left" > Description< / th >
< / tr >
< / thead >
< tbody >
< tr >
< td align = "left" > < code > header< / code > < / td >
< td align = "center" > < / td >
< td align = "left" > Use specified column order (default < code > Object.keys< / code > )< / td >
< / tr >
< tr >
< td align = "left" > < code > dateNF< / code > < / td >
< td align = "center" > FMT 14< / td >
< td align = "left" > Use specified date format in string output< / td >
< / tr >
< tr >
< td align = "left" > < code > cellDates< / code > < / td >
< td align = "center" > false< / td >
< td align = "left" > Store dates as type < code > d< / code > (default is < code > n< / code > )< / td >
< / tr >
< tr >
< td align = "left" > < code > skipHeader< / code > < / td >
< td align = "center" > false< / td >
< td align = "left" > If true, do not include header row in output< / td >
< / tr >
< tr >
< td align = "left" > < code > origin< / code > < / td >
< td align = "center" > < / td >
< td align = "left" > Use specified cell as starting point (see below)< / td >
< / tr >
< / tbody >
< / table >
< p > < code > origin< / code > is expected to be one of:< / p >
< table >
< thead >
< tr >
< th align = "left" > < code > origin< / code > < / th >
< th align = "left" > Description< / th >
< / tr >
< / thead >
< tbody >
< tr >
< td align = "left" > (cell object)< / td >
< td align = "left" > Use specified cell (cell object)< / td >
< / tr >
< tr >
< td align = "left" > (string)< / td >
< td align = "left" > Use specified cell (A1-style cell)< / td >
< / tr >
< tr >
< td align = "left" > (number > = 0)< / td >
< td align = "left" > Start from the first column at specified row (0-indexed)< / td >
< / tr >
< tr >
< td align = "left" > -1< / td >
< td align = "left" > Append to bottom of worksheet starting on first column< / td >
< / tr >
< tr >
< td align = "left" > (default)< / td >
< td align = "left" > Start from cell A1< / td >
< / tr >
< / tbody >
< / table >
< details >
< summary > < b > Examples< / b > (click to show)< / summary >
< p > Consider the worksheet:< / p >
< pre > < code > XXX| A | B | C | D | E | F | G |
---+---+---+---+---+---+---+---+
1 | S | h | e | e | t | J | S |
2 | 1 | 2 | | | 5 | 6 | 7 |
3 | 2 | 3 | | | 6 | 7 | 8 |
4 | 3 | 4 | | | 7 | 8 | 9 |
5 | 4 | 5 | 6 | 7 | 8 | 9 | 0 |
< / code > < / pre >
< p > This worksheet can be built up in the order < code > A1:G1, A2:B4, E2:G4, A5:G5< / code > :< / p >
2021-08-27 00:16:16 +00:00
< div class = "highlight highlight-source-js" > < pre > < span class = "pl-c" > /* Initial row */< / span >
< span class = "pl-k" > var< / span > < span class = "pl-s1" > ws< / 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-kos" > [< / span >
< span class = "pl-kos" > {< / span > < span class = "pl-c1" > A< / span > : < span class = "pl-s" > "S"< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > B< / span > : < span class = "pl-s" > "h"< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > C< / span > : < span class = "pl-s" > "e"< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > D< / span > : < span class = "pl-s" > "e"< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > E< / span > : < span class = "pl-s" > "t"< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > F< / span > : < span class = "pl-s" > "J"< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > G< / span > : < span class = "pl-s" > "S"< / 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" > header< / span > : < span class = "pl-kos" > [< / span > < span class = "pl-s" > "A"< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > "B"< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > "C"< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > "D"< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > "E"< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > "F"< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > "G"< / span > < span class = "pl-kos" > ]< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > skipHeader< / span > : < span class = "pl-c1" > true< / span > < span class = "pl-kos" > }< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ;< / span >
2020-01-28 05:02:07 +00:00
2021-08-27 00:16:16 +00:00
< span class = "pl-c" > /* Write data starting at A2 */< / 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_json< / 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-c1" > A< / span > : < span class = "pl-c1" > 1< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > B< / span > : < span class = "pl-c1" > 2< / span > < span class = "pl-kos" > }< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-kos" > {< / span > < span class = "pl-c1" > A< / span > : < span class = "pl-c1" > 2< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > B< / span > : < span class = "pl-c1" > 3< / span > < span class = "pl-kos" > }< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-kos" > {< / span > < span class = "pl-c1" > A< / span > : < span class = "pl-c1" > 3< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > B< / span > : < span class = "pl-c1" > 4< / 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" > skipHeader< / span > : < span class = "pl-c1" > true< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > origin< / span > : < span class = "pl-s" > "A2"< / span > < span class = "pl-kos" > }< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ;< / span >
2020-01-28 05:02:07 +00:00
2021-08-27 00:16:16 +00:00
< span class = "pl-c" > /* Write data starting at E2 */< / 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_json< / 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-c1" > A< / span > : < span class = "pl-c1" > 5< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > B< / span > : < span class = "pl-c1" > 6< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > C< / span > : < span class = "pl-c1" > 7< / span > < span class = "pl-kos" > }< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-kos" > {< / span > < span class = "pl-c1" > A< / span > : < span class = "pl-c1" > 6< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > B< / span > : < span class = "pl-c1" > 7< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > C< / span > : < span class = "pl-c1" > 8< / span > < span class = "pl-kos" > }< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-kos" > {< / span > < span class = "pl-c1" > A< / span > : < span class = "pl-c1" > 7< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > B< / span > : < span class = "pl-c1" > 8< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > C< / span > : < span class = "pl-c1" > 9< / 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" > skipHeader< / span > : < span class = "pl-c1" > true< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > origin< / span > : < span class = "pl-kos" > {< / span > < span class = "pl-c1" > r< / span > : < span class = "pl-c1" > 1< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > c< / span > : < span class = "pl-c1" > 4< / span > < span class = "pl-kos" > }< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > header< / span > : < span class = "pl-kos" > [< / span > < span class = "pl-s" > "A"< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > "B"< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > "C"< / span > < span class = "pl-kos" > ]< / span > < span class = "pl-kos" > }< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ;< / span >
2020-01-28 05:02:07 +00:00
2021-08-27 00:16:16 +00:00
< span class = "pl-c" > /* Append row */< / 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_json< / 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-c1" > A< / span > : < span class = "pl-c1" > 4< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > B< / span > : < span class = "pl-c1" > 5< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > C< / span > : < span class = "pl-c1" > 6< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > D< / span > : < span class = "pl-c1" > 7< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > E< / span > : < span class = "pl-c1" > 8< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > F< / span > : < span class = "pl-c1" > 9< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > G< / span > : < span class = "pl-c1" > 0< / 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" > header< / span > : < span class = "pl-kos" > [< / span > < span class = "pl-s" > "A"< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > "B"< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > "C"< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > "D"< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > "E"< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > "F"< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > "G"< / span > < span class = "pl-kos" > ]< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > skipHeader< / span > : < span class = "pl-c1" > true< / 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 > < / pre > < / div >
2020-01-28 05:02:07 +00:00
< / details >
< h3 >
< a id = "user-content-html-table-input" class = "anchor" href = "#html-table-input" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > HTML Table Input< / h3 >
< p > < code > XLSX.utils.table_to_sheet< / code > takes a table DOM element and returns a worksheet
resembling the input table. Numbers are parsed. All other data will be stored
as strings.< / p >
< p > < code > XLSX.utils.table_to_book< / code > produces a minimal workbook based on the worksheet.< / p >
< p > Both functions accept options arguments:< / p >
< table >
< thead >
< tr >
< th align = "left" > Option Name< / th >
< th align = "center" > Default< / th >
< th align = "left" > Description< / th >
< / tr >
< / thead >
< tbody >
< tr >
< td align = "left" > < code > raw< / code > < / td >
< td align = "center" > < / td >
< td align = "left" > If true, every cell will hold raw strings< / td >
< / tr >
< tr >
< td align = "left" > < code > dateNF< / code > < / td >
< td align = "center" > FMT 14< / td >
< td align = "left" > Use specified date format in string output< / td >
< / tr >
< tr >
< td align = "left" > < code > cellDates< / code > < / td >
< td align = "center" > false< / td >
< td align = "left" > Store dates as type < code > d< / code > (default is < code > n< / code > )< / td >
< / tr >
< tr >
< td align = "left" > < code > sheetRows< / code > < / td >
< td align = "center" > 0< / td >
< td align = "left" > If > 0, read the first < code > sheetRows< / code > rows of the table< / td >
< / tr >
< tr >
< td align = "left" > < code > display< / code > < / td >
< td align = "center" > false< / td >
< td align = "left" > If true, hidden rows and cells will not be parsed< / td >
< / tr >
< / tbody >
< / table >
< details >
< summary > < b > Examples< / b > (click to show)< / summary >
< p > To generate the example sheet, start with the HTML table:< / p >
2021-08-27 00:16:16 +00:00
< div class = "highlight highlight-text-html-basic" > < pre > < span class = "pl-kos" > < < / span > < span class = "pl-ent" > table< / span > < span class = "pl-c1" > id< / span > ="< span class = "pl-s" > sheetjs< / span > "< span class = "pl-kos" > > < / span >
< span class = "pl-kos" > < < / span > < span class = "pl-ent" > tr< / span > < span class = "pl-kos" > > < / span > < span class = "pl-kos" > < < / span > < span class = "pl-ent" > td< / span > < span class = "pl-kos" > > < / span > S< span class = "pl-kos" > < /< / span > < span class = "pl-ent" > td< / span > < span class = "pl-kos" > > < / span > < span class = "pl-kos" > < < / span > < span class = "pl-ent" > td< / span > < span class = "pl-kos" > > < / span > h< span class = "pl-kos" > < /< / span > < span class = "pl-ent" > td< / span > < span class = "pl-kos" > > < / span > < span class = "pl-kos" > < < / span > < span class = "pl-ent" > td< / span > < span class = "pl-kos" > > < / span > e< span class = "pl-kos" > < /< / span > < span class = "pl-ent" > td< / span > < span class = "pl-kos" > > < / span > < span class = "pl-kos" > < < / span > < span class = "pl-ent" > td< / span > < span class = "pl-kos" > > < / span > e< span class = "pl-kos" > < /< / span > < span class = "pl-ent" > td< / span > < span class = "pl-kos" > > < / span > < span class = "pl-kos" > < < / span > < span class = "pl-ent" > td< / span > < span class = "pl-kos" > > < / span > t< span class = "pl-kos" > < /< / span > < span class = "pl-ent" > td< / span > < span class = "pl-kos" > > < / span > < span class = "pl-kos" > < < / span > < span class = "pl-ent" > td< / span > < span class = "pl-kos" > > < / span > J< span class = "pl-kos" > < /< / span > < span class = "pl-ent" > td< / span > < span class = "pl-kos" > > < / span > < span class = "pl-kos" > < < / span > < span class = "pl-ent" > td< / span > < span class = "pl-kos" > > < / span > S< span class = "pl-kos" > < /< / span > < span class = "pl-ent" > td< / span > < span class = "pl-kos" > > < / span > < span class = "pl-kos" > < /< / span > < span class = "pl-ent" > tr< / span > < span class = "pl-kos" > > < / span >
< span class = "pl-kos" > < < / span > < span class = "pl-ent" > tr< / span > < span class = "pl-kos" > > < / span > < span class = "pl-kos" > < < / span > < span class = "pl-ent" > td< / span > < span class = "pl-kos" > > < / span > 1< span class = "pl-kos" > < /< / span > < span class = "pl-ent" > td< / span > < span class = "pl-kos" > > < / span > < span class = "pl-kos" > < < / span > < span class = "pl-ent" > td< / span > < span class = "pl-kos" > > < / span > 2< span class = "pl-kos" > < /< / span > < span class = "pl-ent" > td< / span > < span class = "pl-kos" > > < / span > < span class = "pl-kos" > < < / span > < span class = "pl-ent" > td< / span > < span class = "pl-kos" > > < / span > 3< span class = "pl-kos" > < /< / span > < span class = "pl-ent" > td< / span > < span class = "pl-kos" > > < / span > < span class = "pl-kos" > < < / span > < span class = "pl-ent" > td< / span > < span class = "pl-kos" > > < / span > 4< span class = "pl-kos" > < /< / span > < span class = "pl-ent" > td< / span > < span class = "pl-kos" > > < / span > < span class = "pl-kos" > < < / span > < span class = "pl-ent" > td< / span > < span class = "pl-kos" > > < / span > 5< span class = "pl-kos" > < /< / span > < span class = "pl-ent" > td< / span > < span class = "pl-kos" > > < / span > < span class = "pl-kos" > < < / span > < span class = "pl-ent" > td< / span > < span class = "pl-kos" > > < / span > 6< span class = "pl-kos" > < /< / span > < span class = "pl-ent" > td< / span > < span class = "pl-kos" > > < / span > < span class = "pl-kos" > < < / span > < span class = "pl-ent" > td< / span > < span class = "pl-kos" > > < / span > 7< span class = "pl-kos" > < /< / span > < span class = "pl-ent" > td< / span > < span class = "pl-kos" > > < / span > < span class = "pl-kos" > < /< / span > < span class = "pl-ent" > tr< / span > < span class = "pl-kos" > > < / span >
< span class = "pl-kos" > < < / span > < span class = "pl-ent" > tr< / span > < span class = "pl-kos" > > < / span > < span class = "pl-kos" > < < / span > < span class = "pl-ent" > td< / span > < span class = "pl-kos" > > < / span > 2< span class = "pl-kos" > < /< / span > < span class = "pl-ent" > td< / span > < span class = "pl-kos" > > < / span > < span class = "pl-kos" > < < / span > < span class = "pl-ent" > td< / span > < span class = "pl-kos" > > < / span > 3< span class = "pl-kos" > < /< / span > < span class = "pl-ent" > td< / span > < span class = "pl-kos" > > < / span > < span class = "pl-kos" > < < / span > < span class = "pl-ent" > td< / span > < span class = "pl-kos" > > < / span > 4< span class = "pl-kos" > < /< / span > < span class = "pl-ent" > td< / span > < span class = "pl-kos" > > < / span > < span class = "pl-kos" > < < / span > < span class = "pl-ent" > td< / span > < span class = "pl-kos" > > < / span > 5< span class = "pl-kos" > < /< / span > < span class = "pl-ent" > td< / span > < span class = "pl-kos" > > < / span > < span class = "pl-kos" > < < / span > < span class = "pl-ent" > td< / span > < span class = "pl-kos" > > < / span > 6< span class = "pl-kos" > < /< / span > < span class = "pl-ent" > td< / span > < span class = "pl-kos" > > < / span > < span class = "pl-kos" > < < / span > < span class = "pl-ent" > td< / span > < span class = "pl-kos" > > < / span > 7< span class = "pl-kos" > < /< / span > < span class = "pl-ent" > td< / span > < span class = "pl-kos" > > < / span > < span class = "pl-kos" > < < / span > < span class = "pl-ent" > td< / span > < span class = "pl-kos" > > < / span > 8< span class = "pl-kos" > < /< / span > < span class = "pl-ent" > td< / span > < span class = "pl-kos" > > < / span > < span class = "pl-kos" > < /< / span > < span class = "pl-ent" > tr< / span > < span class = "pl-kos" > > < / span >
< span class = "pl-kos" > < /< / span > < span class = "pl-ent" > table< / span > < span class = "pl-kos" > > < / span > < / pre > < / div >
2020-01-28 05:02:07 +00:00
< p > To process the table:< / p >
2021-08-27 00:16:16 +00:00
< div class = "highlight highlight-source-js" > < pre > < span class = "pl-k" > var< / span > < span class = "pl-s1" > tbl< / 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" > 'sheetjs'< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ;< / span >
< span class = "pl-k" > var< / span > < span class = "pl-s1" > wb< / 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" > tbl< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ;< / span > < / pre > < / div >
2020-01-28 05:02:07 +00:00
< / details >
< p > Note: < code > XLSX.read< / code > can handle HTML represented as strings.< / p >
2021-08-27 00:16:16 +00:00
< p > < code > XLSX.utils.sheet_add_dom< / code > takes a table DOM element and updates an existing
worksheet object. It follows the same process as < code > table_to_sheet< / code > and accepts
an options argument:< / p >
< table >
< thead >
< tr >
< th align = "left" > Option Name< / th >
< th align = "center" > Default< / th >
< th align = "left" > Description< / th >
< / tr >
< / thead >
< tbody >
< tr >
< td align = "left" > < code > raw< / code > < / td >
< td align = "center" > < / td >
< td align = "left" > If true, every cell will hold raw strings< / td >
< / tr >
< tr >
< td align = "left" > < code > dateNF< / code > < / td >
< td align = "center" > FMT 14< / td >
< td align = "left" > Use specified date format in string output< / td >
< / tr >
< tr >
< td align = "left" > < code > cellDates< / code > < / td >
< td align = "center" > false< / td >
< td align = "left" > Store dates as type < code > d< / code > (default is < code > n< / code > )< / td >
< / tr >
< tr >
< td align = "left" > < code > sheetRows< / code > < / td >
< td align = "center" > 0< / td >
< td align = "left" > If > 0, read the first < code > sheetRows< / code > rows of the table< / td >
< / tr >
< tr >
< td align = "left" > < code > display< / code > < / td >
< td align = "center" > false< / td >
< td align = "left" > If true, hidden rows and cells will not be parsed< / td >
< / tr >
< / tbody >
< / table >
< p > < code > origin< / code > is expected to be one of:< / p >
< table >
< thead >
< tr >
< th align = "left" > < code > origin< / code > < / th >
< th align = "left" > Description< / th >
< / tr >
< / thead >
< tbody >
< tr >
< td align = "left" > (cell object)< / td >
< td align = "left" > Use specified cell (cell object)< / td >
< / tr >
< tr >
< td align = "left" > (string)< / td >
< td align = "left" > Use specified cell (A1-style cell)< / td >
< / tr >
< tr >
< td align = "left" > (number > = 0)< / td >
< td align = "left" > Start from the first column at specified row (0-indexed)< / td >
< / tr >
< tr >
< td align = "left" > -1< / td >
< td align = "left" > Append to bottom of worksheet starting on first column< / td >
< / tr >
< tr >
< td align = "left" > (default)< / td >
< td align = "left" > Start from cell A1< / td >
< / tr >
< / tbody >
< / table >
< details >
< summary > < b > Examples< / b > (click to show)< / summary >
< p > A small helper function can create gap rows between tables:< / p >
< div class = "highlight highlight-source-js" > < pre > < span class = "pl-k" > function< / span > < span class = "pl-en" > create_gap_rows< / span > < span class = "pl-kos" > (< / span > < span class = "pl-s1" > ws< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s1" > nrows< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > {< / span >
< span class = "pl-k" > var< / span > < span class = "pl-s1" > ref< / 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" > decode_range< / span > < span class = "pl-kos" > (< / span > < span class = "pl-s1" > ws< / span > < span class = "pl-kos" > [< / span > < span class = "pl-s" > "!ref"< / span > < span class = "pl-kos" > ]< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ;< / span > < span class = "pl-c" > // get original range< / span >
< span class = "pl-s1" > ref< / span > < span class = "pl-kos" > .< / span > < span class = "pl-c1" > e< / span > < span class = "pl-kos" > .< / span > < span class = "pl-c1" > r< / span > < span class = "pl-c1" > +=< / span > < span class = "pl-s1" > nrows< / span > < span class = "pl-kos" > ;< / span > < span class = "pl-c" > // add to ending row< / span >
< span class = "pl-s1" > ws< / span > < span class = "pl-kos" > [< / span > < span class = "pl-s" > "!ref"< / span > < span class = "pl-kos" > ]< / 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" > encode_range< / span > < span class = "pl-kos" > (< / span > < span class = "pl-s1" > ref< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ;< / span > < span class = "pl-c" > // reassign row< / span >
< span class = "pl-kos" > }< / span >
< span class = "pl-c" > /* first table */< / span >
< span class = "pl-k" > var< / span > < span class = "pl-s1" > ws< / 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_sheet< / span > < span class = "pl-kos" > (< / 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" > 'table1'< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ;< / span >
< span class = "pl-en" > create_gap_rows< / span > < span class = "pl-kos" > (< / span > < span class = "pl-s1" > ws< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > 1< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ;< / span > < span class = "pl-c" > // one row gap after first table< / span >
< span class = "pl-c" > /* second table */< / 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_dom< / span > < span class = "pl-kos" > (< / span > < span class = "pl-s1" > ws< / span > < span class = "pl-kos" > ,< / 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" > 'table2'< / 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-en" > create_gap_rows< / span > < span class = "pl-kos" > (< / span > < span class = "pl-s1" > ws< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > 3< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ;< / span > < span class = "pl-c" > // three rows gap after second table< / span >
< span class = "pl-c" > /* third table */< / 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_dom< / span > < span class = "pl-kos" > (< / span > < span class = "pl-s1" > ws< / span > < span class = "pl-kos" > ,< / 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" > 'table3'< / 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 > < / pre > < / div >
< / details >
2020-01-28 05:02:07 +00:00
< h3 >
< a id = "user-content-formulae-output" class = "anchor" href = "#formulae-output" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > Formulae Output< / h3 >
< p > < code > XLSX.utils.sheet_to_formulae< / code > generates an array of commands that represent
how a person would enter data into an application. Each entry is of the form
< code > A1-cell-address=formula-or-value< / code > . String literals are prefixed with a < code > '< / code > in
accordance with Excel.< / p >
< details >
< summary > < b > Examples< / b > (click to show)< / summary >
< p > For the example sheet:< / p >
2021-08-27 00:16:16 +00:00
< div class = "highlight highlight-source-js" > < pre > < span class = "pl-c1" > > < / span > < span class = "pl-k" > var< / span > < span class = "pl-s1" > o< / 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" > sheet_to_formulae< / 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-c1" > > < / span > < span class = "pl-kos" > [< / span > < span class = "pl-s1" > o< / span > < span class = "pl-kos" > [< / span > < span class = "pl-c1" > 0< / span > < span class = "pl-kos" > ]< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s1" > o< / span > < span class = "pl-kos" > [< / span > < span class = "pl-c1" > 5< / span > < span class = "pl-kos" > ]< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s1" > o< / 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" > o< / span > < span class = "pl-kos" > [< / span > < span class = "pl-c1" > 15< / span > < span class = "pl-kos" > ]< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s1" > o< / span > < span class = "pl-kos" > [< / span > < span class = "pl-c1" > 20< / span > < span class = "pl-kos" > ]< / span > < span class = "pl-kos" > ]< / span > < span class = "pl-kos" > ;< / span >
< span class = "pl-kos" > [< / span > < span class = "pl-s" > 'A1=\'S'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > 'F1=\'J'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > 'D2=4'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > 'B3=3'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > 'G3=8'< / span > < span class = "pl-kos" > ]< / span > < / pre > < / div >
2020-01-28 05:02:07 +00:00
< / details >
< h3 >
< a id = "user-content-delimiter-separated-output" class = "anchor" href = "#delimiter-separated-output" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > Delimiter-Separated Output< / h3 >
< p > As an alternative to the < code > writeFile< / code > CSV type, < code > XLSX.utils.sheet_to_csv< / code > also
produces CSV output. The function takes an options argument:< / p >
< table >
< thead >
< tr >
< th align = "left" > Option Name< / th >
< th align = "center" > Default< / th >
< th align = "left" > Description< / th >
< / tr >
< / thead >
< tbody >
< tr >
< td align = "left" > < code > FS< / code > < / td >
< td align = "center" > < code > ","< / code > < / td >
< td align = "left" > "Field Separator" delimiter between fields< / td >
< / tr >
< tr >
< td align = "left" > < code > RS< / code > < / td >
< td align = "center" > < code > "\n"< / code > < / td >
< td align = "left" > "Record Separator" delimiter between rows< / td >
< / tr >
< tr >
< td align = "left" > < code > dateNF< / code > < / td >
< td align = "center" > FMT 14< / td >
< td align = "left" > Use specified date format in string output< / td >
< / tr >
< tr >
< td align = "left" > < code > strip< / code > < / td >
< td align = "center" > false< / td >
< td align = "left" > Remove trailing field separators in each record **< / td >
< / tr >
< tr >
< td align = "left" > < code > blankrows< / code > < / td >
< td align = "center" > true< / td >
< td align = "left" > Include blank lines in the CSV output< / td >
< / tr >
< tr >
< td align = "left" > < code > skipHidden< / code > < / td >
< td align = "center" > false< / td >
< td align = "left" > Skips hidden rows/columns in the CSV output< / td >
< / tr >
2021-08-27 00:16:16 +00:00
< tr >
< td align = "left" > < code > forceQuotes< / code > < / td >
< td align = "center" > false< / td >
< td align = "left" > Force quotes around fields< / td >
< / tr >
2020-01-28 05:02:07 +00:00
< / tbody >
< / table >
< ul >
< li >
< code > strip< / code > will remove trailing commas from each line under default < code > FS/RS< / code >
< / li >
< li >
< code > blankrows< / code > must be set to < code > false< / code > to skip blank lines.< / li >
2021-08-27 00:16:16 +00:00
< li > Fields containing the record or field separator will automatically be wrapped
in double quotes; < code > forceQuotes< / code > forces all cells to be wrapped in quotes.< / li >
2020-01-28 05:02:07 +00:00
< / ul >
< details >
< summary > < b > Examples< / b > (click to show)< / summary >
< p > For the example sheet:< / p >
2021-08-27 00:16:16 +00:00
< div class = "highlight highlight-source-js" > < pre > < span class = "pl-c1" > > < / span > < span class = "pl-smi" > console< / span > < span class = "pl-kos" > .< / span > < span class = "pl-en" > log< / 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_to_csv< / 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-v" > S< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s1" > h< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s1" > e< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s1" > e< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s1" > t< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-v" > J< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-v" > S< / span >
< span class = "pl-c1" > 1< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > 2< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > 3< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > 4< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > 5< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > 6< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > 7< / span >
< span class = "pl-c1" > 2< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > 3< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > 4< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > 5< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > 6< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > 7< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > 8< / span >
< span class = "pl-c1" > > < / span > < span class = "pl-smi" > console< / span > < span class = "pl-kos" > .< / span > < span class = "pl-en" > log< / 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_to_csv< / 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-c1" > FS< / span > :< span class = "pl-s" > "\t"< / span > < span class = "pl-kos" > }< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ;< / span >
< span class = "pl-v" > S< / span > < span class = "pl-s1" > h< / span > < span class = "pl-s1" > e< / span > < span class = "pl-s1" > e< / span > < span class = "pl-s1" > t< / span > < span class = "pl-v" > J< / span > < span class = "pl-v" > S< / span >
2020-01-28 05:02:07 +00:00
< span class = "pl-c1" > 1< / span > < span class = "pl-c1" > 2< / span > < span class = "pl-c1" > 3< / span > < span class = "pl-c1" > 4< / span > < span class = "pl-c1" > 5< / span > < span class = "pl-c1" > 6< / span > < span class = "pl-c1" > 7< / span >
< span class = "pl-c1" > 2< / span > < span class = "pl-c1" > 3< / span > < span class = "pl-c1" > 4< / span > < span class = "pl-c1" > 5< / span > < span class = "pl-c1" > 6< / span > < span class = "pl-c1" > 7< / span > < span class = "pl-c1" > 8< / span >
2021-08-27 00:16:16 +00:00
< span class = "pl-c1" > > < / span > < span class = "pl-smi" > console< / span > < span class = "pl-kos" > .< / span > < span class = "pl-en" > log< / 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_to_csv< / 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-c1" > FS< / span > :< span class = "pl-s" > ":"< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > RS< / span > :< span class = "pl-s" > "|"< / span > < span class = "pl-kos" > }< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > )< / span > < span class = "pl-kos" > ;< / span >
< span class = "pl-v" > S< / span > :< span class = "pl-s1" > h< / span > :< span class = "pl-s1" > e< / span > :< span class = "pl-s1" > e< / span > :< span class = "pl-s1" > t< / span > :< span class = "pl-v" > J< / span > :< span class = "pl-v" > S< / span > < span class = "pl-c1" > |< / span > < span class = "pl-c1" > 1< / span > :< span class = "pl-c1" > 2< / span > :< span class = "pl-c1" > 3< / span > :< span class = "pl-c1" > 4< / span > :< span class = "pl-c1" > 5< / span > :< span class = "pl-c1" > 6< / span > :< span class = "pl-c1" > 7< / span > < span class = "pl-c1" > |< / span > < span class = "pl-c1" > 2< / span > :< span class = "pl-c1" > 3< / span > :< span class = "pl-c1" > 4< / span > :< span class = "pl-c1" > 5< / span > :< span class = "pl-c1" > 6< / span > :< span class = "pl-c1" > 7< / span > :< span class = "pl-c1" > 8< / span > < span class = "pl-c1" > |< / span > < / pre > < / div >
2020-01-28 05:02:07 +00:00
< / details >
< h4 >
< a id = "user-content-utf-16-unicode-text" class = "anchor" href = "#utf-16-unicode-text" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > UTF-16 Unicode Text< / h4 >
< p > The < code > txt< / code > output type uses the tab character as the field separator. If the
< code > codepage< / code > library is available (included in full distribution but not core),
the output will be encoded in < code > CP1200< / code > and the BOM will be prepended.< / p >
< p > < code > XLSX.utils.sheet_to_txt< / code > takes the same arguments as < code > sheet_to_csv< / code > .< / p >
< h3 >
< a id = "user-content-html-output" class = "anchor" href = "#html-output" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > HTML Output< / h3 >
< p > As an alternative to the < code > writeFile< / code > HTML type, < code > XLSX.utils.sheet_to_html< / code > also
produces HTML output. The function takes an options argument:< / p >
< table >
< thead >
< tr >
< th align = "left" > Option Name< / th >
< th align = "center" > Default< / th >
< th align = "left" > Description< / th >
< / tr >
< / thead >
< tbody >
< tr >
< td align = "left" > < code > id< / code > < / td >
< td align = "center" > < / td >
< td align = "left" > Specify the < code > id< / code > attribute for the < code > TABLE< / code > element< / td >
< / tr >
< tr >
< td align = "left" > < code > editable< / code > < / td >
< td align = "center" > false< / td >
< td align = "left" > If true, set < code > contenteditable="true"< / code > for every TD< / td >
< / tr >
< tr >
< td align = "left" > < code > header< / code > < / td >
< td align = "center" > < / td >
< td align = "left" > Override header (default < code > html body< / code > )< / td >
< / tr >
< tr >
< td align = "left" > < code > footer< / code > < / td >
< td align = "center" > < / td >
< td align = "left" > Override footer (default < code > /body /html< / code > )< / td >
< / tr >
< / tbody >
< / table >
< details >
< summary > < b > Examples< / b > (click to show)< / summary >
< p > For the example sheet:< / p >
2021-08-27 00:16:16 +00:00
< div class = "highlight highlight-source-js" > < pre > < span class = "pl-c1" > > < / span > < span class = "pl-smi" > console< / span > < span class = "pl-kos" > .< / span > < span class = "pl-en" > log< / 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_to_html< / 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-c" > // ...< / span > < / pre > < / div >
2020-01-28 05:02:07 +00:00
< / details >
< h3 >
< a id = "user-content-json" class = "anchor" href = "#json" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > JSON< / h3 >
< p > < code > XLSX.utils.sheet_to_json< / code > generates different types of JS objects. The function
takes an options argument:< / p >
< table >
< thead >
< tr >
< th align = "left" > Option Name< / th >
< th align = "center" > Default< / th >
< th align = "left" > Description< / th >
< / tr >
< / thead >
< tbody >
< tr >
< td align = "left" > < code > raw< / code > < / td >
< td align = "center" > < code > true< / code > < / td >
< td align = "left" > Use raw values (true) or formatted strings (false)< / td >
< / tr >
< tr >
< td align = "left" > < code > range< / code > < / td >
< td align = "center" > from WS< / td >
< td align = "left" > Override Range (see table below)< / td >
< / tr >
< tr >
< td align = "left" > < code > header< / code > < / td >
< td align = "center" > < / td >
< td align = "left" > Control output format (see table below)< / td >
< / tr >
< tr >
< td align = "left" > < code > dateNF< / code > < / td >
< td align = "center" > FMT 14< / td >
< td align = "left" > Use specified date format in string output< / td >
< / tr >
< tr >
< td align = "left" > < code > defval< / code > < / td >
< td align = "center" > < / td >
< td align = "left" > Use specified value in place of null or undefined< / td >
< / tr >
< tr >
< td align = "left" > < code > blankrows< / code > < / td >
< td align = "center" > **< / td >
< td align = "left" > Include blank lines in the output **< / td >
< / tr >
< / tbody >
< / table >
< ul >
< li >
< code > raw< / code > only affects cells which have a format code (< code > .z< / code > ) field or a formatted
text (< code > .w< / code > ) field.< / li >
< li > If < code > header< / code > is specified, the first row is considered a data row; if < code > header< / code >
is not specified, the first row is the header row and not considered data.< / li >
< li > When < code > header< / code > is not specified, the conversion will automatically disambiguate
header entries by affixing < code > _< / code > and a count starting at < code > 1< / code > . For example, if
three columns have header < code > foo< / code > the output fields are < code > foo< / code > , < code > foo_1< / code > , < code > foo_2< / code >
< / li >
< li >
< code > null< / code > values are returned when < code > raw< / code > is true but are skipped when false.< / li >
< li > If < code > defval< / code > is not specified, null and undefined values are skipped normally.
If specified, all null and undefined points will be filled with < code > defval< / code >
< / li >
< li > When < code > header< / code > is < code > 1< / code > , the default is to generate blank rows. < code > blankrows< / code > must
be set to < code > false< / code > to skip blank rows.< / li >
< li > When < code > header< / code > is not < code > 1< / code > , the default is to skip blank rows. < code > blankrows< / code > must
be true to generate blank rows< / li >
< / ul >
< p > < code > range< / code > is expected to be one of:< / p >
< table >
< thead >
< tr >
< th align = "left" > < code > range< / code > < / th >
< th align = "left" > Description< / th >
< / tr >
< / thead >
< tbody >
< tr >
< td align = "left" > (number)< / td >
< td align = "left" > Use worksheet range but set starting row to the value< / td >
< / tr >
< tr >
< td align = "left" > (string)< / td >
< td align = "left" > Use specified range (A1-style bounded range string)< / td >
< / tr >
< tr >
< td align = "left" > (default)< / td >
< td align = "left" > Use worksheet range (< code > ws['!ref']< / code > )< / td >
< / tr >
< / tbody >
< / table >
< p > < code > header< / code > is expected to be one of:< / p >
< table >
< thead >
< tr >
< th align = "left" > < code > header< / code > < / th >
< th align = "left" > Description< / th >
< / tr >
< / thead >
< tbody >
< tr >
< td align = "left" > < code > 1< / code > < / td >
< td align = "left" > Generate an array of arrays ("2D Array")< / td >
< / tr >
< tr >
< td align = "left" > < code > "A"< / code > < / td >
< td align = "left" > Row object keys are literal column labels< / td >
< / tr >
< tr >
< td align = "left" > array of strings< / td >
< td align = "left" > Use specified strings as keys in row objects< / td >
< / tr >
< tr >
< td align = "left" > (default)< / td >
< td align = "left" > Read and disambiguate first row as keys< / td >
< / tr >
< / tbody >
< / table >
< p > If header is not < code > 1< / code > , the row object will contain the non-enumerable property
< code > __rowNum__< / code > that represents the row of the sheet corresponding to the entry.< / p >
< details >
< summary > < b > Examples< / b > (click to show)< / summary >
< p > For the example sheet:< / p >
2021-08-27 00:16:16 +00:00
< div class = "highlight highlight-source-js" > < pre > < 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" > sheet_to_json< / 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-kos" > {< / span > < span class = "pl-c1" > S< / span > : < span class = "pl-c1" > 1< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > h< / span > : < span class = "pl-c1" > 2< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > e< / span > : < span class = "pl-c1" > 3< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > e_1< / span > : < span class = "pl-c1" > 4< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > t< / span > : < span class = "pl-c1" > 5< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > J< / span > : < span class = "pl-c1" > 6< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > S_1< / span > : < span class = "pl-c1" > 7< / span > < span class = "pl-kos" > }< / span > < span class = "pl-kos" > ,< / span >
< span class = "pl-kos" > {< / span > < span class = "pl-c1" > S< / span > : < span class = "pl-c1" > 2< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > h< / span > : < span class = "pl-c1" > 3< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > e< / span > : < span class = "pl-c1" > 4< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > e_1< / span > : < span class = "pl-c1" > 5< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > t< / span > : < span class = "pl-c1" > 6< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > J< / span > : < span class = "pl-c1" > 7< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > S_1< / span > : < span class = "pl-c1" > 8< / span > < span class = "pl-kos" > }< / span > < span class = "pl-kos" > ]< / span >
2020-01-28 05:02:07 +00:00
2021-08-27 00:16:16 +00:00
< 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" > sheet_to_json< / 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-c1" > header< / span > :< span class = "pl-s" > "A"< / 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" > A< / span > : < span class = "pl-s" > 'S'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > B< / span > : < span class = "pl-s" > 'h'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > C< / span > : < span class = "pl-s" > 'e'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > D< / span > : < span class = "pl-s" > 'e'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > E< / span > : < span class = "pl-s" > 't'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > F< / span > : < span class = "pl-s" > 'J'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > G< / span > : < span class = "pl-s" > 'S'< / span > < span class = "pl-kos" > }< / span > < span class = "pl-kos" > ,< / span >
< span class = "pl-kos" > {< / span > < span class = "pl-c1" > A< / span > : < span class = "pl-s" > '1'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > B< / span > : < span class = "pl-s" > '2'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > C< / span > : < span class = "pl-s" > '3'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > D< / span > : < span class = "pl-s" > '4'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > E< / span > : < span class = "pl-s" > '5'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > F< / span > : < span class = "pl-s" > '6'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > G< / span > : < span class = "pl-s" > '7'< / span > < span class = "pl-kos" > }< / span > < span class = "pl-kos" > ,< / span >
< span class = "pl-kos" > {< / span > < span class = "pl-c1" > A< / span > : < span class = "pl-s" > '2'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > B< / span > : < span class = "pl-s" > '3'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > C< / span > : < span class = "pl-s" > '4'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > D< / span > : < span class = "pl-s" > '5'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > E< / span > : < span class = "pl-s" > '6'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > F< / span > : < span class = "pl-s" > '7'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > G< / span > : < span class = "pl-s" > '8'< / span > < span class = "pl-kos" > }< / span > < span class = "pl-kos" > ]< / span >
2020-01-28 05:02:07 +00:00
2021-08-27 00:16:16 +00:00
< 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" > sheet_to_json< / 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-c1" > header< / span > :< span class = "pl-kos" > [< / span > < span class = "pl-s" > "A"< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > "E"< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > "I"< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > "O"< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > "U"< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > "6"< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > "9"< / 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-s" > '6'< / span > : < span class = "pl-s" > 'J'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > '9'< / span > : < span class = "pl-s" > 'S'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > A< / span > : < span class = "pl-s" > 'S'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > E< / span > : < span class = "pl-s" > 'h'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > I< / span > : < span class = "pl-s" > 'e'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > O< / span > : < span class = "pl-s" > 'e'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > U< / span > : < span class = "pl-s" > 't'< / span > < span class = "pl-kos" > }< / span > < span class = "pl-kos" > ,< / span >
< span class = "pl-kos" > {< / span > < span class = "pl-s" > '6'< / span > : < span class = "pl-s" > '6'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > '9'< / span > : < span class = "pl-s" > '7'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > A< / span > : < span class = "pl-s" > '1'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > E< / span > : < span class = "pl-s" > '2'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > I< / span > : < span class = "pl-s" > '3'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > O< / span > : < span class = "pl-s" > '4'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > U< / span > : < span class = "pl-s" > '5'< / span > < span class = "pl-kos" > }< / span > < span class = "pl-kos" > ,< / span >
< span class = "pl-kos" > {< / span > < span class = "pl-s" > '6'< / span > : < span class = "pl-s" > '7'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > '9'< / span > : < span class = "pl-s" > '8'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > A< / span > : < span class = "pl-s" > '2'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > E< / span > : < span class = "pl-s" > '3'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > I< / span > : < span class = "pl-s" > '4'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > O< / span > : < span class = "pl-s" > '5'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > U< / span > : < span class = "pl-s" > '6'< / span > < span class = "pl-kos" > }< / span > < span class = "pl-kos" > ]< / span >
2020-01-28 05:02:07 +00:00
2021-08-27 00:16:16 +00:00
< 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" > sheet_to_json< / 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-c1" > header< / 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-kos" > [< / span > < span class = "pl-kos" > [< / span > < span class = "pl-s" > 'S'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > 'h'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > 'e'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > 'e'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > 't'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > 'J'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > 'S'< / span > < span class = "pl-kos" > ]< / span > < span class = "pl-kos" > ,< / span >
< span class = "pl-kos" > [< / span > < span class = "pl-s" > '1'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > '2'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > '3'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > '4'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > '5'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > '6'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > '7'< / span > < span class = "pl-kos" > ]< / span > < span class = "pl-kos" > ,< / span >
< span class = "pl-kos" > [< / span > < span class = "pl-s" > '2'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > '3'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > '4'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > '5'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > '6'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > '7'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > '8'< / span > < span class = "pl-kos" > ]< / span > < span class = "pl-kos" > ]< / span > < / pre > < / div >
2020-01-28 05:02:07 +00:00
< p > Example showing the effect of < code > raw< / code > :< / p >
2021-08-27 00:16:16 +00:00
< div class = "highlight highlight-source-js" > < pre > < span class = "pl-c1" > > < / span > < span class = "pl-s1" > ws< / span > < span class = "pl-kos" > [< / span > < span class = "pl-s" > 'A2'< / span > < span class = "pl-kos" > ]< / span > < span class = "pl-kos" > .< / span > < span class = "pl-c1" > w< / span > < span class = "pl-c1" > =< / span > < span class = "pl-s" > "3"< / span > < span class = "pl-kos" > ;< / span > < span class = "pl-c" > // set A2 formatted string value< / span >
2020-01-28 05:02:07 +00:00
2021-08-27 00:16:16 +00:00
< 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" > sheet_to_json< / 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-c1" > header< / span > :< span class = "pl-c1" > 1< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > raw< / span > :< span class = "pl-c1" > false< / 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-s" > 'S'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > 'h'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > 'e'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > 'e'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > 't'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > 'J'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > 'S'< / span > < span class = "pl-kos" > ]< / span > < span class = "pl-kos" > ,< / span >
< span class = "pl-kos" > [< / span > < span class = "pl-s" > '3'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > '2'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > '3'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > '4'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > '5'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > '6'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > '7'< / span > < span class = "pl-kos" > ]< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c" > // < -- A2 uses the formatted string< / span >
< span class = "pl-kos" > [< / span > < span class = "pl-s" > '2'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > '3'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > '4'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > '5'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > '6'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > '7'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > '8'< / span > < span class = "pl-kos" > ]< / span > < span class = "pl-kos" > ]< / span >
2020-01-28 05:02:07 +00:00
2021-08-27 00:16:16 +00:00
< 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" > sheet_to_json< / 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-c1" > header< / 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-kos" > [< / span > < span class = "pl-kos" > [< / span > < span class = "pl-s" > 'S'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > 'h'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > 'e'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > 'e'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > 't'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > 'J'< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-s" > 'S'< / span > < span class = "pl-kos" > ]< / span > < span class = "pl-kos" > ,< / span >
< span class = "pl-kos" > [< / span > < span class = "pl-c1" > 1< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > 2< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > 3< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > 4< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > 5< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > 6< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > 7< / span > < span class = "pl-kos" > ]< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c" > // < -- A2 uses the raw value< / span >
< span class = "pl-kos" > [< / span > < span class = "pl-c1" > 2< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > 3< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > 4< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > 5< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > 6< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > 7< / span > < span class = "pl-kos" > ,< / span > < span class = "pl-c1" > 8< / span > < span class = "pl-kos" > ]< / span > < span class = "pl-kos" > ]< / span > < / pre > < / div >
2020-01-28 05:02:07 +00:00
< / details >
< h2 >
< a id = "user-content-file-formats" class = "anchor" href = "#file-formats" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > File Formats< / h2 >
< p > Despite the library name < code > xlsx< / code > , it supports numerous spreadsheet file formats:< / p >
< table >
< thead >
< tr >
< th align = "left" > Format< / th >
< th align = "center" > Read< / th >
< th align = "center" > Write< / th >
< / tr >
< / thead >
< tbody >
< tr >
< td align = "left" > < strong > Excel Worksheet/Workbook Formats< / strong > < / td >
< td align = "center" > :-----:< / td >
< td align = "center" > :-----:< / td >
< / tr >
< tr >
< td align = "left" > Excel 2007+ XML Formats (XLSX/XLSM)< / td >
2021-08-27 00:16:16 +00:00
< td align = "center" > < g-emoji class = "g-emoji" alias = "o" fallback-src = "https://github.githubassets.com/images/icons/emoji/unicode/2b55.png" > ⭕< / g-emoji > < / td >
< td align = "center" > < g-emoji class = "g-emoji" alias = "o" fallback-src = "https://github.githubassets.com/images/icons/emoji/unicode/2b55.png" > ⭕< / g-emoji > < / td >
2020-01-28 05:02:07 +00:00
< / tr >
< tr >
< td align = "left" > Excel 2007+ Binary Format (XLSB BIFF12)< / td >
2021-08-27 00:16:16 +00:00
< td align = "center" > < g-emoji class = "g-emoji" alias = "o" fallback-src = "https://github.githubassets.com/images/icons/emoji/unicode/2b55.png" > ⭕< / g-emoji > < / td >
< td align = "center" > < g-emoji class = "g-emoji" alias = "o" fallback-src = "https://github.githubassets.com/images/icons/emoji/unicode/2b55.png" > ⭕< / g-emoji > < / td >
2020-01-28 05:02:07 +00:00
< / tr >
< tr >
< td align = "left" > Excel 2003-2004 XML Format (XML "SpreadsheetML")< / td >
2021-08-27 00:16:16 +00:00
< td align = "center" > < g-emoji class = "g-emoji" alias = "o" fallback-src = "https://github.githubassets.com/images/icons/emoji/unicode/2b55.png" > ⭕< / g-emoji > < / td >
< td align = "center" > < g-emoji class = "g-emoji" alias = "o" fallback-src = "https://github.githubassets.com/images/icons/emoji/unicode/2b55.png" > ⭕< / g-emoji > < / td >
2020-01-28 05:02:07 +00:00
< / tr >
< tr >
< td align = "left" > Excel 97-2004 (XLS BIFF8)< / td >
2021-08-27 00:16:16 +00:00
< td align = "center" > < g-emoji class = "g-emoji" alias = "o" fallback-src = "https://github.githubassets.com/images/icons/emoji/unicode/2b55.png" > ⭕< / g-emoji > < / td >
< td align = "center" > < g-emoji class = "g-emoji" alias = "o" fallback-src = "https://github.githubassets.com/images/icons/emoji/unicode/2b55.png" > ⭕< / g-emoji > < / td >
2020-01-28 05:02:07 +00:00
< / tr >
< tr >
< td align = "left" > Excel 5.0/95 (XLS BIFF5)< / td >
2021-08-27 00:16:16 +00:00
< td align = "center" > < g-emoji class = "g-emoji" alias = "o" fallback-src = "https://github.githubassets.com/images/icons/emoji/unicode/2b55.png" > ⭕< / g-emoji > < / td >
< td align = "center" > < g-emoji class = "g-emoji" alias = "o" fallback-src = "https://github.githubassets.com/images/icons/emoji/unicode/2b55.png" > ⭕< / g-emoji > < / td >
2020-01-28 05:02:07 +00:00
< / tr >
< tr >
< td align = "left" > Excel 4.0 (XLS/XLW BIFF4)< / td >
2021-08-27 00:16:16 +00:00
< td align = "center" > < g-emoji class = "g-emoji" alias = "o" fallback-src = "https://github.githubassets.com/images/icons/emoji/unicode/2b55.png" > ⭕< / g-emoji > < / td >
2020-01-28 05:02:07 +00:00
< td align = "center" > < / td >
< / tr >
< tr >
< td align = "left" > Excel 3.0 (XLS BIFF3)< / td >
2021-08-27 00:16:16 +00:00
< td align = "center" > < g-emoji class = "g-emoji" alias = "o" fallback-src = "https://github.githubassets.com/images/icons/emoji/unicode/2b55.png" > ⭕< / g-emoji > < / td >
2020-01-28 05:02:07 +00:00
< td align = "center" > < / td >
< / tr >
< tr >
< td align = "left" > Excel 2.0/2.1 (XLS BIFF2)< / td >
2021-08-27 00:16:16 +00:00
< td align = "center" > < g-emoji class = "g-emoji" alias = "o" fallback-src = "https://github.githubassets.com/images/icons/emoji/unicode/2b55.png" > ⭕< / g-emoji > < / td >
< td align = "center" > < g-emoji class = "g-emoji" alias = "o" fallback-src = "https://github.githubassets.com/images/icons/emoji/unicode/2b55.png" > ⭕< / g-emoji > < / td >
2020-01-28 05:02:07 +00:00
< / tr >
< tr >
< td align = "left" > < strong > Excel Supported Text Formats< / strong > < / td >
< td align = "center" > :-----:< / td >
< td align = "center" > :-----:< / td >
< / tr >
< tr >
< td align = "left" > Delimiter-Separated Values (CSV/TXT)< / td >
2021-08-27 00:16:16 +00:00
< td align = "center" > < g-emoji class = "g-emoji" alias = "o" fallback-src = "https://github.githubassets.com/images/icons/emoji/unicode/2b55.png" > ⭕< / g-emoji > < / td >
< td align = "center" > < g-emoji class = "g-emoji" alias = "o" fallback-src = "https://github.githubassets.com/images/icons/emoji/unicode/2b55.png" > ⭕< / g-emoji > < / td >
2020-01-28 05:02:07 +00:00
< / tr >
< tr >
< td align = "left" > Data Interchange Format (DIF)< / td >
2021-08-27 00:16:16 +00:00
< td align = "center" > < g-emoji class = "g-emoji" alias = "o" fallback-src = "https://github.githubassets.com/images/icons/emoji/unicode/2b55.png" > ⭕< / g-emoji > < / td >
< td align = "center" > < g-emoji class = "g-emoji" alias = "o" fallback-src = "https://github.githubassets.com/images/icons/emoji/unicode/2b55.png" > ⭕< / g-emoji > < / td >
2020-01-28 05:02:07 +00:00
< / tr >
< tr >
< td align = "left" > Symbolic Link (SYLK/SLK)< / td >
2021-08-27 00:16:16 +00:00
< td align = "center" > < g-emoji class = "g-emoji" alias = "o" fallback-src = "https://github.githubassets.com/images/icons/emoji/unicode/2b55.png" > ⭕< / g-emoji > < / td >
< td align = "center" > < g-emoji class = "g-emoji" alias = "o" fallback-src = "https://github.githubassets.com/images/icons/emoji/unicode/2b55.png" > ⭕< / g-emoji > < / td >
2020-01-28 05:02:07 +00:00
< / tr >
< tr >
< td align = "left" > Lotus Formatted Text (PRN)< / td >
2021-08-27 00:16:16 +00:00
< td align = "center" > < g-emoji class = "g-emoji" alias = "o" fallback-src = "https://github.githubassets.com/images/icons/emoji/unicode/2b55.png" > ⭕< / g-emoji > < / td >
< td align = "center" > < g-emoji class = "g-emoji" alias = "o" fallback-src = "https://github.githubassets.com/images/icons/emoji/unicode/2b55.png" > ⭕< / g-emoji > < / td >
2020-01-28 05:02:07 +00:00
< / tr >
< tr >
< td align = "left" > UTF-16 Unicode Text (TXT)< / td >
2021-08-27 00:16:16 +00:00
< td align = "center" > < g-emoji class = "g-emoji" alias = "o" fallback-src = "https://github.githubassets.com/images/icons/emoji/unicode/2b55.png" > ⭕< / g-emoji > < / td >
< td align = "center" > < g-emoji class = "g-emoji" alias = "o" fallback-src = "https://github.githubassets.com/images/icons/emoji/unicode/2b55.png" > ⭕< / g-emoji > < / td >
2020-01-28 05:02:07 +00:00
< / tr >
< tr >
< td align = "left" > < strong > Other Workbook/Worksheet Formats< / strong > < / td >
< td align = "center" > :-----:< / td >
< td align = "center" > :-----:< / td >
< / tr >
< tr >
< td align = "left" > OpenDocument Spreadsheet (ODS)< / td >
2021-08-27 00:16:16 +00:00
< td align = "center" > < g-emoji class = "g-emoji" alias = "o" fallback-src = "https://github.githubassets.com/images/icons/emoji/unicode/2b55.png" > ⭕< / g-emoji > < / td >
< td align = "center" > < g-emoji class = "g-emoji" alias = "o" fallback-src = "https://github.githubassets.com/images/icons/emoji/unicode/2b55.png" > ⭕< / g-emoji > < / td >
2020-01-28 05:02:07 +00:00
< / tr >
< tr >
< td align = "left" > Flat XML ODF Spreadsheet (FODS)< / td >
2021-08-27 00:16:16 +00:00
< td align = "center" > < g-emoji class = "g-emoji" alias = "o" fallback-src = "https://github.githubassets.com/images/icons/emoji/unicode/2b55.png" > ⭕< / g-emoji > < / td >
< td align = "center" > < g-emoji class = "g-emoji" alias = "o" fallback-src = "https://github.githubassets.com/images/icons/emoji/unicode/2b55.png" > ⭕< / g-emoji > < / td >
2020-01-28 05:02:07 +00:00
< / tr >
< tr >
< td align = "left" > Uniform Office Format Spreadsheet (标文通 UOS1/UOS2)< / td >
2021-08-27 00:16:16 +00:00
< td align = "center" > < g-emoji class = "g-emoji" alias = "o" fallback-src = "https://github.githubassets.com/images/icons/emoji/unicode/2b55.png" > ⭕< / g-emoji > < / td >
2020-01-28 05:02:07 +00:00
< td align = "center" > < / td >
< / tr >
< tr >
< td align = "left" > dBASE II/III/IV / Visual FoxPro (DBF)< / td >
2021-08-27 00:16:16 +00:00
< td align = "center" > < g-emoji class = "g-emoji" alias = "o" fallback-src = "https://github.githubassets.com/images/icons/emoji/unicode/2b55.png" > ⭕< / g-emoji > < / td >
< td align = "center" > < g-emoji class = "g-emoji" alias = "o" fallback-src = "https://github.githubassets.com/images/icons/emoji/unicode/2b55.png" > ⭕< / g-emoji > < / td >
2020-01-28 05:02:07 +00:00
< / tr >
< tr >
< td align = "left" > Lotus 1-2-3 (WKS/WK1/WK2/WK3/WK4/123)< / td >
2021-08-27 00:16:16 +00:00
< td align = "center" > < g-emoji class = "g-emoji" alias = "o" fallback-src = "https://github.githubassets.com/images/icons/emoji/unicode/2b55.png" > ⭕< / g-emoji > < / td >
2020-01-28 05:02:07 +00:00
< td align = "center" > < / td >
< / tr >
< tr >
< td align = "left" > Quattro Pro Spreadsheet (WQ1/WQ2/WB1/WB2/WB3/QPW)< / td >
2021-08-27 00:16:16 +00:00
< td align = "center" > < g-emoji class = "g-emoji" alias = "o" fallback-src = "https://github.githubassets.com/images/icons/emoji/unicode/2b55.png" > ⭕< / g-emoji > < / td >
2020-01-28 05:02:07 +00:00
< td align = "center" > < / td >
< / tr >
< tr >
< td align = "left" > < strong > Other Common Spreadsheet Output Formats< / strong > < / td >
< td align = "center" > :-----:< / td >
< td align = "center" > :-----:< / td >
< / tr >
< tr >
< td align = "left" > HTML Tables< / td >
2021-08-27 00:16:16 +00:00
< td align = "center" > < g-emoji class = "g-emoji" alias = "o" fallback-src = "https://github.githubassets.com/images/icons/emoji/unicode/2b55.png" > ⭕< / g-emoji > < / td >
< td align = "center" > < g-emoji class = "g-emoji" alias = "o" fallback-src = "https://github.githubassets.com/images/icons/emoji/unicode/2b55.png" > ⭕< / g-emoji > < / td >
2020-01-28 05:02:07 +00:00
< / tr >
< tr >
< td align = "left" > Rich Text Format tables (RTF)< / td >
< td align = "center" > < / td >
2021-08-27 00:16:16 +00:00
< td align = "center" > < g-emoji class = "g-emoji" alias = "o" fallback-src = "https://github.githubassets.com/images/icons/emoji/unicode/2b55.png" > ⭕< / g-emoji > < / td >
2020-01-28 05:02:07 +00:00
< / tr >
< tr >
< td align = "left" > Ethercalc Record Format (ETH)< / td >
2021-08-27 00:16:16 +00:00
< td align = "center" > < g-emoji class = "g-emoji" alias = "o" fallback-src = "https://github.githubassets.com/images/icons/emoji/unicode/2b55.png" > ⭕< / g-emoji > < / td >
< td align = "center" > < g-emoji class = "g-emoji" alias = "o" fallback-src = "https://github.githubassets.com/images/icons/emoji/unicode/2b55.png" > ⭕< / g-emoji > < / td >
2020-01-28 05:02:07 +00:00
< / tr >
< / tbody >
< / table >
< p > Features not supported by a given file format will not be written. Formats with
range limits will be silently truncated:< / p >
< table >
< thead >
< tr >
< th align = "left" > Format< / th >
< th align = "left" > Last Cell< / th >
< th align = "right" > Max Cols< / th >
< th align = "right" > Max Rows< / th >
< / tr >
< / thead >
< tbody >
< tr >
< td align = "left" > Excel 2007+ XML Formats (XLSX/XLSM)< / td >
< td align = "left" > XFD1048576< / td >
< td align = "right" > 16384< / td >
< td align = "right" > 1048576< / td >
< / tr >
< tr >
< td align = "left" > Excel 2007+ Binary Format (XLSB BIFF12)< / td >
< td align = "left" > XFD1048576< / td >
< td align = "right" > 16384< / td >
< td align = "right" > 1048576< / td >
< / tr >
< tr >
< td align = "left" > Excel 97-2004 (XLS BIFF8)< / td >
< td align = "left" > IV65536< / td >
< td align = "right" > 256< / td >
< td align = "right" > 65536< / td >
< / tr >
< tr >
< td align = "left" > Excel 5.0/95 (XLS BIFF5)< / td >
< td align = "left" > IV16384< / td >
< td align = "right" > 256< / td >
< td align = "right" > 16384< / td >
< / tr >
< tr >
< td align = "left" > Excel 2.0/2.1 (XLS BIFF2)< / td >
< td align = "left" > IV16384< / td >
< td align = "right" > 256< / td >
< td align = "right" > 16384< / td >
< / tr >
< / tbody >
< / table >
< p > Excel 2003 SpreadsheetML range limits are governed by the version of Excel and
are not enforced by the writer.< / p >
< h3 >
< a id = "user-content-excel-2007-xml-xlsxxlsm" class = "anchor" href = "#excel-2007-xml-xlsxxlsm" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > Excel 2007+ XML (XLSX/XLSM)< / h3 >
< details >
< summary > (click to show)< / summary >
< p > XLSX and XLSM files are ZIP containers containing a series of XML files in
accordance with the Open Packaging Conventions (OPC). The XLSM format, almost
identical to XLSX, is used for files containing macros.< / p >
< p > The format is standardized in ECMA-376 and later in ISO/IEC 29500. Excel does
not follow the specification, and there are additional documents discussing how
Excel deviates from the specification.< / p >
< / details >
< h3 >
< a id = "user-content-excel-20-95-biff2biff3biff4biff5" class = "anchor" href = "#excel-20-95-biff2biff3biff4biff5" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > Excel 2.0-95 (BIFF2/BIFF3/BIFF4/BIFF5)< / h3 >
< details >
< summary > (click to show)< / summary >
< p > BIFF 2/3 XLS are single-sheet streams of binary records. Excel 4 introduced
the concept of a workbook (< code > XLW< / code > files) but also had single-sheet < code > XLS< / code > format.
The structure is largely similar to the Lotus 1-2-3 file formats. BIFF5/8/12
extended the format in various ways but largely stuck to the same record format.< / p >
< p > There is no official specification for any of these formats. Excel 95 can write
files in these formats, so record lengths and fields were determined by writing
in all of the supported formats and comparing files. Excel 2016 can generate
BIFF5 files, enabling a full suite of file tests starting from XLSX or BIFF2.< / p >
< / details >
< h3 >
< a id = "user-content-excel-97-2004-binary-biff8" class = "anchor" href = "#excel-97-2004-binary-biff8" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > Excel 97-2004 Binary (BIFF8)< / h3 >
< details >
< summary > (click to show)< / summary >
< p > BIFF8 exclusively uses the Compound File Binary container format, splitting some
content into streams within the file. At its core, it still uses an extended
version of the binary record format from older versions of BIFF.< / p >
< p > The < code > MS-XLS< / code > specification covers the basics of the file format, and other
specifications expand on serialization of features like properties.< / p >
< / details >
< h3 >
< a id = "user-content-excel-2003-2004-spreadsheetml" class = "anchor" href = "#excel-2003-2004-spreadsheetml" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > Excel 2003-2004 (SpreadsheetML)< / h3 >
< details >
< summary > (click to show)< / summary >
< p > Predating XLSX, SpreadsheetML files are simple XML files. There is no official
and comprehensive specification, although MS has released documentation on the
format. Since Excel 2016 can generate SpreadsheetML files, mapping features is
pretty straightforward.< / p >
< / details >
< h3 >
< a id = "user-content-excel-2007-binary-xlsb-biff12" class = "anchor" href = "#excel-2007-binary-xlsb-biff12" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > Excel 2007+ Binary (XLSB, BIFF12)< / h3 >
< details >
< summary > (click to show)< / summary >
< p > Introduced in parallel with XLSX, the XLSB format combines the BIFF architecture
with the content separation and ZIP container of XLSX. For the most part nodes
in an XLSX sub-file can be mapped to XLSB records in a corresponding sub-file.< / p >
< p > The < code > MS-XLSB< / code > specification covers the basics of the file format, and other
specifications expand on serialization of features like properties.< / p >
< / details >
< h3 >
< a id = "user-content-delimiter-separated-values-csvtxt" class = "anchor" href = "#delimiter-separated-values-csvtxt" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > Delimiter-Separated Values (CSV/TXT)< / h3 >
< details >
< summary > (click to show)< / summary >
< p > Excel CSV deviates from RFC4180 in a number of important ways. The generated
CSV files should generally work in Excel although they may not work in RFC4180
compatible readers. The parser should generally understand Excel CSV. The
writer proactively generates cells for formulae if values are unavailable.< / p >
< p > Excel TXT uses tab as the delimiter and code page 1200.< / p >
< p > Notes:< / p >
< ul >
< li > Like in Excel, files starting with < code > 0x49 0x44 ("ID")< / code > are treated as Symbolic
Link files. Unlike Excel, if the file does not have a valid SYLK header, it
will be proactively reinterpreted as CSV. There are some files with semicolon
delimiter that align with a valid SYLK file. For the broadest compatibility,
all cells with the value of < code > ID< / code > are automatically wrapped in double-quotes.< / li >
< / ul >
< / details >
< h3 >
< a id = "user-content-other-workbook-formats" class = "anchor" href = "#other-workbook-formats" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > Other Workbook Formats< / h3 >
< details >
< summary > (click to show)< / summary >
< p > Support for other formats is generally far XLS/XLSB/XLSX support, due in large
part to a lack of publicly available documentation. Test files were produced in
the respective apps and compared to their XLS exports to determine structure.
The main focus is data extraction.< / p >
< / details >
< h4 >
< a id = "user-content-lotus-1-2-3-wkswk1wk2wk3wk4123" class = "anchor" href = "#lotus-1-2-3-wkswk1wk2wk3wk4123" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > Lotus 1-2-3 (WKS/WK1/WK2/WK3/WK4/123)< / h4 >
< details >
< summary > (click to show)< / summary >
< p > The Lotus formats consist of binary records similar to the BIFF structure. Lotus
did release a specification decades ago covering the original WK1 format. Other
features were deduced by producing files and comparing to Excel support.< / p >
< / details >
< h4 >
< a id = "user-content-quattro-pro-wq1wq2wb1wb2wb3qpw" class = "anchor" href = "#quattro-pro-wq1wq2wb1wb2wb3qpw" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > Quattro Pro (WQ1/WQ2/WB1/WB2/WB3/QPW)< / h4 >
< details >
< summary > (click to show)< / summary >
< p > The Quattro Pro formats use binary records in the same way as BIFF and Lotus.
Some of the newer formats (namely WB3 and QPW) use a CFB enclosure just like
BIFF8 XLS.< / p >
< / details >
< h4 >
< a id = "user-content-opendocument-spreadsheet-odsfods" class = "anchor" href = "#opendocument-spreadsheet-odsfods" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > OpenDocument Spreadsheet (ODS/FODS)< / h4 >
< details >
< summary > (click to show)< / summary >
< p > ODS is an XML-in-ZIP format akin to XLSX while FODS is an XML format akin to
SpreadsheetML. Both are detailed in the OASIS standard, but tools like LO/OO
add undocumented extensions. The parsers and writers do not implement the full
standard, instead focusing on parts necessary to extract and store raw data.< / p >
< / details >
< h4 >
< a id = "user-content-uniform-office-spreadsheet-uos12" class = "anchor" href = "#uniform-office-spreadsheet-uos12" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > Uniform Office Spreadsheet (UOS1/2)< / h4 >
< details >
< summary > (click to show)< / summary >
< p > UOS is a very similar format, and it comes in 2 varieties corresponding to ODS
and FODS respectively. For the most part, the difference between the formats
is in the names of tags and attributes.< / p >
< / details >
< h3 >
< a id = "user-content-other-single-worksheet-formats" class = "anchor" href = "#other-single-worksheet-formats" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > Other Single-Worksheet Formats< / h3 >
< p > Many older formats supported only one worksheet:< / p >
< h4 >
< a id = "user-content-dbase-and-visual-foxpro-dbf" class = "anchor" href = "#dbase-and-visual-foxpro-dbf" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > dBASE and Visual FoxPro (DBF)< / h4 >
< details >
< summary > (click to show)< / summary >
< p > DBF is really a typed table format: each column can only hold one data type and
each record omits type information. The parser generates a header row and
inserts records starting at the second row of the worksheet. The writer makes
files compatible with Visual FoxPro extensions.< / p >
< p > Multi-file extensions like external memos and tables are currently unsupported,
limited by the general ability to read arbitrary files in the web browser. The
reader understands DBF Level 7 extensions like DATETIME.< / p >
< / details >
< h4 >
< a id = "user-content-symbolic-link-sylk" class = "anchor" href = "#symbolic-link-sylk" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > Symbolic Link (SYLK)< / h4 >
< details >
< summary > (click to show)< / summary >
< p > There is no real documentation. All knowledge was gathered by saving files in
various versions of Excel to deduce the meaning of fields. Notes:< / p >
< ul >
< li > Plain formulae are stored in the RC form.< / li >
< li > Column widths are rounded to integral characters.< / li >
< / ul >
< / details >
< h4 >
< a id = "user-content-lotus-formatted-text-prn" class = "anchor" href = "#lotus-formatted-text-prn" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > Lotus Formatted Text (PRN)< / h4 >
< details >
< summary > (click to show)< / summary >
< p > There is no real documentation, and in fact Excel treats PRN as an output-only
file format. Nevertheless we can guess the column widths and reverse-engineer
the original layout. Excel's 240 character width limitation is not enforced.< / p >
< / details >
< h4 >
< a id = "user-content-data-interchange-format-dif" class = "anchor" href = "#data-interchange-format-dif" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > Data Interchange Format (DIF)< / h4 >
< details >
< summary > (click to show)< / summary >
< p > There is no unified definition. Visicalc DIF differs from Lotus DIF, and both
differ from Excel DIF. Where ambiguous, the parser/writer follows the expected
behavior from Excel. In particular, Excel extends DIF in incompatible ways:< / p >
< ul >
< li > Since Excel automatically converts numbers-as-strings to numbers, numeric
string constants are converted to formulae: < code > "0.3" -> "=""0.3""< / code >
< / li >
< li > DIF technically expects numeric cells to hold the raw numeric data, but Excel
permits formatted numbers (including dates)< / li >
< li > DIF technically has no support for formulae, but Excel will automatically
convert plain formulae. Array formulae are not preserved.< / li >
< / ul >
< / details >
< h4 >
< a id = "user-content-html" class = "anchor" href = "#html" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > HTML< / h4 >
< details >
< summary > (click to show)< / summary >
< p > Excel HTML worksheets include special metadata encoded in styles. For example,
< code > mso-number-format< / code > is a localized string containing the number format. Despite
the metadata the output is valid HTML, although it does accept bare < code > & < / code > symbols.< / p >
< p > The writer adds type metadata to the TD elements via the < code > t< / code > tag. The parser
looks for those tags and overrides the default interpretation. For example, text
like < code > < td> 12345< /td> < / code > will be parsed as numbers but < code > < td t="s"> 12345< /td> < / code > will
be parsed as text.< / p >
< / details >
< h4 >
< a id = "user-content-rich-text-format-rtf" class = "anchor" href = "#rich-text-format-rtf" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > Rich Text Format (RTF)< / h4 >
< details >
< summary > (click to show)< / summary >
< p > Excel RTF worksheets are stored in clipboard when copying cells or ranges from a
worksheet. The supported codes are a subset of the Word RTF support.< / p >
< / details >
< h4 >
< a id = "user-content-ethercalc-record-format-eth" class = "anchor" href = "#ethercalc-record-format-eth" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > Ethercalc Record Format (ETH)< / h4 >
< details >
< summary > (click to show)< / summary >
< p > < a href = "https://ethercalc.net/" rel = "nofollow" > Ethercalc< / a > is an open source web spreadsheet powered by
a record format reminiscent of SYLK wrapped in a MIME multi-part message.< / p >
< / details >
< h2 >
< a id = "user-content-testing" class = "anchor" href = "#testing" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > Testing< / h2 >
< h3 >
< a id = "user-content-node" class = "anchor" href = "#node" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > Node< / h3 >
< details >
< summary > (click to show)< / summary >
< p > < code > make test< / code > will run the node-based tests. By default it runs tests on files in
every supported format. To test a specific file type, set < code > FMTS< / code > to the format
you want to test. Feature-specific tests are available with < code > make test_misc< / code > < / p >
< div class = "highlight highlight-source-shell" > < pre > $ make test_misc < span class = "pl-c" > < span class = "pl-c" > #< / span > run core tests< / span >
$ make < span class = "pl-c1" > test< / span > < span class = "pl-c" > < span class = "pl-c" > #< / span > run full tests< / span >
$ make test_xls < span class = "pl-c" > < span class = "pl-c" > #< / span > only use the XLS test files< / span >
$ make test_xlsx < span class = "pl-c" > < span class = "pl-c" > #< / span > only use the XLSX test files< / span >
$ make test_xlsb < span class = "pl-c" > < span class = "pl-c" > #< / span > only use the XLSB test files< / span >
$ make test_xml < span class = "pl-c" > < span class = "pl-c" > #< / span > only use the XML test files< / span >
$ make test_ods < span class = "pl-c" > < span class = "pl-c" > #< / span > only use the ODS test files< / span > < / pre > < / div >
< p > To enable all errors, set the environment variable < code > WTF=1< / code > :< / p >
< div class = "highlight highlight-source-shell" > < pre > $ make < span class = "pl-c1" > test< / span > < span class = "pl-c" > < span class = "pl-c" > #< / span > run full tests< / span >
$ WTF=1 make < span class = "pl-c1" > test< / span > < span class = "pl-c" > < span class = "pl-c" > #< / span > enable all error messages< / span > < / pre > < / div >
< p > < code > flow< / code > and < code > eslint< / code > checks are available:< / p >
< div class = "highlight highlight-source-shell" > < pre > $ make lint < span class = "pl-c" > < span class = "pl-c" > #< / span > eslint checks< / span >
$ make flow < span class = "pl-c" > < span class = "pl-c" > #< / span > make lint + Flow checking< / span >
$ make tslint < span class = "pl-c" > < span class = "pl-c" > #< / span > check TS definitions< / span > < / pre > < / div >
< / details >
< h3 >
< a id = "user-content-browser" class = "anchor" href = "#browser" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > Browser< / h3 >
< details >
< summary > (click to show)< / summary >
< p > The core in-browser tests are available at < code > tests/index.html< / code > within this repo.
Start a local server and navigate to that directory to run the tests.
< code > make ctestserv< / code > will start a server on port 8000.< / p >
< p > < code > make ctest< / code > will generate the browser fixtures. To add more files, edit the
< code > tests/fixtures.lst< / code > file and add the paths.< / p >
< p > To run the full in-browser tests, clone the repo for
< a href = "https://github.com/SheetJS/SheetJS.github.io" > < code > oss.sheetjs.com< / code > < / a > and replace
the < code > xlsx.js< / code > file (then open a browser window and go to < code > stress.html< / code > ):< / p >
< div class = "highlight highlight-source-shell" > < pre > $ cp xlsx.js ../SheetJS.github.io
$ < span class = "pl-c1" > cd< / span > ../SheetJS.github.io
$ simplehttpserver < span class = "pl-c" > < span class = "pl-c" > #< / span > or "python -mSimpleHTTPServer" or "serve"< / span >
$ open -a Chromium.app http://localhost:8000/stress.html< / pre > < / div >
< / details >
< h3 >
< a id = "user-content-tested-environments" class = "anchor" href = "#tested-environments" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > Tested Environments< / h3 >
< details >
< summary > (click to show)< / summary >
< ul >
< li > NodeJS < code > 0.8< / code > , < code > 0.10< / code > , < code > 0.12< / code > , < code > 4.x< / code > , < code > 5.x< / code > , < code > 6.x< / code > , < code > 7.x< / code > , < code > 8.x< / code >
< / li >
< li > IE 6/7/8/9/10/11 (IE 6-9 require shims)< / li >
< li > Chrome 24+ (including Android 4.0+)< / li >
< li > Safari 6+ (iOS and Desktop)< / li >
< li > Edge 13+, FF 18+, and Opera 12+< / li >
< / ul >
2021-08-27 00:16:16 +00:00
< p > Tests utilize the mocha testing framework.< / p >
2020-01-28 05:02:07 +00:00
< ul >
< li >
< a href = "https://saucelabs.com/u/sheetjs" rel = "nofollow" > https://saucelabs.com/u/sheetjs< / a > for XLS* modules using Sauce Labs< / li >
< / ul >
2021-08-27 00:16:16 +00:00
< p > The test suite also includes tests for various time zones. To change
2020-01-28 05:02:07 +00:00
the timezone locally, set the TZ environment variable:< / p >
< div class = "highlight highlight-source-shell" > < pre > $ env TZ=< span class = "pl-s" > < span class = "pl-pds" > "< / span > Asia/Kolkata< span class = "pl-pds" > "< / span > < / span > WTF=1 make test_misc< / pre > < / div >
< / details >
< h3 >
< a id = "user-content-test-files" class = "anchor" href = "#test-files" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > Test Files< / h3 >
< p > Test files are housed in < a href = "https://github.com/SheetJS/test_files" > another repo< / a > .< / p >
< p > Running < code > make init< / code > will refresh the < code > test_files< / code > submodule and get the files.
Note that this requires < code > svn< / code > , < code > git< / code > , < code > hg< / code > and other commands that may not be
available. If < code > make init< / code > fails, please download the latest version of the test
files snapshot from < a href = "https://github.com/SheetJS/test_files/releases" > the repo< / a > < / p >
< details >
< summary > < b > Latest Snapshot< / b > (click to show)< / summary >
< p > Latest test files snapshot:
< a href = "http://github.com/SheetJS/test_files/releases/download/20170409/test_files.zip" > http://github.com/SheetJS/test_files/releases/download/20170409/test_files.zip< / a > < / p >
< p > (download and unzip to the < code > test_files< / code > subdirectory)< / p >
< / details >
< h2 >
< a id = "user-content-contributing" class = "anchor" href = "#contributing" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > Contributing< / h2 >
< p > Due to the precarious nature of the Open Specifications Promise, it is very
important to ensure code is cleanroom. < a href = "CONTRIBUTING.md" > Contribution Notes< / a > < / p >
< details >
< summary > < b > File organization< / b > (click to show)< / summary >
< p > At a high level, the final script is a concatenation of the individual files in
the < code > bits< / code > folder. Running < code > make< / code > should reproduce the final output on all
platforms. The README is similarly split into bits in the < code > docbits< / code > folder.< / p >
< p > Folders:< / p >
< table >
< thead >
< tr >
< th align = "left" > folder< / th >
< th align = "left" > contents< / th >
< / tr >
< / thead >
< tbody >
< tr >
< td align = "left" > < code > bits< / code > < / td >
< td align = "left" > raw source files that make up the final script< / td >
< / tr >
< tr >
< td align = "left" > < code > docbits< / code > < / td >
< td align = "left" > raw markdown files that make up < code > README.md< / code >
< / td >
< / tr >
< tr >
< td align = "left" > < code > bin< / code > < / td >
< td align = "left" > server-side bin scripts (< code > xlsx.njs< / code > )< / td >
< / tr >
< tr >
< td align = "left" > < code > dist< / code > < / td >
< td align = "left" > dist files for web browsers and nonstandard JS environments< / td >
< / tr >
< tr >
< td align = "left" > < code > demos< / code > < / td >
< td align = "left" > demo projects for platforms like ExtendScript and Webpack< / td >
< / tr >
< tr >
< td align = "left" > < code > tests< / code > < / td >
< td align = "left" > browser tests (run < code > make ctest< / code > to rebuild)< / td >
< / tr >
< tr >
< td align = "left" > < code > types< / code > < / td >
< td align = "left" > typescript definitions and tests< / td >
< / tr >
< tr >
< td align = "left" > < code > misc< / code > < / td >
< td align = "left" > miscellaneous supporting scripts< / td >
< / tr >
< tr >
< td align = "left" > < code > test_files< / code > < / td >
< td align = "left" > test files (pulled from the test files repository)< / td >
< / tr >
< / tbody >
< / table >
< / details >
< p > After cloning the repo, running < code > make help< / code > will display a list of commands.< / p >
< h3 >
< a id = "user-content-osxlinux" class = "anchor" href = "#osxlinux" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > OSX/Linux< / h3 >
< details >
< summary > (click to show)< / summary >
< p > The < code > xlsx.js< / code > file is constructed from the files in the < code > bits< / code > subdirectory. The
build script (run < code > make< / code > ) will concatenate the individual bits to produce the
script. Before submitting a contribution, ensure that running make will produce
the < code > xlsx.js< / code > file exactly. The simplest way to test is to add the script:< / p >
< div class = "highlight highlight-source-shell" > < pre > $ git add xlsx.js
$ make clean
$ make
$ git diff xlsx.js< / pre > < / div >
< p > To produce the dist files, run < code > make dist< / code > . The dist files are updated in each
version release and < em > should not be committed between versions< / em > .< / p >
< / details >
< h3 >
< a id = "user-content-windows" class = "anchor" href = "#windows" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > Windows< / h3 >
< details >
< summary > (click to show)< / summary >
< p > The included < code > make.cmd< / code > script will build < code > xlsx.js< / code > from the < code > bits< / code > directory.
Building is as simple as:< / p >
< div class = "highlight highlight-source-batchfile" > < pre > < span class = "pl-k" > > < / span > make< / pre > < / div >
< p > To prepare development environment:< / p >
< div class = "highlight highlight-source-batchfile" > < pre > < span class = "pl-k" > > < / span > make init< / pre > < / div >
< p > The full list of commands available in Windows are displayed in < code > make help< / code > :< / p >
< pre > < code > make init -- install deps and global modules
make lint -- run eslint linter
make test -- run mocha test suite
make misc -- run smaller test suite
make book -- rebuild README and summary
make help -- display this message
< / code > < / pre >
< p > As explained in < a href = "#test-files" > Test Files< / a > , on Windows the release ZIP file must
be downloaded and extracted. If Bash on Windows is available, it is possible
to run the OSX/Linux workflow. The following steps prepares the environment:< / p >
< div class = "highlight highlight-source-shell" > < pre > < span class = "pl-c" > < span class = "pl-c" > #< / span > Install support programs for the build and test commands< / span >
sudo apt-get install make git subversion mercurial
< span class = "pl-c" > < span class = "pl-c" > #< / span > Install nodejs and NPM within the WSL< / span >
wget -qO- https://deb.nodesource.com/setup_8.x < span class = "pl-k" > |< / span > sudo bash
sudo apt-get install nodejs
< span class = "pl-c" > < span class = "pl-c" > #< / span > Install dev dependencies< / span >
sudo npm install -g mocha voc blanket xlsjs< / pre > < / div >
< / details >
< h3 >
< a id = "user-content-tests" class = "anchor" href = "#tests" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > Tests< / h3 >
< details >
< summary > (click to show)< / summary >
< p > The < code > test_misc< / code > target (< code > make test_misc< / code > on Linux/OSX / < code > make misc< / code > on Windows)
runs the targeted feature tests. It should take 5-10 seconds to perform feature
tests without testing against the entire test battery. New features should be
accompanied with tests for the relevant file formats and features.< / p >
< p > For tests involving the read side, an appropriate feature test would involve
reading an existing file and checking the resulting workbook object. If a
parameter is involved, files should be read with different values to verify that
the feature is working as expected.< / p >
< p > For tests involving a new write feature which can already be parsed, appropriate
feature tests would involve writing a workbook with the feature and then opening
and verifying that the feature is preserved.< / p >
< p > For tests involving a new write feature without an existing read ability, please
add a feature test to the kitchen sink < code > tests/write.js< / code > .< / p >
< / details >
< h2 >
< a id = "user-content-license" class = "anchor" href = "#license" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > License< / h2 >
< p > Please consult the attached LICENSE file for details. All rights not explicitly
granted by the Apache 2.0 License are reserved by the Original Author.< / p >
< h2 >
< a id = "user-content-references" class = "anchor" href = "#references" aria-hidden = "true" > < span aria-hidden = "true" class = "octicon octicon-link" > < / span > < / a > References< / h2 >
< details >
< summary > < b > OSP-covered Specifications< / b > (click to show)< / summary >
< ul >
< li >
< code > MS-CFB< / code > : Compound File Binary File Format< / li >
< li >
< code > MS-CTXLS< / code > : Excel Custom Toolbar Binary File Format< / li >
< li >
< code > MS-EXSPXML3< / code > : Excel Calculation Version 2 Web Service XML Schema< / li >
< li >
< code > MS-ODATA< / code > : Open Data Protocol (OData)< / li >
< li >
< code > MS-ODRAW< / code > : Office Drawing Binary File Format< / li >
< li >
< code > MS-ODRAWXML< / code > : Office Drawing Extensions to Office Open XML Structure< / li >
< li >
< code > MS-OE376< / code > : Office Implementation Information for ECMA-376 Standards Support< / li >
< li >
< code > MS-OFFCRYPTO< / code > : Office Document Cryptography Structure< / li >
< li >
< code > MS-OI29500< / code > : Office Implementation Information for ISO/IEC 29500 Standards Support< / li >
< li >
< code > MS-OLEDS< / code > : Object Linking and Embedding (OLE) Data Structures< / li >
< li >
< code > MS-OLEPS< / code > : Object Linking and Embedding (OLE) Property Set Data Structures< / li >
< li >
< code > MS-OODF3< / code > : Office Implementation Information for ODF 1.2 Standards Support< / li >
< li >
< code > MS-OSHARED< / code > : Office Common Data Types and Objects Structures< / li >
< li >
< code > MS-OVBA< / code > : Office VBA File Format Structure< / li >
< li >
< code > MS-XLDM< / code > : Spreadsheet Data Model File Format< / li >
< li >
< code > MS-XLS< / code > : Excel Binary File Format (.xls) Structure Specification< / li >
< li >
< code > MS-XLSB< / code > : Excel (.xlsb) Binary File Format< / li >
< li >
< code > MS-XLSX< / code > : Excel (.xlsx) Extensions to the Office Open XML SpreadsheetML File Format< / li >
< li >
< code > XLS< / code > : Microsoft Office Excel 97-2007 Binary File Format Specification< / li >
< li >
< code > RTF< / code > : Rich Text Format< / li >
< / ul >
< / details >
< ul >
< li > ISO/IEC 29500:2012(E) "Information technology — Document description and processing languages — Office Open XML File Formats"< / li >
< li > Open Document Format for Office Applications Version 1.2 (29 September 2011)< / li >
< li > Worksheet File Format (From Lotus) December 1984< / li >
< / ul >
< / article >
< / div >
< / div >
< / div >
< / div >
< / div >
< div > < / div >
< / div > < script >
function showCanonicalImages() {
var images = document.getElementsByTagName('img');
if (!images) {
return;
}
for (var index = 0; index < images.length ; index + + ) {
var image = images[index];
if (image.getAttribute('data-canonical-src') & & image.src !== image.getAttribute('data-canonical-src')) {
image.src = image.getAttribute('data-canonical-src');
}
}
}
function scrollToHash() {
if (location.hash & & !document.querySelector(':target')) {
var element = document.getElementById('user-content-' + location.hash.slice(1));
if (element) {
element.scrollIntoView();
}
}
}
function autorefreshContent(eventSourceUrl) {
var initialTitle = document.title;
var contentElement = document.getElementById('grip-content');
var source = new EventSource(eventSourceUrl);
var isRendering = false;
source.onmessage = function(ev) {
var msg = JSON.parse(ev.data);
if (msg.updating) {
isRendering = true;
document.title = '(Rendering) ' + document.title;
} else {
isRendering = false;
document.title = initialTitle;
contentElement.innerHTML = msg.content;
showCanonicalImages();
}
}
source.onerror = function(e) {
if (e.readyState === EventSource.CLOSED & & isRendering) {
isRendering = false;
document.title = initialTitle;
}
}
}
window.onhashchange = function() {
scrollToHash();
}
window.onload = function() {
scrollToHash();
}
showCanonicalImages();
var autorefreshUrl = document.getElementById('preview-page').getAttribute('data-autorefresh-url');
if (autorefreshUrl) {
autorefreshContent(autorefreshUrl);
}
< / script >
< / body >
< / html >