pub mod table_style;
#[cfg(feature = "serde")]
use serde::Serialize;
use crate::{common_types::Dimension, raw::spreadsheet::table::XlsxTable};
use table_style::TableStyle;
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(Serialize))]
pub struct Table {
pub display_name: String,
pub table_id: u64,
pub dimension: Dimension,
pub columns: Vec<String>,
pub header_row_count: u64,
pub totals_row_count: u64,
pub table_style: TableStyle,
}
impl Table {
pub(crate) fn from_raw(table: XlsxTable, default_table_style: Option<String>) -> Self {
let column_names: Vec<String> = table
.clone()
.table_columns
.unwrap_or(vec![])
.into_iter()
.map(|c| c.name.unwrap_or("".to_string()))
.collect();
return Self {
display_name: table.clone().display_name.unwrap_or("".to_string()),
table_id: table.clone().id.unwrap_or(1),
dimension: table.clone().r#ref.unwrap_or(Dimension::default()),
columns: column_names,
header_row_count: table.clone().header_row_count.unwrap_or(1),
totals_row_count: table.clone().totals_row_count.unwrap_or(1),
table_style: TableStyle::from_raw(table.clone().table_style_info, default_table_style),
};
}
}