mirror of
https://github.com/storytold/gridcraft.git
synced 2026-11-07 02:51:33 +00:00
XLSX: control properties parts use the ctrlProp relationship type Excel uses
The sheet related each control properties part with http://schemas.microsoft.com/office/2006/relationships/ctrlProp. MS-XLSX defines the relationship in the officeDocument namespace, http://schemas.openxmlformats.org/officeDocument/2006/relationships/ctrlProp, which Excel writes and looks the part up by. GridCraft's own reader matched either (it goes by the last segment and the r:id), so its round trips passed; Excel would not have found the parts.
This commit is contained in:
1 parent
e1fbee8ebc
commit
85c22dd27b
2 files changed
+14
-1
No files matched your search
@@ -25,7 +25,8 @@ use crate::write::{Out, Rels};
|
||||
use crate::xml::{El, esc, esc_attr};
|
||||
|
||||
pub const CT_CTRL_PROP: &str = "application/vnd.ms-excel.controlproperties+xml";
|
||||
pub const REL_CTRL_PROP: &str = "http://schemas.microsoft.com/office/2006/relationships/ctrlProp";
|
||||
/// The worksheet relationship to a control properties part (MS-XLSX), as Excel writes it.
|
||||
pub const REL_CTRL_PROP: &str = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/ctrlProp";
|
||||
const NS_X14: &str = "http://schemas.microsoft.com/office/spreadsheetml/2009/9/main";
|
||||
const NS_MC: &str = "http://schemas.openxmlformats.org/markup-compatibility/2006";
|
||||
const NS_XDR: &str = "http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing";
|
||||
|
||||
@@ -303,3 +303,15 @@ fn many_listed_controls_read_in_linear_time() {
|
||||
// About 0.4 s here; scanning every shape for every control took over 8 s.
|
||||
assert!(took < std::time::Duration::from_secs(3), "{took:?}");
|
||||
}
|
||||
|
||||
/// The sheet relates each control properties part with the relationship type MS-XLSX defines and
|
||||
/// Excel writes (in the officeDocument namespace); Excel finds the part by that type.
|
||||
#[test]
|
||||
fn the_properties_parts_use_the_ctrl_prop_relationship_type() {
|
||||
let bytes = write_xlsx(&book()).unwrap();
|
||||
let mut pkg = Package::open(&bytes).unwrap();
|
||||
let rels = text(&mut pkg, "xl/worksheets/_rels/sheet1.xml.rels");
|
||||
let types: Vec<&str> = rels.split("Type=\"").skip(1).filter_map(|r| r.split('"').next()).filter(|t| t.ends_with("/ctrlProp")).collect();
|
||||
assert_eq!(types.len(), 4, "{rels}");
|
||||
assert!(types.iter().all(|t| *t == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/ctrlProp"), "{types:?}");
|
||||
}
|
||||
Reference in new issue
Block a user