excelstream 0.15.0

High-performance streaming Excel & CSV library with S3/GCS cloud support and Parquet conversion - Ultra-low memory usage
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
# excelstream

🦀 **High-performance streaming Excel, CSV & Parquet library for Rust with constant memory usage**

[![Rust](https://img.shields.io/badge/rust-1.70%2B-orange.svg)](https://www.rust-lang.org/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![CI](https://github.com/KSD-CO/excelstream/workflows/Rust/badge.svg)](https://github.com/KSD-CO/excelstream/actions)

## ✨ Highlights

- 📊 **XLSX, CSV & Parquet Support** - Read/write Excel, CSV, and Parquet files
- 📉 **Constant Memory** - ~3-35 MB regardless of file size
- ☁️ **Cloud Streaming** - Direct S3/GCS uploads with ZERO temp files
-**High Performance** - 94K rows/sec (S3), 1.2M rows/sec (CSV)
- 🔄 **True Streaming** - Process files row-by-row, no buffering
- 🗜️ **Parquet Conversion** - Stream Excel ↔ Parquet with constant memory
- 🐳 **Production Ready** - Works in 256 MB containers

## 🔥 What's New in v0.15.0

**Parquet Support** - Stream Excel ↔ Parquet with constant memory!

```rust
use excelstream::parquet::{ExcelToParquetConverter, ParquetToExcelConverter};

// Excel → Parquet (10K rows at a time, constant memory)
let converter = ExcelToParquetConverter::new("data.xlsx")?;
converter.convert_to_parquet("output.parquet")?;

// Parquet → Excel (streaming)
let converter = ParquetToExcelConverter::new("data.parquet")?;
converter.convert_to_excel("output.xlsx")?;
```

**Features:**
- **Streaming conversion** - Constant memory (10K row batches)
-**All data types** - Strings, numbers, booleans, dates
-**High performance** - Process millions of rows efficiently
-**Progress callbacks** - Track conversion progress

[See full changelog]CHANGELOG.md | [Parquet examples →]examples/

---

## 📦 Quick Start

### Installation

```toml
[dependencies]
excelstream = "0.15"

# Optional features
excelstream = { version = "0.15", features = ["cloud-s3"] }        # S3 support
excelstream = { version = "0.15", features = ["cloud-gcs"] }       # GCS support
excelstream = { version = "0.15", features = ["parquet-support"] } # Parquet conversion
```

### Write Excel (Local)

```rust
use excelstream::ExcelWriter;

let mut writer = ExcelWriter::new("output.xlsx")?;

// Write 1M rows with only 3 MB memory!
writer.write_header_bold(&["ID", "Name", "Amount"])?;
for i in 1..=1_000_000 {
    writer.write_row(&[&i.to_string(), "Item", "1000"])?;
}
writer.save()?;
```

### Read Excel (Streaming)

```rust
use excelstream::ExcelReader;

let mut reader = ExcelReader::open("large.xlsx")?;

// Process 1 GB file with only 12 MB memory!
for row in reader.rows("Sheet1")? {
    let row = row?;
    println!("{:?}", row.to_strings());
}
```

### S3 Streaming (v0.14+)

```rust
use excelstream::cloud::S3ExcelWriter;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let mut writer = S3ExcelWriter::builder()
        .bucket("reports")
        .key("sales.xlsx")
        .build()
        .await?;

    writer.write_header_bold(["Date", "Revenue"]).await?;
    writer.write_row(["2024-01-01", "125000"]).await?;
    writer.save().await?;  // Streams to S3, no disk!
    Ok(())
}
```

[More examples →](examples/)

---

## 🎯 Why ExcelStream?

**The Problem:** Traditional libraries load entire files into memory

```rust
// ❌ Traditional: 1 GB file = 1+ GB RAM (OOM in containers!)
let workbook = Workbook::new("huge.xlsx")?;
```

**The Solution:** True streaming with constant memory

```rust
// ✅ ExcelStream: 1 GB file = 12 MB RAM
let mut reader = ExcelReader::open("huge.xlsx")?;
for row in reader.rows("Sheet1")? { /* streaming! */ }
```

### Performance Comparison

| Operation | Traditional | ExcelStream | Improvement |
|-----------|-------------|-------------|-------------|
| Write 1M rows | 100+ MB | **2.7 MB** | **97% less memory** |
| Read 1GB file | ❌ Crash | **12 MB** | Works! |
| S3 upload 500K rows | Temp file | **34 MB** | **Zero disk** |
| K8s pod (256MB) | ❌ OOMKilled | ✅ Works | Production ready |

---

## ☁️ Cloud Features

### S3 Direct Streaming (v0.14)

Upload Excel files directly to S3 with **ZERO temp files**:

```bash
cargo add excelstream --features cloud-s3
```

**Performance (Real AWS S3):**

| Dataset | Memory | Throughput | Temp Files |
|---------|--------|------------|------------|
| 10K rows | 15 MB | 11K rows/s | **ZERO**|
| 100K rows | 23 MB | 45K rows/s | **ZERO**|
| 500K rows | 34 MB | 94K rows/s | **ZERO**|

Perfect for:
- ✅ AWS Lambda (read-only filesystem)
- ✅ Docker containers (no disk space)
- ✅ Kubernetes CronJobs (limited memory)

[See S3 performance details →](PERFORMANCE_S3.md)

### GCS Direct Streaming (v0.14)

Upload Excel files directly to Google Cloud Storage with **ZERO temp files**:

```bash
cargo add excelstream --features cloud-gcs
```

```rust
use excelstream::cloud::GCSExcelWriter;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let mut writer = GCSExcelWriter::builder()
        .bucket("my-bucket")
        .object("report.xlsx")
        .build()
        .await?;

    writer.write_header_bold(["Month", "Sales"]).await?;
    writer.write_row(["January", "50000"]).await?;
    writer.save().await?; // ✅ Streams directly to GCS!
    Ok(())
}
```

Perfect for:
- ✅ Cloud Run (read-only filesystem)
- ✅ Cloud Functions (no disk space)
- ✅ GKE workloads (limited memory)

[See GCS example →](examples/gcs_streaming.rs)

### HTTP Streaming

Stream Excel files directly to web responses:

```rust
use excelstream::cloud::HttpExcelWriter;

async fn download() -> impl IntoResponse {
    let mut writer = HttpExcelWriter::new();
    writer.write_row(&["Data"])?;
    ([(header::CONTENT_TYPE, "application/vnd....")], writer.finish()?)
}
```

[HTTP streaming guide →](examples/http_streaming.rs)

---

## 📊 CSV Support

**13.5x faster** than Excel for CSV workloads:

```rust
use excelstream::csv::CsvWriter;

let mut writer = CsvWriter::new("data.csv")?;
writer.write_row(&["A", "B", "C"])?;  // 1.2M rows/sec!
writer.save()?;
```

**Features:**
- ✅ Zstd compression (`.csv.zst` - 2.9x smaller)
- ✅ Auto-detection (`.csv`, `.csv.gz`, `.csv.zst`)
- ✅ Streaming (< 5 MB memory)

[CSV examples →](examples/csv_write.rs)

---

## 🗜️ Parquet Support (v0.15+)

Convert between Excel and Parquet with **constant memory** streaming:

```bash
cargo add excelstream --features parquet-support
```

### Excel → Parquet

```rust
use excelstream::parquet::ExcelToParquetConverter;

let converter = ExcelToParquetConverter::new("data.xlsx")?;
let rows = converter.convert_to_parquet("output.parquet")?;
println!("Converted {} rows", rows);
```

### Parquet → Excel

```rust
use excelstream::parquet::ParquetToExcelConverter;

let converter = ParquetToExcelConverter::new("data.parquet")?;
let rows = converter.convert_to_excel("output.xlsx")?;
println!("Converted {} rows", rows);
```

### Streaming with Progress

```rust
let converter = ParquetToExcelConverter::new("large.parquet")?;
converter.convert_with_progress("output.xlsx", |current, total| {
    println!("Progress: {}/{} rows", current, total);
})?;
```

**Features:**
- **Constant memory** - Processes in 10K row batches
-**All data types** - Strings, numbers, booleans, dates, timestamps
-**Progress tracking** - Monitor large conversions
-**High performance** - Efficient columnar format handling

**Use Cases:**
- Convert Excel reports to Parquet for data lakes
- Export Parquet data to Excel for analysis
- Integrate with Apache Arrow/Spark workflows

[Parquet examples →](examples/parquet_to_excel.rs)

---

## 🚀 Use Cases

### 1. Large File Processing

```rust
// Process 500 MB Excel with only 25 MB RAM
let mut reader = ExcelReader::open("customers.xlsx")?;
for row in reader.rows("Sales")? {
    // Process row-by-row, constant memory!
}
```

### 2. Database Exports

```rust
// Export 1M database rows to Excel
let mut writer = ExcelWriter::new("export.xlsx")?;
let rows = db.query("SELECT * FROM large_table")?;
for row in rows {
    writer.write_row(&[row.get(0), row.get(1)])?;
}
writer.save()?;  // Only 3 MB memory used!
```

### 3. Cloud Pipelines

```rust
// Lambda function: DB → Excel → S3
let mut writer = S3ExcelWriter::builder()
    .bucket("data-lake").key("export.xlsx").build().await?;

let rows = db.query_stream("SELECT * FROM events").await?;
while let Some(row) = rows.next().await {
    writer.write_row(row).await?;
}
writer.save().await?;  // No temp files, no disk!
```

---

## 📚 Documentation

- [API Docs]https://docs.rs/excelstream - Full API reference
- [Examples]examples/ - Code examples for all features
- [CHANGELOG]CHANGELOG.md - Version history
- [Performance]PERFORMANCE_S3.md - Detailed benchmarks

### Key Topics

- [Excel Writing]examples/basic_write.rs - Basic & advanced writing
- [Excel Reading]examples/basic_read.rs - Streaming read
- [S3 Streaming]examples/s3_streaming.rs - AWS S3 uploads
- [GCS Streaming]examples/gcs_streaming.rs - Google Cloud Storage uploads
- [CSV Support]examples/csv_write.rs - CSV operations
- [Parquet Conversion]examples/parquet_to_excel.rs - Excel ↔ Parquet
- [Styling]examples/cell_formatting.rs - Cell formatting & colors

---

## 🔧 Features

| Feature | Description |
|---------|-------------|
| `default` | Core Excel/CSV with Zstd compression |
| `cloud-s3` | S3 direct streaming (async) |
| `cloud-gcs` | GCS direct streaming (async) |
| `cloud-http` | HTTP response streaming |
| `parquet-support` | Parquet ↔ Excel conversion |
| `serde` | Serde serialization support |
| `parallel` | Parallel processing with Rayon |

---

## ⚡ Performance

**Memory Usage (Constant):**
- Excel write: **2.7 MB** (any size)
- Excel read: **10-12 MB** (any size)
- S3 streaming: **30-35 MB** (any size)
- CSV write: **< 5 MB** (any size)

**Throughput:**
- Excel write: 42K rows/sec
- Excel read: 50K rows/sec
- S3 streaming: 94K rows/sec
- CSV write: 1.2M rows/sec

---

## 🛠️ Migration from v0.13

**S3ExcelWriter** is now async:

```rust
// OLD (v0.13 - sync)
writer.write_row(&["a", "b"])?;

// NEW (v0.14 - async)
writer.write_row(["a", "b"]).await?;
```

All other APIs unchanged!

---

## 📋 Requirements

- Rust 1.70+
- Optional: AWS credentials for S3 features

---

## 🤝 Contributing

Contributions welcome! Please read [CONTRIBUTING.md](CONTRIBUTING.md).

---

## 📄 License

MIT License - See [LICENSE](LICENSE) for details

---

## 🙏 Credits

- Built with [s-zip]https://crates.io/crates/s-zip for streaming ZIP
- AWS SDK for Rust
- All contributors and users!

---

**Need help?** [Open an issue]https://github.com/KSD-CO/excelstream/issues | **Questions?** [Discussions]https://github.com/KSD-CO/excelstream/discussions