Preserve QExcell internal hyperlinks
This commit is contained in:
@@ -106,6 +106,29 @@ describe("excellOffice OOXML helpers", () => {
|
||||
expect(relationshipsXml).not.toContain("javascript:alert");
|
||||
});
|
||||
|
||||
it("сохраняет внутренние гиперссылки XLSX как location без external relationship", () => {
|
||||
const hyperlinks = {
|
||||
A1: "#Справочник!B2",
|
||||
B2: "https://example.com/report"
|
||||
};
|
||||
const xml = buildWorksheetXml({ A1: "Справочник", B2: "Отчет" }, [], hyperlinks);
|
||||
const relationshipsXml = buildWorksheetRelationshipsXml(hyperlinks);
|
||||
|
||||
expect(buildHyperlinksXml(hyperlinks)).toBe(
|
||||
'<hyperlinks><hyperlink ref="A1" location="Справочник!B2"/><hyperlink ref="B2" r:id="rId1"/></hyperlinks>'
|
||||
);
|
||||
expect(xml).toContain('<hyperlink ref="A1" location="Справочник!B2"/>');
|
||||
expect(relationshipsXml).toContain('Target="https://example.com/report"');
|
||||
expect(relationshipsXml).not.toContain("Справочник!B2");
|
||||
});
|
||||
|
||||
it("назначает drawing relationship после внешних ссылок, игнорируя внутренние ссылки XLSX", () => {
|
||||
const relationshipsXml = buildWorksheetRelationshipsXml({ A1: "#Справочник!B2" }, "../drawings/drawing1.xml");
|
||||
|
||||
expect(relationshipsXml).toContain('Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing"');
|
||||
expect(relationshipsXml).not.toContain('TargetMode="External"');
|
||||
});
|
||||
|
||||
it("сохраняет базовое форматирование ячеек XLSX в XML листа", () => {
|
||||
const cellFormats = {
|
||||
A1: { bold: true, fontSize: 14, fontFamily: "Arial", textColor: "0f5fae", fillColor: "fff2cc", horizontalAlign: "center" as const },
|
||||
@@ -393,6 +416,25 @@ describe("excellOffice OOXML helpers", () => {
|
||||
).toEqual({ A1: "https://example.com/report" });
|
||||
});
|
||||
|
||||
it("читает внутренние гиперссылки XLSX из location", () => {
|
||||
expect(
|
||||
worksheetXmlToHyperlinks(
|
||||
{
|
||||
worksheet: {
|
||||
hyperlinks: {
|
||||
hyperlink: [
|
||||
{ ref: "A1", location: "Справочник!B2" },
|
||||
{ ref: "B2", location: "" },
|
||||
{ ref: "bad", location: "Справочник!B2" }
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
undefined
|
||||
)
|
||||
).toEqual({ A1: "#Справочник!B2" });
|
||||
});
|
||||
|
||||
it("читает ссылки листов и relationships из workbook XML", () => {
|
||||
expect(
|
||||
workbookSheetRefs({
|
||||
|
||||
Reference in New Issue
Block a user