
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
excel-to-sqlite
Advanced tools
Convert excel documents to sqlite!
Navigation
Firstly, load the package.
const excelToSqlite = require("excel-to-sqlite");
The export of excel-to-sqlite
is one function, with one parameter: excelPath
.
The path must me absolute, like __dirname
. This example uses path
.
const path = require("path");
let excelPath = path.join(__dirname, "test.xlsx"); // File "test.xlsx" in the current directory
let excel = excelToSqlite(excelPath);
After you used the excelToSqlite
function, you can use the property sheets
to get a string array of all the sheet names.
let sheets = excel.sheets;
console.log(sheets);
To read one sheet, use the method readSheet
afer you used the excelToSqlite
function. It has one parameter: The name of the sheet.
The name of the sheet is case-sensitive!
let sheet = excel.readSheet("Sheet1"); // Read "Sheet1".
To get the data of the current sheet, use the property data
on sheet
.
let data = sheet.data;
To get the json data, use the method getJSON
.
let json = sheet.getJSON();
[
Sheet1: [
{column_1_name: "value", column_2_name: "value", ...},
{column_1_name: "value", column_2_name: "value", ...}
]
]
To save the current sheet to sqlite, use the saveTo
method. It has one parameter: The name of the sqlite file.
Warning: When saving to a database, a table with the same name as the current sheet will get deleted.
To change the name of the table in the sqlite database, set sheet._name
to another string before calling the saveTo
function.
This function returns a promise, that will be resolved with a database object of sqlite3
.
// Save without changing the name
sheet.saveTo("database.sqlite").then((database) => {
console.log(`Sheet ${sheet._name} saved in "database.sqlite"!`);
});
// Change the name for the table and then save
sheet._name = "lol";
sheet.saveTo("database.sqlite").then((database) => {
console.log(`Sheet ${sheet._name} saved in "database.sqlite"!`);
});
To read all the sheets in an excel, use the readAll
method.
let sheets = excel.readAll();
To get all the data of all the sheets, use the property data
. To convert your data to JSON, use the method getJSON
.
let data = sheets.data;
let json = sheets.getJSON();
Output: See Output
To save the whole excel in sqlite, use the saveTo
method. It has one parameter, the name of the database.
This function returns a promise, that will be resolved with a database object of sqlite3
.
Warning: When saving to a database, a table with the same name as a sheet will get deleted.
sheets.saveTo("database.sqlite").then((database) => {
console.log("Whole database saved in sqlite!");
});
The property _xlsx
is the output of xlsx.readFile
.
FAQs
Convert excel documents to sqlite!
The npm package excel-to-sqlite receives a total of 1 weekly downloads. As such, excel-to-sqlite popularity was classified as not popular.
We found that excel-to-sqlite demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.