Files
IronCalc/xlsx/src/export/workbook_xml_rels.rs
2023-11-20 10:46:19 +01:00

26 lines
1.1 KiB
Rust

use ironcalc_base::types::Workbook;
use super::xml_constants::{XML_DECLARATION, XML_WORKSHEET};
pub(crate) fn get_workbook_xml_rels(workbook: &Workbook) -> String {
let mut relationships_str: Vec<String> = vec![];
let worksheet_count = workbook.worksheets.len() + 1;
for id in 1..worksheet_count {
relationships_str.push(format!(
"<Relationship Id=\"rId{id}\" Type=\"{XML_WORKSHEET}\" Target=\"worksheets/sheet{id}.xml\"/>"
));
}
let mut id = worksheet_count;
relationships_str.push(
format!("<Relationship Id=\"rId{id}\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles\" Target=\"styles.xml\"/>")
);
id += 1;
relationships_str.push(
format!("<Relationship Id=\"rId{id}\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings\" Target=\"sharedStrings.xml\"/>")
);
format!(
"{XML_DECLARATION}\n<Relationships xmlns=\"http://schemas.openxmlformats.org/package/2006/relationships\">{}</Relationships>",
relationships_str.join("")
)
}