FIX: adds create user_model_from_bytes
This commit is contained in:
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -783,7 +783,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pyroncalc"
|
name = "pyroncalc"
|
||||||
version = "0.5.5"
|
version = "0.5.6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitcode",
|
"bitcode",
|
||||||
"ironcalc",
|
"ironcalc",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "pyroncalc"
|
name = "pyroncalc"
|
||||||
version = "0.5.5"
|
version = "0.5.6"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[project]
|
[project]
|
||||||
name = "ironcalc"
|
name = "ironcalc"
|
||||||
version = "0.5.5"
|
version = "0.5.6"
|
||||||
description = "Create, edit and evaluate Excel spreadsheets"
|
description = "Create, edit and evaluate Excel spreadsheets"
|
||||||
requires-python = ">=3.10"
|
requires-python = ">=3.10"
|
||||||
keywords = [
|
keywords = [
|
||||||
|
|||||||
@@ -353,6 +353,16 @@ pub fn create_user_model_from_icalc(file_name: &str) -> PyResult<PyUserModel> {
|
|||||||
Ok(PyUserModel { model })
|
Ok(PyUserModel { model })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[pyfunction]
|
||||||
|
pub fn create_user_model_from_bytes(bytes: &[u8]) -> PyResult<PyUserModel> {
|
||||||
|
let workbook: Workbook =
|
||||||
|
bitcode::decode(bytes).map_err(|e| WorkbookError::new_err(e.to_string()))?;
|
||||||
|
let model =
|
||||||
|
Model::from_workbook(workbook).map_err(|e| WorkbookError::new_err(e.to_string()))?;
|
||||||
|
let user_model = UserModel::from_model(model);
|
||||||
|
Ok(PyUserModel { model: user_model })
|
||||||
|
}
|
||||||
|
|
||||||
#[pyfunction]
|
#[pyfunction]
|
||||||
#[allow(clippy::panic)]
|
#[allow(clippy::panic)]
|
||||||
pub fn test_panic() {
|
pub fn test_panic() {
|
||||||
@@ -373,6 +383,7 @@ fn ironcalc(m: &Bound<'_, PyModule>) -> PyResult<()> {
|
|||||||
|
|
||||||
// User model functions
|
// User model functions
|
||||||
m.add_function(wrap_pyfunction!(create_user_model, m)?)?;
|
m.add_function(wrap_pyfunction!(create_user_model, m)?)?;
|
||||||
|
m.add_function(wrap_pyfunction!(create_user_model_from_bytes, m)?)?;
|
||||||
m.add_function(wrap_pyfunction!(create_user_model_from_xlsx, m)?)?;
|
m.add_function(wrap_pyfunction!(create_user_model_from_xlsx, m)?)?;
|
||||||
m.add_function(wrap_pyfunction!(create_user_model_from_icalc, m)?)?;
|
m.add_function(wrap_pyfunction!(create_user_model_from_icalc, m)?)?;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user