| Crates.io | excel_add_sheet |
| lib.rs | excel_add_sheet |
| version | 0.1.0 |
| created_at | 2025-07-14 12:47:47.806458+00 |
| updated_at | 2025-07-14 12:47:47.806458+00 |
| description | A library for adding worksheets to existing Excel (XLSX) files. |
| homepage | |
| repository | https://github.com/joeyclemens/excel_add_sheet |
| max_upload_size | |
| id | 1751644 |
| size | 120,167 |
A Rust library for adding worksheets to existing Excel (XLSX) files.
.xlsx fileszip, quick-xml, and tempfileAdd to your Cargo.toml:
[dependencies]
excel_add_sheet = "0.1.0"
use excel_add_sheet::ExcelDoc;
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Open the Excel file
let mut doc = ExcelDoc::open("minimal.xlsx")?;
// Add a new worksheet with some data
let data = vec![
vec!["Hello".to_string(), "World".to_string()],
vec!["123".to_string(), "456".to_string()],
];
doc.add_worksheet("NewSheet", Some(data))?;
// Save as a new file
doc.save("modified.xlsx")?;
println!("Added worksheet and saved as modified.xlsx!");
Ok(())
}
use excel_add_sheet::ExcelDoc;
fn main() -> Result<(), Box<dyn std::error::Error>> {
ExcelDoc::print_file_list("modified.xlsx")
}
use excel_add_sheet::ExcelDoc;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let path = "minimal.xlsx";
let mut doc = ExcelDoc::open(path)?;
let data = vec![
vec!["Scripted".to_string(), "Sheet".to_string()],
vec!["123".to_string(), "456".to_string()],
];
doc.add_worksheet("ScriptSheet", Some(data))?;
doc.save(path)?;
Ok(())
}
ExcelDocExcelDoc::open(path) -> Result<ExcelDoc, _>: Open an existing XLSX file for modification.add_worksheet(name, data): Add a worksheet with a given name and optional 2D string data.add_blank_worksheet(name): Add a blank worksheet.save(path): Save the modified document to a file.print_file_list(path): Print the list of files in the XLSX archive.ExcelWorkbook and WorksheetFor advanced manipulation, you can use the ExcelWorkbook and Worksheet structs to work with sheets and cells directly.
MIT License. See LICENSE for details.
Author: Joey Clemens (joeyclemens@tuta.io)