tealeg / xlsx

Go library for reading and writing XLSX files.
Other
5.81k stars 810 forks source link

Error closing and returning file with email hyperlink #725

Closed thales-assis closed 1 year ago

thales-assis commented 2 years ago

Hi guys! How are you?

I've a question, when I try to return the file xlsx.File (converting to []bytes) and it contains the cell with a Hyperlink (email), the file breaks and it becomes impossible to open it.

Is it possible to clear all kind of formatting, hyperlink or something like that just so I can return the file successfully?

Image: Screen Shot 2021-07-26 at 18 58 21

thales-assis commented 2 years ago

Running some debuggers, I was able to identify that it is possible to set a field to "text" and put HyperLink as an empty structure (default). However, when I try to save the file it corrupts and gets broken. I'm not use sheet.Close() and the emails from the original file have the hyperlink.

buffer := bytes.NewBuffer(nil)
err := xlsxFile.Write(buffer)
if err != nil {
    return nil, err
}
return buffer.Bytes(), nil
thales-assis commented 2 years ago

Trying to overwrite the hyperlinked email field to an unlinked one:

cell.SetString(email)
cell.Hyperlink = xlsx.Hyperlink{}

It works, but when it comes to returning bytes and converting to file, it's broken/corrupted. I'm using the .xlsx extension.

github-actions[bot] commented 1 year ago

Stale issue message