excel-ooxml 1.0.0

Reading and writing of the SpreadsheetML format (.xlsx).
Documentation
//! Error type for `excel-ooxml`.

use thiserror::Error;

/// Errors that can occur while reading or writing a `.xlsx` workbook.
#[derive(Debug, Error)]
pub enum Error {
    /// An error occurred at the OPC package level (ZIP container, parts,
    /// relationships).
    #[error("OPC package error: {0}")]
    Opc(#[from] opc::Error),

    /// An error occurred while reading or writing XML.
    #[error("XML error: {0}")]
    Xml(#[from] xml_core::Error),

    /// An error occurred while reading or writing a shape's DrawingML
    /// content (fill/line/text/image reference) inside a sheet's drawing.
    #[error("drawing error: {0}")]
    Drawing(#[from] drawing::Error),

    /// An error occurred while reading or writing an embedded chart's
    /// content.
    #[error("chart error: {0}")]
    Chart(#[from] chart::Error),

    /// A sheet's drawing part (`xl/drawings/drawingN.xml`) is referenced by
    /// the worksheet but missing from the package.
    #[error("drawing part '{0}' is missing from the package")]
    MissingDrawingPart(String),

    /// A drawing anchor references an image or chart relationship id that
    /// has no matching entry in the drawing part's own `.rels`.
    #[error("drawing relationship '{0}' is not declared in the drawing part's .rels")]
    MissingDrawingRelationship(String),

    /// A drawing anchor's image/chart relationship resolved to a part name
    /// that isn't actually present in the package.
    #[error("part '{0}' referenced by a drawing is missing from the package")]
    MissingDrawingReferencedPart(String),

    /// The package has no relationship of type
    /// `.../relationships/officeDocument`, so `xl/workbook.xml` could not
    /// be located.
    #[error("the package has no main workbook part (missing officeDocument relationship)")]
    MissingWorkbook,

    /// A part's content is not valid UTF-8.
    #[error("'{0}' is not valid UTF-8: {1}")]
    InvalidUtf8(String, std::str::Utf8Error),

    /// `xl/workbook.xml` declares a `<sheet>` whose relationship id
    /// (`r:id`) has no matching entry in `xl/_rels/workbook.xml.rels`.
    #[error("sheet relationship '{0}' is not declared in xl/_rels/workbook.xml.rels")]
    MissingSheetRelationship(String),

    /// A sheet's relationship resolved to a part name that isn't actually
    /// present in the package.
    #[error("worksheet part '{0}' is missing from the package")]
    MissingWorksheetPart(String),
}

/// A [`Result`](std::result::Result) alias using [`Error`] as the error type.
pub type Result<T> = std::result::Result<T, Error>;