Skip to content

Commit 5bc0370

Browse files
committed
Merge branch 'release/v0.1.4'
2 parents e409d95 + cf51a88 commit 5bc0370

File tree

4 files changed

+29
-32
lines changed

4 files changed

+29
-32
lines changed

README.md

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,30 @@
11
# FastExcel
22

3-
> This project using [Neon](https://neon-bindings.com) as a binding to Rust to execute fast and efficient memory usage for generating XLSX document.
3+
> This project need Rust to be installed, check here for [Rust installation instruction](https://www.rust-lang.org/tools/install)
44
5-
> Check here for [Rust installation instruction](https://www.rust-lang.org/tools/install)
5+
> This project using [Rust](https://www.rust-lang.org) and [Neon](https://neon-bindings.com) as a binding to Rust to execute fast and efficient memory usage for generating XLSX document from NodeJs.
6+
7+
> This project cannot be executed via NVM based NodeJs, you should deactivate (via `nvm deactivate`) and use a normal version installation of NodeJs.
8+
9+
Writing a large amount of data into Excel file is not a trivial task when you have a limited memory (RAM) allocated. Especially when working at a small node on the server. This library is created to solve that problem, using the efficiency of Rust while generating XLSX from CSV.
610

711
### Installation
812

13+
npm i -D cargo-cp-artifact
14+
915
npm i fastexcel
1016

11-
npm i -D cargo-cp-artifact
17+
### How it works
1218

13-
### Example
19+
1. Generate the CSV
20+
2. Convert the CSV to XLSX
1421

15-
```
16-
// index.js
22+
The CSV generation is happen on the NodeJs side, and converting XLSX file is on Rust side (via Neon)
23+
24+
### Example Usage
25+
26+
```js
27+
// dummy-excel.js
1728
const path = require('path');
1829
const { CsvFileWriter, Converter } = require("fastexcel");
1930

@@ -25,14 +36,14 @@ const main = async () => {
2536
console.log('dst', dst);
2637

2738
const cols = [];
28-
const totalCols = 200;
39+
const totalCols = 200; // 200 columns
2940
for (let i = 0; i < totalCols; i++) {
3041
cols.push('Col ' + (i+1));
3142
}
3243

3344
const writer = new CsvFileWriter(src, cols);
3445

35-
const totalRows = 1000000; // 1jt rows
46+
const totalRows = 1_000_000; // 1 million rows
3647
for (let i = 0; i < totalRows; i++) {
3748
let row = [];
3849

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: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
{
22
"name": "fastexcel",
3-
"version": "0.1.3",
3+
"version": "0.1.4",
44
"description": "Fast and efficient large excel file writer",
55
"main": "dist/index.js",
6+
"repository": {
7+
"type": "git",
8+
"url": "git+https://github.com/slaveofcode/fastexcel.git"
9+
},
610
"scripts": {
711
"build": "cargo-cp-artifact -nc index.node -- cargo build --message-format=json-render-diagnostics",
812
"build-debug": "npm run build --",
@@ -22,5 +26,6 @@
2226
"writer",
2327
"streaming",
2428
"office"
25-
]
29+
],
30+
"homepage": "https://github.com/slaveofcode/fastexcel#readme"
2631
}

src/lib.rs

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::{fs::File, error::Error, io::{Read, BufReader, BufRead, Write}, fmt::Display};
1+
use std::{fs::File, io::{BufReader, BufRead, Write}, fmt::Display};
22
use neon::{prelude::*};
33
use simple_xlsx_writer::{WorkBook, Row as XLSRow, Cell};
44

@@ -11,25 +11,6 @@ impl<'a> Display for Row<'a> {
1111
}
1212
}
1313

14-
#[allow(dead_code)]
15-
fn read_file_buffer(filepath: String) -> Result<(), Box<dyn Error>> {
16-
const BUFFER_LEN: usize = 512;
17-
let mut buffer = [0u8; BUFFER_LEN];
18-
let mut file = File::open(filepath)?;
19-
20-
loop {
21-
let read_count = file.read(&mut buffer)?;
22-
let buff = &buffer[..read_count];
23-
let line = String::from_utf8_lossy(buff);
24-
println!("line: {}", line);
25-
26-
if read_count != BUFFER_LEN {
27-
break;
28-
}
29-
}
30-
Ok(())
31-
}
32-
3314
fn read_file_liner<F>(filepath: String, fn_operation: &mut F) -> Result<(), std::io::Error>
3415
where
3516
F: FnMut(&mut Row) -> Result<(), std::io::Error> {

0 commit comments

Comments
 (0)