Skip to content

fanlia/xlsx2csv

Folders and files

NameName
Last commit message
Last commit date
Jul 17, 2022
May 8, 2024
Jul 17, 2022
Jul 15, 2022
Oct 22, 2022
Aug 6, 2022
Aug 7, 2022
Jul 15, 2022
Jul 21, 2022
Oct 22, 2022
Jul 21, 2022
Jun 10, 2024
Jun 10, 2024
Jul 16, 2022
Aug 7, 2022
Oct 10, 2022
Oct 22, 2022
Oct 10, 2022
Oct 22, 2022
Aug 1, 2023
Dec 16, 2022
Aug 7, 2022
Jul 21, 2022

Repository files navigation

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

About

xlsx2csv for browser and nodejs

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published