npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

netas-csv2xlsx

v1.0.0

Published

JavaScript csv to spreadsheet (xlsx) converter

Downloads

5

Readme

csv2xlsx

JavaScript csv to spreadsheet (xlsx) converter. Converts columns automatically to the correct column type and formats the data as a table, which allows simple filtering of data.

parameter documentation

Csv2Xlsx.convertCsv(csvUrl, filename, metaData, charset, updateFn, returnAsLink, csvSeparator, formatCodes)
    @param {String} csvUrl              URL to fetch the csv from
    @param {String} filename            of the generated file
    @param {Object} metaData            metaData of the generated xlsx
                     > .title
                     > .subject
                     > .creator
                     > .company
                     > .lastModifiedBy
                     > .created         (Date object, default to now)
                     > .modified        (Date object, default to now)

    @param {String} charset             charset of CSV, default to Windows-1252
    @param {Function} updateFn          you can set a callback function to receive status informations.
    @param {Bool} returnAsLink          false, to return a Blob url as string instead of a <a> element
    @param {String} csvSeparator        csv separator, null for auto
    @param {Object} formatCodes         excel format codes. defaults to
                     > .date: 'dd.mm.yyyy'
                     > .datetime: 'dd.mm.yyyy hh:mm'
                     > .number: '0'
                     > .float: '0.0'

    @return {Promise} which resolves to {String|Element} Blob URL or Element depending on {returnAsLink}, default to String

example code

async function downloadAsExcel() {
    const cvrt = await import('src/Csv2Xlsx.js');

    // Meta-Data of the xlsx
    const metaData = {
        title: 'My Demo Spreadsheet',
        subject: 'A Demo for CSV to XLSX',
        creator: 'John Doe',
        company: 'Super Doe Ltd.',
        lastModifiedBy: 'John Doe',
        created: new Date(2020, 0, 1, 11, 21),
        modified: null // now
    };

    // download the csv and convert it to a excel file
    const aTag = await cvrt.Csv2Xlsx.convertCsv('my/demo/data.csv', 'mynewfilename.xlsx', metaData);

    // return value is a <a> element, add it to the DOM to start the download
    document.body.appendChild(aTag);

    // start the download automatically
    aTag.click();
}

browser support

the latest versions of

  • Firefox (Gecko)
  • Chrome/Edge (Blink)
  • Safari (Webkit)

demo

check out _demo/demo.html for a simple demo

license

Copyright © 2024 Lukas Buchs, netas.ch, Apache License, Version 2.0.

used third party code

  • https://github.com/Neovici/nullxlsx Copyright © 2020 Neovici, Apache License 2.0
  • https://github.com/FlatFilers/csvjson-csv2json Copyright © 2019 Martin Drapeau, MIT License