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 🙏

© 2026 – Pkg Stats / Ryan Hefner

pg-ninja-excel

v1.1.0

Published

Node.js lightweight asynchronous library for export PostgreSQL queries (SELECT) to Excel

Downloads

1

Readme

pg-ninja-excel

Node.js lightweight asynchronous library for export PostgreSQL queries (SELECT) to Excel

navigation

installation


$ npm i pg-ninja-excel

usage


additional library for pg-ninja that add option convert result of SELECT query into Excel file.

Import

import excel from 'pg-ninja-excel'

const converter = new excel();

constructor

new converter(max_width: int, wrap_words: boolean)

max-width defines width of column (auto-fit columns by width from 11 to your width). default value - 50.

wrap-words defines words wrapping. default value - true. in case of big responce values better would be stay with false.


create_file_name

generate file name for your PostgreSQL report

syntax:

converter.create_file_name(): string

returns string of new file name in format: postgresql-report-{DATE}T{TIME}-{XXXXX}.xlsx, for example - postgresql-report-11-27-2024T8_19_56AM-3qcj6.xlsx


pg_to_excel

creates Excel file from your object of PostgreSQL responce.

syntax:

converter.pg_to_excel(rows, path='./'): Promise<string/object>

result:

resolve - path to file with file name (string)
reject - error

in case of you want to create Excel depends on something different, but not PostgreSQL responce, template of rows:

[
    {key: value, ..., key:value},
    ...
    {key: value, ..., key:value}
]

and also you can specify path. default path ./ means file will be near to your script. change directory, for example ./report/ and if you want to create your own file you can write name by yourself, for example ./report/test1.xlsx. otherwise always use / in end of your path!

** ! do not return reject-available function ! **

Example

with using pg-ninja (install pg-ninja with $ npm install pg-ninja)

import pg from 'pg-ninja';
import excel from 'pg-ninja-excel';

const database = new pg({
    connectionString: process.env.PG_CONNECTION
});
const converter = new excel();

database.query('SELECT * FROM customers;').then(res => {
    excel.pg_to_excel(res?.rows).then(res => {
        console.log('Excel report was created in this path and file name: ', res);
    }, err => {
        console.log('Excel error: ', err);
    });
}, err => {
    console.log('PostgreSQL error: ', err);
});

Summary

in benefits of this variant it sets auto filters, adding borders to columns, pin the first row (so you always remember what you see), setting width of columns and same to word wrapping.