mod error;
mod options;
mod temporal;
pub mod workbook;
pub mod writer;
pub mod writer_handle;
#[cfg(feature = "arrow")]
pub mod arrow;
pub use error::Error;
pub use options::{OpenOptions, OpenOptionsRaw, WriteOptions};
pub use temporal::{Date, Time, Timestamp};
use std::os::raw::{c_int, c_void};
pub const XL_OK: i32 = 0;
pub const XL_EOF: i32 = -1;
pub const XL_BUFFER_TOO_SMALL: i32 = -2;
pub const XL_INVALID_HANDLE: i32 = -3;
pub const XL_INVALID_ARGUMENT: i32 = -4;
pub const XL_ERROR: i32 = -5;
pub const XL_STATUS_PASSWORD_REQUIRED: i32 = -6;
pub const XL_STATUS_PASSWORD_INCORRECT: i32 = -7;
pub const XL_ABI_VERSION: i32 = 4;
pub const XL_T_STRING: i32 = 0;
pub const XL_T_I64: i32 = 1;
pub const XL_T_F64: i32 = 2;
pub const XL_T_BOOL: i32 = 3;
pub const XL_T_DATE: i32 = 4;
pub const XL_T_TIME: i32 = 5;
pub const XL_T_TIMESTAMP: i32 = 6;
pub const XL_FORMAT_AUTO: i32 = 0;
pub const XL_FORMAT_XLS: i32 = 1;
pub const XL_FORMAT_XLSX: i32 = 2;
pub const XL_FORMAT_XLSB: i32 = 3;
pub const XL_FORMAT_CSV: i32 = 4;
pub const XL_OPT_DEFAULT: i32 = 0;
pub const XL_OPT_FALSE: i32 = 1;
pub const XL_OPT_TRUE: i32 = 2;
#[repr(C)]
pub struct XlWorkbook {
_private: [u8; 0],
}
#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct XlOpenOptions {
pub struct_size: i32,
pub csv_sniff_dialect: i32,
pub csv_delimiter: i32,
pub csv_quote: i32,
pub csv_detect_bom: i32,
pub csv_max_cell_bytes: i32,
pub csv_intern_strings: i32,
pub max_total_decompressed_bytes: i64,
pub max_cell_bytes: i32,
pub max_shared_string_bytes: i64,
pub max_zip_entries: i32,
pub prefetch_decompression: i32,
pub intern_strings: i32,
pub password: *const u8,
pub password_len: i32,
}
#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct XlWriteOptions {
pub struct_size: i32,
pub sheet_name_len: i32,
pub sheet_name: *const u8,
pub csv_delimiter: i32,
pub csv_quote: i32,
pub date1904: i32,
pub use_shared_strings: i32,
}
#[repr(C)]
pub struct XlColumnSpec {
pub names: *const *const u8,
pub name_lens: *const i32,
pub name_count: i32,
pub index: i32,
pub r#type: i32,
pub nullable: i32,
}
#[repr(C)]
pub struct XlColumn {
pub r#type: i32,
pub length: i64,
pub values: *const c_void,
pub validity: *const u8,
pub data: *const u8,
pub data_len: i64,
}
#[repr(C)]
pub struct XlTable {
pub column_count: i32,
pub row_count: i64,
pub columns: *mut XlColumn,
}
#[repr(C)]
pub struct XlInferredSchema {
pub columns: *mut XlColumnSpec,
pub column_count: i32,
}
#[repr(C)]
pub struct XlBuffer {
pub data: *mut u8,
pub len: i64,
}
#[repr(C)]
pub struct XlWriterHandle {
_private: [u8; 0],
}
extern "C" {
pub fn xl_abi_version() -> c_int;
pub fn xl_open_file_ex(
path: *const u8,
path_len: i32,
format: i32,
options: *const XlOpenOptions,
out_handle: *mut *mut XlWorkbook,
) -> c_int;
pub fn xl_open_memory_ex(
data: *const u8,
data_len: i32,
format: i32,
options: *const XlOpenOptions,
out_handle: *mut *mut XlWorkbook,
) -> c_int;
pub fn xl_close(handle: *mut XlWorkbook) -> c_int;
pub fn xl_sheet_count(handle: *mut XlWorkbook, out_count: *mut i32) -> c_int;
pub fn xl_sheet_name(
handle: *mut XlWorkbook,
buffer: *mut u8,
capacity: i32,
out_len: *mut i32,
) -> c_int;
pub fn xl_sheet_name_at(
handle: *mut XlWorkbook,
index: i32,
buffer: *mut u8,
capacity: i32,
out_len: *mut i32,
) -> c_int;
pub fn xl_move_to_sheet(handle: *mut XlWorkbook, index: i32) -> c_int;
pub fn xl_is_date1904(handle: *mut XlWorkbook, out_flag: *mut i32) -> c_int;
pub fn xl_parse_typed(
handle: *mut XlWorkbook,
specs: *const XlColumnSpec,
spec_count: i32,
header_row: i32,
out_table: *mut XlTable,
) -> c_int;
pub fn xl_parse_arrow(
handle: *mut XlWorkbook,
specs: *const XlColumnSpec,
spec_count: i32,
header_row: i32,
out_array: *mut c_void,
out_schema: *mut c_void,
) -> c_int;
pub fn xl_free_table(table: *mut XlTable);
pub fn xl_infer_schema(
handle: *mut XlWorkbook,
header_row: i32,
sample_size: i32,
out_schema: *mut XlInferredSchema,
) -> c_int;
pub fn xl_free_schema(schema: *mut XlInferredSchema);
pub fn xl_write_typed(
path: *const u8,
path_len: i32,
format: i32,
specs: *const XlColumnSpec,
table: *const XlTable,
options: *const XlWriteOptions,
) -> c_int;
pub fn xl_write_typed_to_memory(
format: i32,
specs: *const XlColumnSpec,
table: *const XlTable,
options: *const XlWriteOptions,
out_buffer: *mut XlBuffer,
) -> c_int;
pub fn xl_free_buffer(buffer: *mut XlBuffer);
pub fn xl_open_write_handle(
path: *const u8,
path_len: i32,
format: i32,
options: *const XlWriteOptions,
out_handle: *mut *mut XlWriterHandle,
) -> c_int;
pub fn xl_open_write_handle_to_memory(
format: i32,
options: *const XlWriteOptions,
out_handle: *mut *mut XlWriterHandle,
) -> c_int;
pub fn xl_start_sheet(handle: *mut XlWriterHandle, name: *const u8, name_len: i32) -> c_int;
pub fn xl_start_row(handle: *mut XlWriterHandle) -> c_int;
pub fn xl_write_string(handle: *mut XlWriterHandle, value: *const u8, value_len: i32) -> c_int;
pub fn xl_write_int64(handle: *mut XlWriterHandle, value: i64) -> c_int;
pub fn xl_write_float64(handle: *mut XlWriterHandle, value: f64) -> c_int;
pub fn xl_write_bool(handle: *mut XlWriterHandle, value: i32) -> c_int;
pub fn xl_write_date(handle: *mut XlWriterHandle, days_since_epoch: i32) -> c_int;
pub fn xl_write_time(handle: *mut XlWriterHandle, micros_since_midnight: i64) -> c_int;
pub fn xl_write_timestamp(handle: *mut XlWriterHandle, micros_since_epoch: i64) -> c_int;
pub fn xl_write_null(handle: *mut XlWriterHandle, r#type: i32) -> c_int;
pub fn xl_end_row(handle: *mut XlWriterHandle) -> c_int;
pub fn xl_end_sheet(handle: *mut XlWriterHandle) -> c_int;
pub fn xl_close_write_handle(handle: *mut XlWriterHandle) -> c_int;
pub fn xl_write_handle_bytes(handle: *mut XlWriterHandle, out_buffer: *mut XlBuffer) -> c_int;
pub fn xl_last_error_ptr(out_len: *mut i32) -> *const u8;
}