From b6b98bc0994aa88ee46d63f27445d2226ffa1a30 Mon Sep 17 00:00:00 2001 From: Jeremy Wall Date: Sun, 26 Jan 2025 19:14:30 -0500 Subject: [PATCH] wip: preserve the column width when setting style --- src/book/mod.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/book/mod.rs b/src/book/mod.rs index 36aaab6..e454cd4 100644 --- a/src/book/mod.rs +++ b/src/book/mod.rs @@ -323,9 +323,13 @@ impl Book { pub fn set_col_style(&mut self, style: &Style, sheet: u32, col: usize) -> Result<()> { let idx = self.create_or_get_style_idx(style); - self.model.workbook.worksheet_mut(sheet) - .map_err(|e| anyhow!("{}", e))? - .set_column_style(col as i32, idx) + let sheet = self.model.workbook.worksheet_mut(sheet) + .map_err(|e| anyhow!("{}", e))?; + let width = sheet.get_column_width(col as i32) + .map_err(|e| anyhow!("{}", e))?; + sheet.set_column_style(col as i32, idx) + .map_err(|e| anyhow!("{}", e))?; + sheet.set_column_width(col as i32, width) .map_err(|e| anyhow!("{}", e))?; Ok(()) }