added missing api functions for get_cell*
This commit is contained in:
committed by
Nicolás Hatcher Andrés
parent
d9dbd3bf14
commit
1734fd5740
@@ -10,6 +10,8 @@ use xlsx::import;
|
||||
|
||||
mod types;
|
||||
|
||||
use crate::types::PyCellType;
|
||||
|
||||
create_exception!(_ironcalc, WorkbookError, PyException);
|
||||
|
||||
/// This is a model implementing the 'raw' API
|
||||
@@ -58,6 +60,21 @@ impl PyModel {
|
||||
|
||||
// Get values
|
||||
|
||||
/// Get raw value
|
||||
pub fn get_cell_content(&self, sheet: u32, row: i32, column: i32) -> PyResult<String> {
|
||||
self.model
|
||||
.get_cell_content(sheet, row, column)
|
||||
.map_err(|e| WorkbookError::new_err(e.to_string()))
|
||||
}
|
||||
|
||||
/// Get cell type
|
||||
pub fn get_cell_type(&self, sheet: u32, row: i32, column: i32) -> PyResult<PyCellType> {
|
||||
self.model
|
||||
.get_cell_type(sheet, row, column)
|
||||
.map(|cell_type| cell_type.into())
|
||||
.map_err(|e| WorkbookError::new_err(e.to_string()))
|
||||
}
|
||||
|
||||
/// Get formatted value
|
||||
pub fn get_formatted_cell_value(&self, sheet: u32, row: i32, column: i32) -> PyResult<String> {
|
||||
self.model
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use pyo3::prelude::*;
|
||||
use xlsx::base::types::{
|
||||
Alignment, Border, BorderItem, BorderStyle, Fill, Font, FontScheme, HorizontalAlignment, Style,
|
||||
Alignment, Border, BorderItem, BorderStyle, Fill, Font, FontScheme, HorizontalAlignment, Style, CellType,
|
||||
VerticalAlignment,
|
||||
};
|
||||
|
||||
@@ -161,6 +161,17 @@ pub struct PyFill {
|
||||
pub bg_color: Option<String>,
|
||||
}
|
||||
|
||||
#[pyclass(eq, eq_int)]
|
||||
#[derive(PartialEq, Clone)]
|
||||
pub enum PyCellType {
|
||||
Number = 1,
|
||||
Text = 2,
|
||||
LogicalValue = 4,
|
||||
ErrorValue = 16,
|
||||
Array = 64,
|
||||
CompoundData = 128,
|
||||
}
|
||||
|
||||
// Conversions from references to Py* types to non-Py types
|
||||
|
||||
// Enums
|
||||
@@ -426,3 +437,31 @@ impl From<Style> for PyStyle {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Conversion from PyCellType to CellType
|
||||
impl From<PyCellType> for CellType {
|
||||
fn from(py_cell_type: PyCellType) -> Self {
|
||||
match py_cell_type {
|
||||
PyCellType::Number => CellType::Number,
|
||||
PyCellType::Text => CellType::Text,
|
||||
PyCellType::LogicalValue => CellType::LogicalValue,
|
||||
PyCellType::ErrorValue => CellType::ErrorValue,
|
||||
PyCellType::Array => CellType::Array,
|
||||
PyCellType::CompoundData => CellType::CompoundData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Conversion from CellType to PyCellType
|
||||
impl From<CellType> for PyCellType {
|
||||
fn from(cell_type: CellType) -> Self {
|
||||
match cell_type {
|
||||
CellType::Number => PyCellType::Number,
|
||||
CellType::Text => PyCellType::Text,
|
||||
CellType::LogicalValue => PyCellType::LogicalValue,
|
||||
CellType::ErrorValue => PyCellType::ErrorValue,
|
||||
CellType::Array => PyCellType::Array,
|
||||
CellType::CompoundData => PyCellType::CompoundData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user