mirror of
https://github.com/storytold/gridcraft.git
synced 2026-12-01 10:14:21 -06:00
Fix hidden Values row with page filters
This commit is contained in:
@@ -909,8 +909,9 @@ fn table_xml(pt: &PivotTable, idx: usize, cache_id: u32, c: &Cache, fmt_id: &dyn
|
||||
row_levels.max(1)
|
||||
};
|
||||
// Two or more value fields in Columns alone: Excel 365 adds a `Values` caption row
|
||||
// when field headers are shown. Page-filter layouts retain their classic header row.
|
||||
let hide_values_row = col_values.is_some() && col_idx.is_empty() && pages.is_empty() && pt.show_headers;
|
||||
// when field headers are shown. Page-filter layouts retain their classic header row
|
||||
// unless the table explicitly hides the Values row.
|
||||
let hide_values_row = col_values.is_some() && col_idx.is_empty() && (pages.is_empty() || !pt.show_values_row) && pt.show_headers;
|
||||
let first_header_row = usize::from(!hide_values_row);
|
||||
let _ = write!(
|
||||
s,
|
||||
|
||||
@@ -743,6 +743,15 @@ fn location_without_field_headers_has_no_values_row() {
|
||||
let parts = unzip(&write_xlsx(&wb).unwrap());
|
||||
let t3 = String::from_utf8(parts.get("xl/pivotTables/pivotTable3.xml").unwrap().clone()).unwrap();
|
||||
assert!(t3.contains("firstHeaderRow=\"1\" firstDataRow=\"2\""), "{t3}");
|
||||
{
|
||||
let p = &mut wb.sheet_mut(1).unwrap().pivots[2];
|
||||
p.values.push(PivotValue { source_col: "Sales".into(), name: "Sum of Sales".into(), ..PivotValue::default() });
|
||||
p.show_values_row = false;
|
||||
}
|
||||
let parts = unzip(&write_xlsx(&wb).unwrap());
|
||||
let t3 = String::from_utf8(parts.get("xl/pivotTables/pivotTable3.xml").unwrap().clone()).unwrap();
|
||||
assert!(t3.contains("firstHeaderRow=\"0\""), "{t3}");
|
||||
assert!(t3.contains("<x14:pivotTableDefinition hideValuesRow=\"1\"/>"), "{t3}");
|
||||
}
|
||||
|
||||
/// A one-sheet-of-data workbook with a pivot on "Report": `columns` are the source columns
|
||||
|
||||
Reference in New Issue
Block a user