UPDATE: Adds 'user model' API (#27)
* bump version for documentation * Fixes wrong doc comment * renames old APIs to be consistent
This commit is contained in:
committed by
GitHub
parent
e9fc41541b
commit
d445553d85
@@ -1,5 +1,5 @@
|
||||
use ironcalc::{
|
||||
base::{expressions::utils::number_to_column, model::Model},
|
||||
base::{expressions::utils::number_to_column, Model},
|
||||
export::save_to_xlsx,
|
||||
};
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use ironcalc::{base::model::Model, export::save_to_xlsx};
|
||||
use ironcalc::{base::Model, export::save_to_xlsx};
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let mut model = Model::new_empty("hello_styles", "en", "UTC")?;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use ironcalc::{base::model::Model, export::save_to_xlsx};
|
||||
use ironcalc::{base::Model, export::save_to_xlsx};
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let mut model = Model::new_empty("widths-and-heights", "en", "UTC")?;
|
||||
@@ -6,7 +6,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let (sheet, row, column) = (0, 5, 3);
|
||||
// Make the first column 4 times as width
|
||||
let worksheet = model.workbook.worksheet_mut(sheet)?;
|
||||
let column_width = worksheet.column_width(column)? * 4.0;
|
||||
let column_width = worksheet.get_column_width(column)? * 4.0;
|
||||
worksheet.set_column_width(column, column_width)?;
|
||||
|
||||
// and the first row twice as high.
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
use std::fs;
|
||||
|
||||
use ironcalc_base::model::Model;
|
||||
use ironcalc_base::Model;
|
||||
|
||||
fn main() {
|
||||
let args: Vec<_> = std::env::args().collect();
|
||||
|
||||
@@ -2,7 +2,7 @@ use std::path::Path;
|
||||
|
||||
use ironcalc_base::cell::CellValue;
|
||||
use ironcalc_base::types::*;
|
||||
use ironcalc_base::{expressions::utils::number_to_column, model::Model};
|
||||
use ironcalc_base::{expressions::utils::number_to_column, Model};
|
||||
|
||||
use crate::export::save_to_xlsx;
|
||||
use crate::import::load_model_from_xlsx;
|
||||
@@ -208,7 +208,7 @@ pub fn test_load_and_saving(file_path: &str, temp_dir_name: &Path) -> Result<(),
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::compare::compare;
|
||||
use ironcalc_base::model::Model;
|
||||
use ironcalc_base::Model;
|
||||
|
||||
#[test]
|
||||
fn compare_different_sheets() {
|
||||
|
||||
@@ -15,8 +15,8 @@ use std::{
|
||||
};
|
||||
|
||||
use ironcalc_base::expressions::utils::number_to_column;
|
||||
use ironcalc_base::model::{get_milliseconds_since_epoch, Model};
|
||||
use ironcalc_base::types::Workbook;
|
||||
use ironcalc_base::{get_milliseconds_since_epoch, Model};
|
||||
|
||||
use self::xml_constants::XML_DECLARATION;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use std::fs;
|
||||
|
||||
use ironcalc_base::model::Model;
|
||||
use ironcalc_base::Model;
|
||||
|
||||
use crate::error::XlsxError;
|
||||
use crate::{export::save_to_xlsx, import::load_model_from_xlsx};
|
||||
@@ -31,13 +31,22 @@ fn test_values() {
|
||||
save_to_xlsx(&model, temp_file_name).unwrap();
|
||||
|
||||
let model = load_model_from_xlsx(temp_file_name, "en", "UTC").unwrap();
|
||||
assert_eq!(model.formatted_cell_value(0, 1, 1).unwrap(), "123.456");
|
||||
assert_eq!(model.formatted_cell_value(0, 2, 1).unwrap(), "Hello world!");
|
||||
assert_eq!(model.formatted_cell_value(0, 3, 1).unwrap(), "Hello world!");
|
||||
assert_eq!(model.formatted_cell_value(0, 4, 1).unwrap(), "你好世界!");
|
||||
assert_eq!(model.formatted_cell_value(0, 5, 1).unwrap(), "TRUE");
|
||||
assert_eq!(model.formatted_cell_value(0, 6, 1).unwrap(), "FALSE");
|
||||
assert_eq!(model.formatted_cell_value(0, 7, 1).unwrap(), "#VALUE!");
|
||||
assert_eq!(model.get_formatted_cell_value(0, 1, 1).unwrap(), "123.456");
|
||||
assert_eq!(
|
||||
model.get_formatted_cell_value(0, 2, 1).unwrap(),
|
||||
"Hello world!"
|
||||
);
|
||||
assert_eq!(
|
||||
model.get_formatted_cell_value(0, 3, 1).unwrap(),
|
||||
"Hello world!"
|
||||
);
|
||||
assert_eq!(
|
||||
model.get_formatted_cell_value(0, 4, 1).unwrap(),
|
||||
"你好世界!"
|
||||
);
|
||||
assert_eq!(model.get_formatted_cell_value(0, 5, 1).unwrap(), "TRUE");
|
||||
assert_eq!(model.get_formatted_cell_value(0, 6, 1).unwrap(), "FALSE");
|
||||
assert_eq!(model.get_formatted_cell_value(0, 7, 1).unwrap(), "#VALUE!");
|
||||
|
||||
fs::remove_file(temp_file_name).unwrap();
|
||||
}
|
||||
@@ -59,10 +68,10 @@ fn test_formulas() {
|
||||
save_to_xlsx(&model, temp_file_name).unwrap();
|
||||
|
||||
let model = load_model_from_xlsx(temp_file_name, "en", "UTC").unwrap();
|
||||
assert_eq!(model.formatted_cell_value(0, 1, 2).unwrap(), "11");
|
||||
assert_eq!(model.formatted_cell_value(0, 2, 2).unwrap(), "13");
|
||||
assert_eq!(model.formatted_cell_value(0, 3, 2).unwrap(), "15");
|
||||
assert_eq!(model.formatted_cell_value(0, 4, 2).unwrap(), "58.5");
|
||||
assert_eq!(model.get_formatted_cell_value(0, 1, 2).unwrap(), "11");
|
||||
assert_eq!(model.get_formatted_cell_value(0, 2, 2).unwrap(), "13");
|
||||
assert_eq!(model.get_formatted_cell_value(0, 3, 2).unwrap(), "15");
|
||||
assert_eq!(model.get_formatted_cell_value(0, 4, 2).unwrap(), "58.5");
|
||||
fs::remove_file(temp_file_name).unwrap();
|
||||
}
|
||||
|
||||
|
||||
@@ -16,8 +16,8 @@ use std::{
|
||||
use roxmltree::Node;
|
||||
|
||||
use ironcalc_base::{
|
||||
model::Model,
|
||||
types::{Metadata, Workbook, WorkbookSettings},
|
||||
Model,
|
||||
};
|
||||
|
||||
use crate::error::XlsxError;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//! # IronCalc - Core API documentation
|
||||
//!
|
||||
//! This technical API documentation is aimed at developers.
|
||||
//! It is used to build language bindings (like python, javascript or nodejs) or to build full fledged applications like ironCalc in the terminal or IronCalc, the Web application.
|
||||
//! It is used to build language bindings (like python, javascript or nodejs) or to build full fledged applications like TironCalc in the terminal or IronCalc, the Web application.
|
||||
//!
|
||||
//! ## Basic usage
|
||||
//!
|
||||
@@ -9,7 +9,7 @@
|
||||
//!
|
||||
//! ```toml
|
||||
//! [dependencies]
|
||||
//! ironcalc = { git = "https://github.com/ironcalc/IronCalc", version = "0.1"}
|
||||
//! ironcalc = { git = "https://github.com/ironcalc/IronCalc" }
|
||||
//! ```
|
||||
//!
|
||||
//! <small> until version 0.5.0 you should use the git dependencies as stated </small>
|
||||
|
||||
@@ -4,8 +4,8 @@ use uuid::Uuid;
|
||||
use ironcalc::compare::{test_file, test_load_and_saving};
|
||||
use ironcalc::export::save_to_xlsx;
|
||||
use ironcalc::import::{load_from_excel, load_model_from_xlsx};
|
||||
use ironcalc_base::model::Model;
|
||||
use ironcalc_base::types::{HorizontalAlignment, VerticalAlignment, Workbook};
|
||||
use ironcalc_base::Model;
|
||||
|
||||
// This is a functional test.
|
||||
// We check that the output of example.xlsx is what we expect.
|
||||
@@ -179,7 +179,7 @@ fn test_defined_names_casing() {
|
||||
model.set_user_input(0, row, column, formula.to_string());
|
||||
model.evaluate();
|
||||
assert_eq!(
|
||||
model.formatted_cell_value(0, row, column).unwrap(),
|
||||
model.get_formatted_cell_value(0, row, column).unwrap(),
|
||||
expected_value
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user