1.3.8 • Published 1 year ago

@ailnaf/xlsx2csv v1.3.8

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

xlsx2csv

xlsx2csv for browser and nodejs with performance considered

demo

Install

npm i @ailnaf/xlsx2csv

Usage

esm

import xlsx2csv from '@ailnaf/xlsx2csv'

cdn

<script src="https://unpkg.com/@ailnaf/xlsx2csv/xlsx2csv.min.js"></script>

cjs

const { default: xlsx2csv } = await import('@ailnaf/xlsx2csv')

nodejs

const filename = 'data.xlsx'

xlsx2csv(filename, console.log)

browser

const buffer = await fetch('data.xlsx').then(res => res.blob())

xlsx2csv(buffer, console.log, { sheet: { max: 100 } })

// [ 'hello', 'world' ]
// [ 'bar', 'foo' ]


const rows = await xlsx2csv(buffer, null, { sheet: { max: 100, collect: true } })
console.log(rows)

// [ [ 'hello', 'world' ], [ 'bar', 'foo' ] ]

const rows = await xlsx2csv(buffer, null, { sheet: { max: 100, collect: true, json: true } })
console.log(rows)

// [ { hello: 'bar', world: 'foo' } ]

export xlsx

for small files browser and nodejs

import csv2xlsx from '@ailnaf/xlsx2csv/csv2xlsx'

const source = [
    ['number1', 'number2', 'hello', 'number3', null, 'date', 'list'],
    [12.7, 12.8, 'world', '100', null, new Date(), [1,2,3]],
]

csv2xlsx(source)
.then(buf => {
    console.log(buf)
})
.catch(console.log)

Test

# all data
node test.js data.xlsx

# 1 row
node test.js data.xlsx 1

License

MIT

1.3.7

1 year ago

1.3.6

2 years ago

1.3.5

2 years ago

1.3.4

2 years ago

1.3.8

1 year ago

1.3.3

2 years ago

1.3.2

2 years ago

1.3.1

2 years ago

1.3.0

2 years ago

1.2.3

2 years ago

1.2.2

2 years ago

1.2.1

2 years ago

1.2.0

2 years ago

1.1.10

2 years ago

1.1.9

2 years ago

1.1.8

2 years ago

1.1.7

2 years ago

1.1.6

2 years ago

1.1.5

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.0

2 years ago