Skip to content

Commit e409d95

Browse files
committed
Merge branch 'release/v0.1.3'
2 parents acf585a + 7adec83 commit e409d95

File tree

3 files changed

+46
-27
lines changed

3 files changed

+46
-27
lines changed

README.md

Lines changed: 43 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,56 @@
22

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

79
npm i fastexcel
810

11+
npm i -D cargo-cp-artifact
12+
913
### Example
1014

1115
```
12-
const fs = require('fs');
16+
// index.js
17+
const path = require('path');
1318
const { CsvFileWriter, Converter } = require("fastexcel");
1419
15-
// Part 1: Put Data to CSV/Text
16-
const writer = new CsvFileWriter("./test/source-lib.csv", [
17-
"No",
18-
"Name",
19-
"Gender",
20-
]);
21-
22-
const rows = [
23-
[1, "John", "Male"],
24-
[2, "Doe", "Male"],
25-
];
26-
27-
for (const row of rows) {
28-
await writer.write(row);
29-
}
30-
31-
await writer.close();
32-
33-
// Part 2: Convert csv to excel
34-
const res = await Converter.toXLSX(
35-
"./test/source-lib.csv",
36-
"./test/result-lib.xlsx",
37-
);
20+
const main = async () => {
21+
const src = path.join(process.cwd(), 'example/source.csv');
22+
const dst = path.join(process.cwd(), 'example/generated.xlsx');
23+
24+
console.log('src', src);
25+
console.log('dst', dst);
26+
27+
const cols = [];
28+
const totalCols = 200;
29+
for (let i = 0; i < totalCols; i++) {
30+
cols.push('Col ' + (i+1));
31+
}
32+
33+
const writer = new CsvFileWriter(src, cols);
34+
35+
const totalRows = 1000000; // 1jt rows
36+
for (let i = 0; i < totalRows; i++) {
37+
let row = [];
38+
39+
for (let i = 0; i < totalCols; i++) {
40+
row.push('Col No ' + (i+1));
41+
}
42+
43+
row.push(row);
44+
await writer.write(row);
45+
}
46+
47+
await writer.close();
48+
49+
// Part 2: Convert csv to excel
50+
const res = await Converter.toXLSX(
51+
src,
52+
dst
53+
);
54+
};
55+
56+
main();
3857
```

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "fastexcel",
3-
"version": "0.1.2",
3+
"version": "0.1.3",
44
"description": "Fast and efficient large excel file writer",
55
"main": "dist/index.js",
66
"scripts": {

0 commit comments

Comments
 (0)