Skip to content
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

Purpose of setting empty string to cell in "nil" case #756

Closed
ykartoev opened this issue Dec 30, 2020 · 4 comments
Closed

Purpose of setting empty string to cell in "nil" case #756

ykartoev opened this issue Dec 30, 2020 · 4 comments
Projects

Comments

@ykartoev
Copy link

Hi!

Explain please, what the purpose of setting the value "" to cell in SetCellValue method, when value argument is nil? I don't report is as a bug, because as I can see it's done deliberately, but I don't get a point of that.
Here is the line of code I'm talking about https://github.com/360EntSecGroup-Skylar/excelize/blob/master/cell.go#L96

The problem is that It fills the cell with some value, and excel doesn't take that kind cells as empty (you can check it by calling ISBLANK() excel function on them), so when you for example set row data by using SetSheetRow and want skip some cells in the row by passing a nil, it fills them with "", and so you not skipping them in fact, only setting to empty string.

So what the point of that line of code? Can you just skip the case of value == nil in SetCellValue?

@xuri
Copy link
Member

xuri commented Jan 7, 2021

Hi @yakartoev Thanks for your proposal, I agree with you and I'll fix it recently.

@xuri xuri added the in progress Working in progress label Jan 7, 2021
@xuri xuri closed this as completed in a266755 Jan 8, 2021
@xuri xuri removed the in progress Working in progress label Jan 8, 2021
@xuri xuri added this to Bugfix in v2.4.0 Feb 2, 2021
xuri added a commit that referenced this issue Feb 18, 2021
…mula fn: BITAND, BITLSHIFT, BITOR, BITRSHIFT, BITXOR
xuri added a commit that referenced this issue Feb 18, 2021
…mula fn: BITAND, BITLSHIFT, BITOR, BITRSHIFT, BITXOR
@barismar
Copy link
Contributor

barismar commented Feb 23, 2023

Hi @xuri, what about StreamWriter.SetRow? I still find "" (empty string) in the empty cell, when I set the cell value to nil like this excelize.Cell{Value: nil, StyleID: styleId} or not set the value of the cell excelize.Cell{StyleID: styleId} and both ways are detected as not blank when using ISBLANK() function in excel

I am using v2.7.0

@xuri
Copy link
Member

xuri commented Feb 23, 2023

Hi @barismar, thanks for your feedback. I think we need to change the setCellValFunc for the stream writer in the stream.go like this:

    case nil:
-       c.setCellValue("")
+       return err
    case []RichTextRun:

If you like to create a pull request for this. I'll certainly accept this patch, or I'll fix that tomorrow.

@barismar
Copy link
Contributor

Thanks for the response @xuri, here is the PR #1481, please kindly check it...

xuri pushed a commit to JDavidVR/excelize that referenced this issue Jul 11, 2023
jenbonzhang pushed a commit to jenbonzhang/excelize that referenced this issue Oct 22, 2023
jenbonzhang pushed a commit to jenbonzhang/excelize that referenced this issue Oct 22, 2023
, new formula fn: BITAND, BITLSHIFT, BITOR, BITRSHIFT, BITXOR
jenbonzhang pushed a commit to jenbonzhang/excelize that referenced this issue Oct 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
v2.4.0
Bugfix
Development

No branches or pull requests

3 participants