-
-
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
StreamWriter.SetRow should not insert a cell when value is nil #1299
Comments
It's worth discussing whether an empty |
thomascharbonnel
pushed a commit
to thomascharbonnel/excelize
that referenced
this issue
Aug 3, 2022
10 tasks
xuri
pushed a commit
to carbin-gun/excelize
that referenced
this issue
Oct 9, 2022
Co-authored-by: Thomas Charbonnel <[email protected]>
xuri
pushed a commit
to JDavidVR/excelize
that referenced
this issue
Jul 11, 2023
Co-authored-by: Thomas Charbonnel <[email protected]>
jenbonzhang
pushed a commit
to jenbonzhang/excelize
that referenced
this issue
Oct 22, 2023
Co-authored-by: Thomas Charbonnel <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
When using StreamWriter's
SetRow
, one has to pass a[]interface{}
of values. However, when a value given is nil (eg.values := []any{nil, nil, excelize.Cell{}}
, Excelize still creates an XMLc
cell. This creates problems when a row-level style has been set.Steps to reproduce the issue:
RowOpts
(this style should apply to all the cells in that row unless overwritten by a specific cellCell{}
preceded bynil
cells usingSetRow
. (eg. A1 and B1 are nil but C1 contains "My string")Describe the results you received:
If N
nil
cells are inserted before aCell{}
, Excel will show those cells using the default style (white background) rather than the row-level style.Ie. the XML worksheet will contain
<c t="str" r="A1"></c><c t="str" r="B1"></c><c t="str" r="C1">My string</c>
.Describe the results you expected:
Empty cells should not be written to the XML worksheet, so A1 and B1 should be empty cells using the row-level style.
XML should be
<c t="str" r="C1">My string</c>
.This is Excel's behavior
Output of
go version
:Excelize version or commit ID:
Environment details (OS, Microsoft Excel™ version, physical, etc.):
Running on Red Hat Linux.
Library code to change
https://github.com/qax-os/excelize/blob/master/stream.go#L329 This is the issue, the loop should test if
val == nil
and if yes it shouldcontinue
.The text was updated successfully, but these errors were encountered: