Skip to content
This repository has been archived by the owner on Dec 17, 2022. It is now read-only.

Latest commit

 

History

History
43 lines (39 loc) · 1.31 KB

README.md

File metadata and controls

43 lines (39 loc) · 1.31 KB

rust-xls

Read Excel files from Rust. Requires libxls.

Example program:

extern crate xls;

use std::env;

fn main() {
    let version = xls::reader::version();
    let arg_vec = env::args().collect::<Vec<String>>();
    if arg_vec.len() == 2 {
        println!("libxls version: {}", version);
        let maybe_handle = xls::reader::workbook::new(arg_vec[1].clone());
        match maybe_handle {
            Some(workbook) => {
                println!("Success!");
                for sheet in workbook.sheets() {
                    println!("+ Sheet");
                    for row in sheet.rows() {
                        println!("++ Row {}", row.index);
                        for cell in row.cells() {
                            match cell.value() {
                                Some(value) =>  {
                                    println!("+++ Cell {}: {}", cell.col_number,
                                             value);
                                },
                                None => { },
                            }
                        }
                    }
                }
            },
            None => println!("Failure!"),
        }
    } else {
        println!("Usage: {} <filename>", arg_vec[0]);
        std::process::exit(1);
    };
}