1.3.8 • Published 3 years ago
@ailnaf/xlsx2csv v1.3.8
xlsx2csv
xlsx2csv for browser and nodejs with performance considered
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
3 years ago
1.3.6
3 years ago
1.3.5
3 years ago
1.3.4
3 years ago
1.3.8
3 years ago
1.3.3
3 years ago
1.3.2
3 years ago
1.3.1
3 years ago
1.3.0
3 years ago
1.2.3
3 years ago
1.2.2
3 years ago
1.2.1
3 years ago
1.2.0
3 years ago
1.1.10
3 years ago
1.1.9
3 years ago
1.1.8
3 years ago
1.1.7
3 years ago
1.1.6
3 years ago
1.1.5
3 years ago
1.1.4
3 years ago
1.1.3
3 years ago
1.1.2
3 years ago
1.1.1
3 years ago
1.1.0
3 years ago
1.0.0
3 years ago