spreadsheet_addresses

Crates.iospreadsheet_addresses
lib.rsspreadsheet_addresses
version1.0.3
sourcesrc
created_at2024-04-22 20:58:23.403815
updated_at2024-04-22 21:34:13.98366
descriptionConvert spreadsheet addresses ("A4", "B$7" and so on) to a struct and vice versa!
homepage
repositoryhttps://github.com/MAA28/spreadsheet_addresses
max_upload_size
id1216770
size11,916
(MAA28)

documentation

README

Spreadsheet addresses

github crates.io docs.rs

Convert spreadsheet addresses to coordinates and vice versa in a fully tested and documented way!

Excel training image

Are you working on a spreadsheet application or something of the sort? What, you are not sure how to implement these address names? No worries - i have got you covered!

Examples

Convert from addresses to structs...

use spreadsheet_addresses::{Coordinate, AddressParsingError};

let coordinate1 = Coordinate::from_address("$CV23");
let coordinate2 = Coordinate::from_address("Hello World");

assert_eq!(
    coordinate1,
    Ok(Coordinate {
        row: 22,
        column: 99,
        relative_row: true,
        relative_column: false,
    })
);

assert_eq!(
    coordinate2,
    Err(AddressParsingError {
        input: "Hello World".to_string()
    })
);

...or the other way around!

use spreadsheet_addresses::Coordinate;

let coordinate = Coordinate::new(22, 99, true, false);

let address = coordinate.to_address();

assert_eq!(
    address,
    "$CV23".to_string()
);
Commit count: 7

cargo fmt