Skip to main content

convert_workbook

Function convert_workbook 

Source
pub fn convert_workbook(
    from: Format,
    to: Format,
    input: &[u8],
) -> Result<Vec<OutputDoc>, Box<dyn Error>>
Expand description

Converts a byte buffer between formats, supporting multi-sheet workbooks.

Returns one entry per output document. For XLSX inputs with N sheets and CSV/TSV outputs, the result has N entries. For JSON/YAML/XML/TOML/XLSX outputs, the result has exactly one entry containing all sheets merged into a single document.

The returned string is the sheet name (from XLSX) or "Sheet1" for single-document inputs. Callers decide how to map these names to file paths.

§Errors

Returns an error if the input cannot be parsed or the output cannot be represented in the target format.

§Examples

use sheeter_engine::{convert_workbook, Format};

let out = convert_workbook(Format::Csv, Format::Json, b"a\n1\n").unwrap();
assert_eq!(out.len(), 1);
assert_eq!(out[0].0, "Sheet1");