spreadsheet-column 0.1.0

Convert between spreadsheet column numbers and letters (1 <-> A, 27 <-> AA). A faithful port of the spreadsheet-column npm package. Zero deps, no_std.
Documentation
  • Coverage
  • 100%
    12 out of 12 items documented3 out of 9 items with examples
  • Size
  • Source code size: 26.74 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 277.47 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 3s Average build duration of successful builds.
  • all releases: 3s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • trananhtung/spreadsheet-column
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • trananhtung

spreadsheet-column

All Contributors

crates.io docs.rs CI license

Convert between spreadsheet column numbers and letters1A, 26Z, 27AA (the bijective base-26 used by Excel, Google Sheets, …).

A faithful Rust port of the spreadsheet-column npm package.

  • Zero dependencies, #![no_std]
  • One-based (default) or zero-based columns
  • Differential-tested against the reference spreadsheet-column implementation (60k cases)

Install

[dependencies]
spreadsheet-column = "0.1"

Usage

use spreadsheet_column::{from_int, from_str, SpreadsheetColumn};

assert_eq!(from_int(27).unwrap(), "AA");
assert_eq!(from_str("AA").unwrap(), 27);
assert_eq!(from_int(16384).unwrap(), "XFD"); // Excel's last column

// Zero-based columns:
let sc = SpreadsheetColumn::zero_based();
assert_eq!(sc.from_int(0).unwrap(), "A");
assert_eq!(sc.from_str("AA").unwrap(), 26);

In one-based mode, from_int(0) is an error (the smallest column is 1); negative numbers and non-letter strings are errors in both modes.

Contributors ✨

This project follows the all-contributors specification. Contributions of any kind are welcome — code, docs, bug reports, ideas, reviews! See the emoji key for how each contribution is recognized, and open a PR or issue to get involved.

Thanks goes to these wonderful people:

License

Licensed under either of MIT or Apache-2.0 at your option.