committed by
Nicolás Hatcher Andrés
parent
8ca73c6224
commit
1476e8f6da
@@ -60,6 +60,17 @@ impl PyUserModel {
|
||||
.map_err(|e| WorkbookError::new_err(e.to_string()))
|
||||
}
|
||||
|
||||
/// Gets the dimensions of a worksheet, returning the bounds of all non-empty cells.
|
||||
/// Returns a tuple of (min_row, max_row, min_column, max_column).
|
||||
/// For an empty sheet, returns (1, 1, 1, 1).
|
||||
pub fn get_sheet_dimensions(&self, sheet: u32) -> PyResult<(i32, i32, i32, i32)> {
|
||||
let model = self.model.get_model();
|
||||
let worksheet = model.workbook.worksheet(sheet)
|
||||
.map_err(|e| WorkbookError::new_err(e.to_string()))?;
|
||||
let dimension = worksheet.dimension();
|
||||
Ok((dimension.min_row, dimension.max_row, dimension.min_column, dimension.max_column))
|
||||
}
|
||||
|
||||
pub fn to_bytes(&self) -> PyResult<Vec<u8>> {
|
||||
let bytes = self.model.to_bytes();
|
||||
Ok(bytes)
|
||||
@@ -283,6 +294,16 @@ impl PyModel {
|
||||
.map_err(|e| WorkbookError::new_err(e.to_string()))
|
||||
}
|
||||
|
||||
/// Gets the dimensions of a worksheet, returning the bounds of all non-empty cells.
|
||||
/// Returns a tuple of (min_row, max_row, min_column, max_column).
|
||||
/// For an empty sheet, returns (1, 1, 1, 1).
|
||||
pub fn get_sheet_dimensions(&self, sheet: u32) -> PyResult<(i32, i32, i32, i32)> {
|
||||
let worksheet = self.model.workbook.worksheet(sheet)
|
||||
.map_err(|e| WorkbookError::new_err(e.to_string()))?;
|
||||
let dimension = worksheet.dimension();
|
||||
Ok((dimension.min_row, dimension.max_row, dimension.min_column, dimension.max_column))
|
||||
}
|
||||
|
||||
#[allow(clippy::panic)]
|
||||
pub fn test_panic(&self) -> PyResult<()> {
|
||||
panic!("This function panics for testing panic handling");
|
||||
|
||||
Reference in New Issue
Block a user