Skip to content
This repository was archived by the owner on Aug 13, 2025. It is now read-only.
This repository was archived by the owner on Aug 13, 2025. It is now read-only.

help me: read hyperlink and rewrite make an error #842

@cossbow

Description

@cossbow

After commit #838 fix the bug, I can easily add links to the table.
But today I've had a new error, if I read an file which has any hyperlink, and then save file again, the saved file will have an error:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<recoveryLog xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><logFileName>error895600_18.xml</logFileName><summary>在文件“D:\test-2.xlsx”中检测到错误</summary><repairedParts><repairedPart>已修复的部件: 有 XML 错误的 /xl/worksheets/sheet1.xml。 灾难性故障 行 2,列 823。</repairedPart></repairedParts></recoveryLog>

I simplified the code:

func excelWrite() {
	wb := xlsx.NewFile()
	sh, er := wb.AddSheet("test")
	exitIfError(er)

	r := sh.AddRow()
	c := r.AddCell()
	c.SetHyperlink("http://www.google.com/index.html",
		"This is a hyperlink",
		"Click on the cell text to follow the hyperlink")

	er = wb.Save(`D:\test-1.xlsx`)
	exitIfError(er)
}

func excelRead() {
	wb, er := xlsx.OpenFile(`D:\test-1.xlsx`)
	exitIfError(er)

	sh, _ := wb.Sheet["test"]
	r, er := sh.Row(0)
	exitIfError(er)
	c := r.GetCell(0)
	fmt.Println(c.Hyperlink)

	er = wb.Save(`D:\test-2.xlsx`)
	exitIfError(er)
}

func main() {
	excelWrite()
	excelRead()
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions