diff --git a/base/src/model.rs b/base/src/model.rs index 5f5c280..bfb8a38 100644 --- a/base/src/model.rs +++ b/base/src/model.rs @@ -2102,6 +2102,14 @@ impl Model { /// Returns a list of all cells pub fn get_all_cells(&self) -> Vec { let mut cells = Vec::new(); + for (sheet, row, column) in &self.workbook.calc_chain { + let cell = CellIndex { + row: *row, + column: *column, + index: *sheet, + }; + cells.push(cell); + } for (index, sheet) in self.workbook.worksheets.iter().enumerate() { let mut sorted_rows: Vec<_> = sheet.sheet_data.keys().collect(); sorted_rows.sort_unstable(); @@ -2128,6 +2136,8 @@ impl Model { let cells = self.get_all_cells(); + // First evaluate all dynamic arrays + for cell in cells { self.evaluate_cell(CellReferenceIndex { sheet: cell.index, diff --git a/base/src/test/user_model/test_dynamic_array.rs b/base/src/test/user_model/test_dynamic_array.rs index 351d177..1947d34 100644 --- a/base/src/test/user_model/test_dynamic_array.rs +++ b/base/src/test/user_model/test_dynamic_array.rs @@ -65,7 +65,7 @@ fn basic_undo_redo() { #[test] fn mixed_spills() { let mut model = UserModel::new_empty("model", "en", "UTC").unwrap(); - // D9 => ={1,2,3} + // D9 => ={34,35,3} model.set_user_input(0, 9, 4, "={34,35,3}").unwrap(); // F6 => ={1;2;3;4} model.set_user_input(0, 6, 6, "={1;2;3;4}").unwrap(); diff --git a/base/src/types.rs b/base/src/types.rs index abea099..4caae9a 100644 --- a/base/src/types.rs +++ b/base/src/types.rs @@ -51,6 +51,9 @@ pub struct Workbook { pub metadata: Metadata, pub tables: HashMap, pub views: HashMap, + /// Calculation chain of the dynamic arrays. + /// List of tuples (sheet_id, row, column) + pub calc_chain: Vec<(u32, i32, i32)>, } /// A defined name. The `sheet_id` is the sheet index in case the name is local diff --git a/webapp/IronCalc/src/components/Workbook/Workbook.tsx b/webapp/IronCalc/src/components/Workbook/Workbook.tsx index e1f93c0..796ec02 100644 --- a/webapp/IronCalc/src/components/Workbook/Workbook.tsx +++ b/webapp/IronCalc/src/components/Workbook/Workbook.tsx @@ -348,7 +348,15 @@ const Workbook = (props: { model: Model; workbookState: WorkbookState }) => { return workbookState.getEditingText(); } const { sheet, row, column } = model.getSelectedView(); - return model.getCellContent(sheet, row, column); + const r = model.getCellArrayStructure(sheet, row, column); + if (r === "SingleCell") { + return model.getCellContent(sheet, row, column); + } + if ("DynamicMother" in r) { + return model.getCellContent(sheet, row, column); + } + const [mother_row, mother_column, _] = r.DynamicChild; + return model.getCellContent(sheet, mother_row, mother_column); }; // returns true if it is either single cell or the root cell of an array diff --git a/xlsx/tests/example.ic b/xlsx/tests/example.ic index 740cd6b..4007d3a 100644 Binary files a/xlsx/tests/example.ic and b/xlsx/tests/example.ic differ