0.0.9 • Published 1 year ago

typexlsx v0.0.9

Weekly downloads
-
License
-
Repository
github
Last release
1 year ago

favicon

typexlsx

Write *.xlsx files in a browser or Node.js

🚨 in development 🚨

Demo

Features

  • small
  • styles
    • fonts
    • fill
    • border
    • formats
  • types
    • string
    • number
    • date

Install

with npm:

npm install typexlsx

with yarn:

yarn add typexlsx

to save the blob you could for example use file-saver

Use

to write an *.xlsx file, provide the sheet data, each cell having a type, style and a value:

import {saveAs} from 'file-saver';
import generateXlsx from '../src/typexlsx';

const sheet: Sheet = {
    name: 'TestFile',
    rows: [
        [{value: 'A'}, {value: 'B'}, {value: 'C'}],
        [{value: 1}, {value: 2}, {value: 3}],
    ],
};

generateXlsx(TEST_FILE)
    .then((blob) => saveAs(blob, 'Workbook.xlsx'))
    .catch((err) => console.error(err));

Api

Workbook

Workbook is an array of Sheets.

Sheet

NameTypeDescription
name?stringname of Sheet
rowsRow[]array of rows

Row

A Row is an array of Cells

Cell

NameTypeDescription
value?string / number / boolean / Datecell value
align?left / center / righttext align
alignVertical?top / center / bottomvertical align
wrap?booleantext wrap
format?stringnumber or date format
span?numbercol span
rowSpan?numberrow span
fill?stringbackground hex color
font?XLSXFontfont styles
border?BorderStylesborder styles

XLSXFont

NameTypeDescription
style?'bold' / 'italic' / 'none'font style
size?numberfont size
family?stringfont family
color?stringhex color

XLSXBorder

NameTypeDescription
color?stringhex color
style?XLSXBorderStyleborder style

XLSXBorders

NameTypeDescription
start?XLSXBorderleft border style
end?XLSXBorderright border style
top?XLSXBordertop border style
bottom?XLSXBorderbottom border style
diagonal?XLSXBorderdiagonal border style

XLSXBorderStyle

  • thin
  • medium
  • thick
  • dotted
  • hair
  • dashed
  • mediumDashed
  • dashDot
  • mediumDashDot
  • dashDotDot
  • mediumDashDotDot
  • slantDashDot

XLSX Date / Number Format

Source

Format
0
0.00
#,##0
#,##0.00
0%
0.00%
m/d/yy
d-mmm-yy
d-mmm
mmm-yy
h:mm AM/PM
h:mm:ss AM/PM
h:mm
h:mm:ss
m/d/yy h:mm
0.0.9

1 year ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago