Closed ryanmcgrath closed 1 year ago
I do it for every sheet directly before saving the file and it works fine.
Pass the amount of rows and columns you want to lock!
So in your case (1,2)
sheet1.freeze_panes(1, 1);
sheet2.freeze_panes(1, 1);
sheet3.freeze_panes(1, 1);
if excel.close().is_ok() {...}
Hmmmm... well, I'm certainly open to being wrong. Suppose I'll tinker a bit more, there's probably something I've missed then. Thanks for the sanity check!
If you post some code that refuses to work I might be able to help out more.
It should work as expected. The only thing to look out for is to make sure that splitting cell is after the split, like in Excel.
I need to freeze the header (row 0) and the first two columns (columns 0 and 1).
In that case you would need to split at row = 1 and column = 2. This is still zero indexing but the split needs to be specified in the bottom right quadrant instead of the top left. Here is an example.
So Here is an example:
use xlsxwriter::Workbook;
fn main() -> Result<(), xlsxwriter::XlsxError> {
let workbook = Workbook::new("freeze.xlsx");
let mut worksheet = workbook.add_worksheet(None)?;
for row in 0_u32..10_u32 {
for col in 0_u16..8_u16 {
worksheet.write_string(row, col, "Text", None)?;
}
}
worksheet.freeze_panes(1, 2);
workbook.close()
}
Output:
I'd suggest closing this issue.
Thanks!
...or, if it does, I'm simply completely misunderstanding it.
I need to freeze the header (row
0
) and the first two columns (columns0
and1
). No matter where I place the call tofreeze_panes
, the rows/columns do not actually freeze.(Grepping around the internet for logic regarding the inner workings of Excel is 100% not my strength, so if I'm missing something please let me know)