#report #power #parser #extract #file #page #settings

pbix

Parsing library for Power BI report files (.pbix)

1 unstable release

0.1.0 Apr 11, 2023

#50 in #power

MIT/Apache

11KB
184 lines

Power BI report file (.pbix) parser implemented in Rust. Extract report settings, page structure, and visuals.

pbix is a crate that lets you parse and extract metadata from Power BI report files (.pbix).

Parsing files

You can use pbix::parse_file(path: AsRef<Path>) to parse a Power BI report file for a given path:

match pbix::parse_file("Example.pbix") {
    Ok(report) => println!("Parsed {} pages from the report file!", report.pages.len()),
    Err(e) => eprintln!("Failed to parse report: {e}"),
};

from_bytes

Alternatively, you can use pbix::from_bytes(bytes: &[u8]) to parse a report file if you would like to work with bytes (instead of filenames).

let bytes = ...;

match pbix::from_bytes(&bytes) {
    Ok(report) => println!("Parsed {} pages from the report file!", report.pages.len()),
    Err(e) => eprintln!("Failed to parse report: {e}"),
};

Features

Below you can find documentation on the different feature flags that this crate exposes.

rayon

This feature uses the rayon crate to introduce parallelism in report data parsing and transforming.

You can enable this feature by including it in your Cargo.toml: no extra configuration or code is required!

[dependencies]
pbix = { version = ..., features = ["rayon"] }

Basic testing on a Power BI report sourced from Microsoft's examples indicated a ~15% improvement in parsing time when using this feature.

Dependencies

~1.2–2.3MB
~49K SLoC