Skip to main content

sheetkit/
lib.rs

1//! SheetKit: High-level API for reading and writing Excel (.xlsx) files.
2//!
3//! # Quick Start
4//!
5//! ```no_run
6//! use sheetkit::Workbook;
7//!
8//! let wb = Workbook::new();
9//! wb.save("output.xlsx").unwrap();
10//! ```
11
12#[cfg(feature = "encryption")]
13pub use sheetkit_core::crypt::CryptLimits;
14pub use sheetkit_core::defined_names::{DefinedNameInfo, DefinedNameScope};
15pub use sheetkit_core::doc_props::{AppProperties, CustomPropertyValue, DocProperties};
16pub use sheetkit_core::error::{Error, Result};
17pub use sheetkit_core::formula::FormulaLimits;
18pub use sheetkit_core::protection::WorkbookProtectionConfig;
19pub use sheetkit_core::resource::{
20    ResourceCategory, ResourceDimension, ResourceLimitError, ResourceOperation, ResourceStage,
21};
22pub use sheetkit_core::save::{SaveLimits, SaveOptions, StreamLimits};
23pub use sheetkit_core::sheet::SheetProtectionConfig;
24pub use sheetkit_core::stream::StreamWriter;
25pub use sheetkit_core::workbook::{
26    AuxParts, DateInterpretation, OpenLimits, OpenOptions, ReadMode, Workbook, WorkbookFormat,
27};
28
29pub use sheetkit_core::cell::{
30    date_to_serial, datetime_to_serial, is_date_format_code, is_date_num_fmt, serial_to_date,
31    serial_to_datetime, CellValue,
32};
33pub use sheetkit_core::chart::{ChartConfig, ChartSeries, ChartType, View3DConfig};
34pub use sheetkit_core::comment::CommentConfig;
35pub use sheetkit_core::conditional::{
36    CfOperator, CfValueType, ConditionalFormatRule, ConditionalFormatType, ConditionalStyle,
37};
38pub use sheetkit_core::control::{FormControlConfig, FormControlInfo, FormControlType};
39pub use sheetkit_core::hyperlink::{HyperlinkInfo, HyperlinkType};
40pub use sheetkit_core::image::{ImageConfig, ImageFormat, PictureInfo};
41pub use sheetkit_core::numfmt::{builtin_format_code, format_number, format_with_builtin};
42pub use sheetkit_core::output::{
43    serialize_csv, serialize_csv_with_policy, CsvFormulaPolicy, MAX_CSV_OUTPUT_BYTES,
44};
45pub use sheetkit_core::page_layout::{Orientation, PageMarginsConfig, PaperSize};
46pub use sheetkit_core::pivot::{
47    AggregateFunction, PivotDataField, PivotField, PivotTableConfig, PivotTableInfo,
48};
49pub use sheetkit_core::render::RenderOptions;
50pub use sheetkit_core::rich_text::{rich_text_to_plain, RichTextRun};
51pub use sheetkit_core::shape::{ShapeConfig, ShapeType};
52pub use sheetkit_core::slicer::{SlicerConfig, SlicerInfo};
53pub use sheetkit_core::sparkline::{SparklineConfig, SparklineType};
54pub use sheetkit_core::style::{
55    AlignmentStyle, BorderLineStyle, BorderSideStyle, BorderStyle, FillStyle, FontStyle,
56    GradientFillStyle, GradientStop, GradientType, HorizontalAlign, NumFmtStyle, PatternType,
57    ProtectionStyle, Style, StyleColor, VerticalAlign,
58};
59pub use sheetkit_core::table::{TableColumn, TableConfig, TableInfo};
60pub use sheetkit_core::threaded_comment::{
61    PersonData, PersonInput, ThreadedCommentData, ThreadedCommentInput,
62};
63pub use sheetkit_core::traversal::{TraversalLimits, TraversalMode, TraversalOptions};
64pub use sheetkit_core::validation::{
65    DataValidationConfig, ErrorStyle, ValidationOperator, ValidationType,
66};
67pub use sheetkit_core::vba::{VbaLimits, VbaModule, VbaModuleType, VbaProject};
68
69/// Utility functions for cell reference conversion.
70pub mod utils {
71    pub use sheetkit_core::utils::cell_ref::{
72        cell_name_to_coordinates, column_name_to_number, column_number_to_name,
73        coordinates_to_cell_name,
74    };
75    pub use sheetkit_core::utils::constants;
76
77    /// Cell reference conversion functions, grouped by module.
78    pub mod cell_ref {
79        pub use sheetkit_core::utils::cell_ref::{
80            cell_name_to_coordinates, column_name_to_number, column_number_to_name,
81            coordinates_to_cell_name,
82        };
83    }
84}
85
86/// Table configuration types, also available at the crate root.
87pub mod table {
88    pub use sheetkit_core::table::{TableColumn, TableConfig, TableInfo};
89}
90
91/// Cell value types and date serial helpers, also available at the crate root.
92pub mod cell {
93    pub use sheetkit_core::cell::{
94        date_to_serial, datetime_to_serial, is_date_format_code, is_date_num_fmt, serial_to_date,
95        serial_to_datetime, CellValue,
96    };
97}
98
99/// Chart configuration types, also available at the crate root.
100pub mod chart {
101    pub use sheetkit_core::chart::{ChartConfig, ChartSeries, ChartType, View3DConfig};
102}
103
104/// Comment configuration types, also available at the crate root.
105pub mod comment {
106    pub use sheetkit_core::comment::CommentConfig;
107}
108
109/// Conditional formatting types, also available at the crate root.
110pub mod conditional {
111    pub use sheetkit_core::conditional::{
112        CfOperator, CfValueType, ConditionalFormatRule, ConditionalFormatType, ConditionalStyle,
113    };
114}
115
116/// Document property types, also available at the crate root.
117pub mod doc_props {
118    pub use sheetkit_core::doc_props::{AppProperties, CustomPropertyValue, DocProperties};
119}
120
121/// Hyperlink types, also available at the crate root.
122pub mod hyperlink {
123    pub use sheetkit_core::hyperlink::{HyperlinkInfo, HyperlinkType};
124}
125
126/// Image types, also available at the crate root.
127pub mod image {
128    pub use sheetkit_core::image::{ImageConfig, ImageFormat, PictureInfo};
129}
130
131/// Page layout types, also available at the crate root.
132pub mod page_layout {
133    pub use sheetkit_core::page_layout::{Orientation, PageMarginsConfig, PaperSize};
134}
135
136/// Pivot table types, also available at the crate root.
137pub mod pivot {
138    pub use sheetkit_core::pivot::{
139        AggregateFunction, PivotDataField, PivotField, PivotTableConfig, PivotTableInfo,
140    };
141}
142
143/// Workbook protection types, also available at the crate root.
144pub mod protection {
145    pub use sheetkit_core::protection::WorkbookProtectionConfig;
146}
147
148/// Sheet protection, view, and visibility types.
149pub mod sheet {
150    pub use sheetkit_core::sheet::{
151        SheetProtectionConfig, SheetViewOptions, SheetVisibility, ViewMode,
152    };
153}
154
155/// Streaming writer types.
156pub mod stream {
157    pub use sheetkit_core::stream::{StreamRowOptions, StreamWriter};
158}
159
160/// Style types, also available at the crate root.
161pub mod style {
162    pub use sheetkit_core::style::{
163        AlignmentStyle, BorderLineStyle, BorderSideStyle, BorderStyle, FillStyle, FontStyle,
164        GradientFillStyle, GradientStop, GradientType, HorizontalAlign, NumFmtStyle, PatternType,
165        ProtectionStyle, Style, StyleColor, VerticalAlign,
166    };
167}
168
169/// Data validation types, also available at the crate root.
170pub mod validation {
171    pub use sheetkit_core::validation::{
172        DataValidationConfig, ErrorStyle, ValidationOperator, ValidationType,
173    };
174}
175
176/// VBA project types, also available at the crate root.
177pub mod vba {
178    pub use sheetkit_core::vba::{VbaLimits, VbaModule, VbaModuleType, VbaProject};
179}
180
181#[cfg(test)]
182mod tests {
183    #[test]
184    fn table_types_are_reachable_through_the_facade() {
185        use crate::table::{TableColumn, TableConfig};
186
187        let mut wb = crate::Workbook::new();
188        let config = TableConfig {
189            name: "Sales".to_string(),
190            display_name: "Sales".to_string(),
191            range: "A1:A3".to_string(),
192            columns: vec![TableColumn {
193                name: "Qty".to_string(),
194                totals_row_function: None,
195                totals_row_label: None,
196            }],
197            ..TableConfig::default()
198        };
199        wb.add_table("Sheet1", &config).unwrap();
200        let tables: Vec<crate::TableInfo> = wb.get_tables("Sheet1").unwrap();
201        assert_eq!(tables[0].name, "Sales");
202        let _: crate::TableColumn = config.columns[0].clone();
203    }
204}