-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
File shows corrupted after save file #1799
Comments
Thanks for your issue. Which version of Excelize are you using? I have fixed some style-related issues in v2.8.0, please try to upgrade the master branch code, and if it still doesn't work, please provide a reproducible attachment and code. |
Hello, I have the same error too: The server is Linux, Note: I use the function f.AddTable() (Maybe this is the cause) In my case, I can generate the file, and I can open it with WPS 2019, here the file is normal. However, when download the file from windows, show the next error in Excel (version Microsoft Office Profesional Plus 2019 - Windows 11 as reference): error148240_01.xml Note: the file open in excel, but after that show the error. |
@xuri, I am using github.com/xuri/excelize/v2 v2.8.0. The attachment is the sample, and I had tried that it would be also corrupted.
|
Hi @jason10880, thanks for your feedback. As my reply above, I have fixed some style-related issues in v2.8.0, please try to upgrade the master branch code by command |
Hi @jhonriv, thanks for your feedback. Please try to upgrade the master branch code by |
Hi @xuri, This is a wonderful library. I am currently experiencing corrupted export file on CentOS 8 Streaming like @jhonriv .
Note: I have already updated excelize to the v2@master It works fine on Windows 11. Here is a snippet of my code: f := excelize.NewFile()
f.SetDocProps(
&excelize.DocProperties{
Creator: "Test",
Created: time.Now().Format(time.RFC3339),
})
// Column Header Style
style, err := f.NewStyle(
&excelize.Style{
Font: &excelize.Font{
Bold: true,
},
})
if err != nil {
return err
}
for _, c := range cells {
if c.IsHeader {
f.SetCellStyle("Sheet1", c.Axis, c.Axis, style)
}
f.SetCellValue("Sheet1", c.Axis, c.Value)
}
// Save to file to count the contents
if err = f.SaveAs(tempfile); err != nil {
return err
}
b, err := os.ReadFile(tempfile)
if err != nil {
return err
}
w.Header().Set("Content-Length", strconv.Itoa(len(b)))
w.Header().Set("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
w.Header().Set("Content-Disposition", "attachment; filename="+filepath.Base(tempfile))
if _, err = w.Write(b); err != nil {
return err
} Thank you |
Thanks for your feedback @eaglebush, if it does not work with Go 1.21.0, please reference the issues #1465, #1595, #1603, #1608, #1614, #1619, #1620, #1621, #1623, #1633, #1637, #1641, #1642, #1648, #1651, #1652, #1656, #1657, #1660, #1663, #1670, #1686, #1734, #1752, #1764 and #1768. There are some incompatible changes in the Go 1.21.0 encoding/xml library. I have given feedback to the Go team and created a patch for it (golang/go#61881), and it has been fixed on Go 1.21.1. Please using the Go 1.20.12 and previous Go released version or upgrade to Go 1.21.1 and later. I have added notice on the README and documentation website for this. |
Hi @xuri , Thanks for the quick response. I think I will just update to 1.21.1+. |
@xuri It works for me after upgrade to the master branch v2.8.1. |
This issue has been closed. But there is still not enough info such as code and attachments to reproduce the comments by @jhonriv, so if you have any feedback, please let me know. |
Description
I tried to save cell value/picture to .xlsm file, but I found the file would show corrupted after saving file.
OS: Windows 10
Go Version: 1.18.10
Code:
The text was updated successfully, but these errors were encountered: