Skip to content

Commit

Permalink
Merge branch 'release/v0.1.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
slaveofcode committed Dec 12, 2022
2 parents acf585a + 7adec83 commit e409d95
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 27 deletions.
67 changes: 43 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,56 @@

> This project using [Neon](https://neon-bindings.com) as a binding to Rust to execute fast and efficient memory usage for generating XLSX document.
> Check here for [Rust installation instruction](https://www.rust-lang.org/tools/install)
### Installation

npm i fastexcel

npm i -D cargo-cp-artifact

### Example

```
const fs = require('fs');
// index.js
const path = require('path');
const { CsvFileWriter, Converter } = require("fastexcel");
// Part 1: Put Data to CSV/Text
const writer = new CsvFileWriter("./test/source-lib.csv", [
"No",
"Name",
"Gender",
]);
const rows = [
[1, "John", "Male"],
[2, "Doe", "Male"],
];
for (const row of rows) {
await writer.write(row);
}
await writer.close();
// Part 2: Convert csv to excel
const res = await Converter.toXLSX(
"./test/source-lib.csv",
"./test/result-lib.xlsx",
);
const main = async () => {
const src = path.join(process.cwd(), 'example/source.csv');
const dst = path.join(process.cwd(), 'example/generated.xlsx');
console.log('src', src);
console.log('dst', dst);
const cols = [];
const totalCols = 200;
for (let i = 0; i < totalCols; i++) {
cols.push('Col ' + (i+1));
}
const writer = new CsvFileWriter(src, cols);
const totalRows = 1000000; // 1jt rows
for (let i = 0; i < totalRows; i++) {
let row = [];
for (let i = 0; i < totalCols; i++) {
row.push('Col No ' + (i+1));
}
row.push(row);
await writer.write(row);
}
await writer.close();
// Part 2: Convert csv to excel
const res = await Converter.toXLSX(
src,
dst
);
};
main();
```
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fastexcel",
"version": "0.1.2",
"version": "0.1.3",
"description": "Fast and efficient large excel file writer",
"main": "dist/index.js",
"scripts": {
Expand Down

0 comments on commit e409d95

Please sign in to comment.