UPDATE: Select multiple columns/rows

Also fixed a bug where a second column would not pick up salyes correctly
This commit is contained in:
Nicolás Hatcher
2025-02-16 07:15:31 +01:00
committed by Nicolás Hatcher Andrés
parent 5aa7617e97
commit dd9ca4224d
4 changed files with 109 additions and 29 deletions

View File

@@ -455,3 +455,50 @@ fn column_style_then_width() {
DEFAULT_COLUMN_WIDTH * 2.0
);
}
#[test]
fn test_row_column_column() {
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
let column_c_range = Area {
sheet: 0,
row: 1,
column: 3,
width: 1,
height: LAST_ROW,
};
let column_e_range = Area {
sheet: 0,
row: 1,
column: 5,
width: 1,
height: LAST_ROW,
};
let row_5_range = Area {
sheet: 0,
row: 5,
column: 1,
width: LAST_COLUMN,
height: 1,
};
// update the row style
model
.update_range_style(&row_5_range, "fill.bg_color", "#333444")
.unwrap();
// update the column style
model
.update_range_style(&column_c_range, "fill.bg_color", "#555666")
.unwrap();
model
.update_range_style(&column_e_range, "fill.bg_color", "#CCC111")
.unwrap();
// test E5 has the column style
let style = model.get_cell_style(0, 5, 5).unwrap();
assert_eq!(style.fill.bg_color, Some("#CCC111".to_string()));
}

View File

@@ -1156,6 +1156,19 @@ impl UserModel {
new_value: Box::new(style),
});
// We need to update the styles in all cells that have a row style
for row_s in styled_rows.iter() {
let row = row_s.r;
self.update_single_cell_style(
sheet,
row,
column,
style_path,
value,
&mut diff_list,
)?;
}
// Update style in all cells that have different styles
// FIXME: We need a better way to transverse of cells in a column
for &row in &data_rows {
@@ -1175,22 +1188,6 @@ impl UserModel {
}
}
}
// We need to update the styles in all cells that have a row style
for row_s in styled_rows.iter() {
let row = row_s.r;
if data_rows.contains(&row) {
// Skip if the row has data
continue;
}
self.update_single_cell_style(
sheet,
row,
column,
style_path,
value,
&mut diff_list,
)?;
}
}
} else if range.column == 1 && range.width == LAST_COLUMN {
// Full rows