Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 3329115

Browse files
JSE [finish] xlsx/xl/_rels/workbook.xml.rels
1 parent 23b700b commit 3329115

File tree

1 file changed

+113
-0
lines changed

1 file changed

+113
-0
lines changed

‎src/xlsx/xl/_rels/DirectoryRels.ts‎

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
import {
2+
XMLNS_RELATIONSHIPS,
3+
EXTENSION_RELS,
4+
DEFAULT_XML_VERSION,
5+
ENCODING_UTF_8,
6+
DEFAULT_STAND_ALONE, FILE_RELS
7+
} from "../../../api/Internals";
8+
import {EXTENSION_XML, FILE_WORKBOOK} from "../../../api/Internals";
9+
import {JSESheet, JSExcel} from "../../../Types";
10+
import {
11+
___JSE_XLSX___Directory,
12+
___JSE_XLSX___File,
13+
___JSE_XLSX___FileContent,
14+
___JSE_XLSX___Node
15+
} from "../../../api/xlsx";
16+
17+
const fileProps: any = {
18+
name: `${FILE_WORKBOOK}${EXTENSION_XML}`,
19+
extension: EXTENSION_RELS,
20+
version: DEFAULT_XML_VERSION,
21+
encoding: ENCODING_UTF_8,
22+
standalone: DEFAULT_STAND_ALONE,
23+
nodes: {
24+
Relationships: "Relationships",
25+
Relationship: "Relationship"
26+
},
27+
keys: {
28+
xmlns: "xmlns",
29+
Id: "Id",
30+
Type: "Type",
31+
Target: "Target"
32+
}
33+
};
34+
35+
const directorProps: any = {
36+
name: FILE_RELS,
37+
files: {workBookXMLRels: {...fileProps}}
38+
};
39+
40+
export default (excel: JSExcel): ___JSE_XLSX___Directory => ({
41+
directoryName: directorProps.name,
42+
content: getRelDirectoryFiles(excel)
43+
});
44+
45+
function getRelDirectoryFiles(excel: JSExcel): ___JSE_XLSX___File {
46+
return {
47+
fileName: fileProps.name,
48+
fileExtension: fileProps.extension,
49+
fileContent: getRelsNodes(excel)
50+
};
51+
}
52+
53+
function getRelsNodes(excel: JSExcel): ___JSE_XLSX___FileContent {
54+
return {
55+
xml: {
56+
version: fileProps.version,
57+
encoding: fileProps.encoding,
58+
standalone: fileProps.standalone
59+
},
60+
content: {
61+
name: fileProps.nodes.Relationships,
62+
values: [{key: fileProps.keys.xmlns, value: XMLNS_RELATIONSHIPS}],
63+
content: [
64+
...excel.sheets.map((sheet: JSESheet, index: number): ___JSE_XLSX___Node => {
65+
return {
66+
name: fileProps.nodes.Relationship,
67+
values: [
68+
{key: fileProps.keys.Id, value: `rId${index + 1}`},
69+
{
70+
key: fileProps.keys.Type,
71+
value: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet"
72+
},
73+
{key: fileProps.keys.Target, value: `worksheets/sheet${index + 1}.xml`}
74+
]
75+
};
76+
}),
77+
{
78+
name: fileProps.nodes.Relationship,
79+
values: [
80+
{key: fileProps.keys.Id, value: `rId${excel.sheets.length + 1}`},
81+
{
82+
key: fileProps.keys.Type,
83+
value: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme"
84+
},
85+
{key: fileProps.keys.Target, value: "theme/theme1.xml"}
86+
]
87+
},
88+
{
89+
name: fileProps.nodes.Relationship,
90+
values: [
91+
{key: fileProps.keys.Id, value: `rId${excel.sheets.length + 2}`},
92+
{
93+
key: fileProps.keys.Type,
94+
value: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings"
95+
},
96+
{key: fileProps.keys.Target, value: "sharedStrings.xml"}
97+
]
98+
},
99+
{
100+
name: fileProps.nodes.Relationship,
101+
values: [
102+
{key: fileProps.keys.Id, value: `rId${excel.sheets.length + 3}`},
103+
{
104+
key: fileProps.keys.Type,
105+
value: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles"
106+
},
107+
{key: fileProps.keys.Target, value: "styles.xml"}
108+
]
109+
}
110+
]
111+
}
112+
};
113+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /