Skip to content

Commit 8e5bec8

Browse files
committed
Implement XLSX init support in MiniExcel
- Add error handling with custom error types in `error.rs`. - Create core library structure in `lib.rs` with modules for cell handling, error management, options, reading, writing, and serialization helpers. - Define `ReadOptions` and `WriteOptions` in `options.rs` for configuring read/write behavior. - Implement `XlsxReader` in `reader.rs` for reading XLSX files, including dynamic row handling and deserialization. - Add serialization helpers in `serde_helpers.rs` for date, time, and duration types. - Implement `XlsxWriter` in `writer.rs` for writing XLSX files, including schema validation and cell formatting. - Create common test utilities in `common/mod.rs` for file path handling. - Add tests for reading dynamic and typed rows, handling empty rows, and round-trip writing/reading of XLSX files. - Set Rust toolchain version and formatting options in `rust-toolchain.toml` and `rustfmt.toml`.
1 parent 1d22a55 commit 8e5bec8

25 files changed

Lines changed: 2623 additions & 0 deletions

‎.github/workflows/rust.yml‎

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: Rust
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- "rust/**"
7+
- "tests/data/xlsx/**"
8+
- ".github/workflows/rust.yml"
9+
push:
10+
branches: [master]
11+
paths:
12+
- "rust/**"
13+
- "tests/data/xlsx/**"
14+
- ".github/workflows/rust.yml"
15+
16+
permissions:
17+
contents: read
18+
19+
env:
20+
CARGO_TERM_COLOR: always
21+
22+
jobs:
23+
quality:
24+
runs-on: ubuntu-latest
25+
steps:
26+
- uses: actions/checkout@v4
27+
- name: Install stable Rust
28+
uses: dtolnay/rust-toolchain@stable
29+
with:
30+
components: clippy, rustfmt
31+
- uses: Swatinem/rust-cache@v2
32+
with:
33+
workspaces: rust -> target
34+
- name: Check formatting
35+
run: cargo fmt --manifest-path rust/Cargo.toml --all -- --check
36+
- name: Run Clippy
37+
run: cargo clippy --manifest-path rust/Cargo.toml --workspace --all-targets --locked -- -D warnings
38+
- name: Build documentation
39+
run: cargo doc --manifest-path rust/Cargo.toml --workspace --no-deps --locked
40+
env:
41+
RUSTDOCFLAGS: -D warnings
42+
43+
test:
44+
strategy:
45+
matrix:
46+
os: [ubuntu-latest, windows-latest]
47+
runs-on: ${{ matrix.os }}
48+
steps:
49+
- uses: actions/checkout@v4
50+
- name: Install stable Rust
51+
uses: dtolnay/rust-toolchain@stable
52+
- uses: Swatinem/rust-cache@v2
53+
with:
54+
workspaces: rust -> target
55+
- name: Run tests
56+
run: cargo test --manifest-path rust/Cargo.toml --workspace --all-targets --locked
57+
58+
msrv:
59+
runs-on: ubuntu-latest
60+
steps:
61+
- uses: actions/checkout@v4
62+
- name: Install Rust 1.85.0
63+
uses: dtolnay/rust-toolchain@1.85.0
64+
- uses: Swatinem/rust-cache@v2
65+
with:
66+
workspaces: rust -> target
67+
key: msrv
68+
- name: Check minimum supported Rust version
69+
run: cargo check --manifest-path rust/Cargo.toml --workspace --all-targets --locked

‎.gitignore‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,3 +403,6 @@ FodyWeavers.xsd
403403
/tests/MiniExcel.Tests/TemplateOptimization
404404
/tests/data/xlsx/Test_EnableWriteFilePath.xlsx
405405
samples/xlsx/Test_EnableWriteFilePath.xlsx
406+
407+
# Rust
408+
/rust/target/

‎README.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434

3535
MiniExcel is a simple and efficient Excel processing tool for .NET, specifically designed to minimize memory usage.
3636

37+
> **Experimental Rust XLSX MVP:** See the [Rust implementation and usage guide](rust/README.md).
38+
3739
At present, most popular frameworks need to load all the data from an Excel document into memory to facilitate operations, but this may cause memory consumption problems. MiniExcel's approach is different: the data is processed row by row in a streaming manner, reducing the original consumption from potentially hundreds of megabytes to just a few megabytes, effectively preventing out-of-memory(OOM) issues.
3840

3941
```mermaid

‎README.zh-CN.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@
4545

4646
MiniExcel简单、高效避免OOM的.NET处理Excel查、写、填充数据工具。
4747

48+
> **实验性 Rust XLSX MVP:** 请查看 [Rust 实现与使用说明](rust/README.zh-CN.md)。
49+
4850

4951
目前主流框架大多需要将数据全载入到内存方便操作,但这会导致内存消耗问题,MiniExcel 尝试以 Stream 角度写底层算法逻辑,能让原本1000多MB占用降低到几MB,避免内存不够情况。
5052

0 commit comments

Comments
 (0)