Struct df_excel::Head

source ·
pub struct Head {
    pub field: String,
    pub title: String,
    pub note: String,
    pub width: i32,
}

Fields§

§field: String§title: String§note: String§width: i32

Implementations§

source§

impl Head

source

pub fn new(field: &str, title: &str, note: &str, width: i32) -> Self

Examples found in repository?
examples/read.rs (line 16)
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
fn main() {


    // let path = format!("/Users/xiaduan/carrycoding/edi/edi-service/public/file/xlsx/a8df8a29b622d4017486f12df7586d3c6d662d80.xlsx");
    let path = format!("{}/examples/file/0450762145test.xlsx", env!("CARGO_MANIFEST_DIR"));
    // let path = format!("{}/examples/file/a8df8a29b622d4017486f12df7586d3c6d662d80.xlsx", env!("CARGO_MANIFEST_DIR"));
    // let heads = vec![
    //     Head::new("order_no", "订单", "", 0),
    //     Head::new("code", "编号", "", 0),
    //     Head::new("name", "名称", "", 0),
    // ];
    let heads = vec![
        Head::new("item", "项号", "", 0),
        Head::new("barcode", "条码", "", 0),
        Head::new("code", "货号", "", 0),
        Head::new("name", "描述", "", 0),
        Head::new("qty", "数量", "", 0),
        Head::new("price", "单价", "", 0),
        Head::new("subtotal", "合计", "", 0),
    ];
    let data = Read::export(path.as_str(), 2, heads);
    println!("{:#}", data);
}
More examples
Hide additional examples
examples/write.rs (line 23)
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
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/carry/carryxdcoding/helpers/df-excel/examples/file/demo.xlsx");


    let heads = vec![
        Head::new("order_no", "订单", "", 0),
        Head::new("code", "编号", "", 0),
        Head::new("name", "名称", "", 0),
        Head::new("item", "项号", "", 0),
        Head::new("barcode", "条码", "", 0),
        Head::new("code", "货号", "", 0),
        Head::new("name", "描述", "", 0),
        Head::new("qty", "数量", "", 0),
        Head::new("price", "单价", "", 0),
        Head::new("subtotal", "合计", "", 0),
    ];

    let data = array![object! {"order_no":"123","code":"321","name":"订单123"},object! {"order_no":"123345","code":"321222","name":"订单123123123"}];

    excel.set_page(0, "name0", heads.clone(), data.clone());
    excel.set_page(1, "name1", heads.clone(), data);

    excel.save();
}

Trait Implementations§

source§

impl Clone for Head

source§

fn clone(&self) -> Head

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl RefUnwindSafe for Head

§

impl Send for Head

§

impl Sync for Head

§

impl Unpin for Head

§

impl UnwindSafe for Head

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.