Crates.io | io-excel |
lib.rs | io-excel |
version | 0.1.4 |
source | src |
created_at | 2024-10-22 13:32:38.972346 |
updated_at | 2024-10-23 23:27:02.79086 |
description | This is a package that wraps around Calamine and rust_xlsxwriter, allowing for simple Excel read and write operations through procedural macros. |
homepage | |
repository | https://github.com/yipen9/io-excel |
max_upload_size | |
id | 1418664 |
size | 13,622 |
io-excel = "0.1.4"
serde = { version = "1.0", features = ["derive"] }
calamine = "0.26.1"
rust_xlsxwriter = "0.79.0"
Record::read_excel("中文名称.xlsx", "Sheet1"),分别为 file_path 和 sheet name
use io_excel::IOExcel;
#[derive(IOExcel, Debug)]
pub struct Record {
#[column(name = "省份")]
pub province: String,
#[column(name = "城市")]
pub city: String,
}
fn main() {
let record_list = Record::read_excel("中文名称.xlsx", "Sheet1").unwrap();
for record in &record_list {
eprintln!("{:#?}", record);
}
}
Record {
province: "湖北",
city: "武汉",
}
Record {
province: "湖北",
city: "孝感",
}
Record::write_excel("中文名称.xlsx", "Sheet1", record_list).unwrap();分别为 file_path 和 sheet name and record_list
use io_excel::IOExcel;
#[derive(IOExcel, Debug)]
pub struct Record {
#[column(name = "省份")]
pub province: String,
#[column(name = "城市")]
pub city: String,
}
fn main() {
let record_list = Record::read_excel("中文名称.xlsx", "Sheet1").unwrap();
Record::write_excel("中文名称2.xlsx", "第二个中文名称", &record_list).unwrap();
}
use io_excel::IOExcel;
#[derive(IOExcel, Debug)]
pub struct Record {
#[column(name = "省份")]
pub province: String,
#[column(name = "城市")]
pub city: Option<String>,
#[column(name = "版本号")]
pub name: u32,
}
fn main() {
let record_list = Record::read_excel("中文名称.xlsx", "Sheet1").unwrap();
for record in &record_list {
eprintln!("{:#?}", record);
}
Record::write_excel("中文名称2.xlsx", "第二个中文名称", &record_list).unwrap();
}