pub struct Excel { /* private fields */ }Implementations§
source§impl Excel
impl Excel
sourcepub fn new(filepath: &str) -> Self
pub fn new(filepath: &str) -> Self
Examples found in repository?
examples/write.rs (line 19)
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
fn main() {
if PathBuf::from(env!("CARGO_MANIFEST_DIR")) != env::current_dir().unwrap() {
let mut dir = env::current_exe().unwrap();
dir.pop();
env::set_current_dir(dir).unwrap();
}
let root_path = env::current_dir().unwrap();
let web_conf_path = root_path.join("file");
let web_conf_path = web_conf_path.join("name.xlsx");
let web_conf_path = web_conf_path.to_str().unwrap();
let mut excel = Excel::new("/Users/xiaduan/rust-helper/df-excel/examples/file/demossssttt.xlsx");
let heads = vec![
Head::new("order_no", "订单", "", 0),
Head::new("code", "编号", "", 0),
Head::new("name", "名称", "", 0),
];
let data = array![object! {"order_no":"123","code":"321","name":"订单123"},object! {"order_no":"123345","code":"321222","name":"订单123123123"}];
excel.set_page(0, "name", heads.clone(), data.clone());
excel.set_page(1, "name1", heads, data);
excel.save();
}sourcepub fn set_page(
&mut self,
page: usize,
nane: &str,
heads: Vec<Head>,
data: JsonValue
) -> &mut Self
pub fn set_page(
&mut self,
page: usize,
nane: &str,
heads: Vec<Head>,
data: JsonValue
) -> &mut Self
Examples found in repository?
examples/write.rs (line 30)
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
fn main() {
if PathBuf::from(env!("CARGO_MANIFEST_DIR")) != env::current_dir().unwrap() {
let mut dir = env::current_exe().unwrap();
dir.pop();
env::set_current_dir(dir).unwrap();
}
let root_path = env::current_dir().unwrap();
let web_conf_path = root_path.join("file");
let web_conf_path = web_conf_path.join("name.xlsx");
let web_conf_path = web_conf_path.to_str().unwrap();
let mut excel = Excel::new("/Users/xiaduan/rust-helper/df-excel/examples/file/demossssttt.xlsx");
let heads = vec![
Head::new("order_no", "订单", "", 0),
Head::new("code", "编号", "", 0),
Head::new("name", "名称", "", 0),
];
let data = array![object! {"order_no":"123","code":"321","name":"订单123"},object! {"order_no":"123345","code":"321222","name":"订单123123123"}];
excel.set_page(0, "name", heads.clone(), data.clone());
excel.set_page(1, "name1", heads, data);
excel.save();
}sourcepub fn save(&mut self)
pub fn save(&mut self)
Examples found in repository?
examples/write.rs (line 33)
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
fn main() {
if PathBuf::from(env!("CARGO_MANIFEST_DIR")) != env::current_dir().unwrap() {
let mut dir = env::current_exe().unwrap();
dir.pop();
env::set_current_dir(dir).unwrap();
}
let root_path = env::current_dir().unwrap();
let web_conf_path = root_path.join("file");
let web_conf_path = web_conf_path.join("name.xlsx");
let web_conf_path = web_conf_path.to_str().unwrap();
let mut excel = Excel::new("/Users/xiaduan/rust-helper/df-excel/examples/file/demossssttt.xlsx");
let heads = vec![
Head::new("order_no", "订单", "", 0),
Head::new("code", "编号", "", 0),
Head::new("name", "名称", "", 0),
];
let data = array![object! {"order_no":"123","code":"321","name":"订单123"},object! {"order_no":"123345","code":"321222","name":"订单123123123"}];
excel.set_page(0, "name", heads.clone(), data.clone());
excel.set_page(1, "name1", heads, data);
excel.save();
}