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

GetConditionalFormats do not return cell only Conditional Formating #1968

Closed
OlivierMary opened this issue Jul 26, 2024 · 3 comments
Closed
Labels
bug Something isn't working

Comments

@OlivierMary
Copy link

Description

GetConditionalFormats do not return cell only Conditional Formating

In this case only the first conditional Formating is return:
image

for _, cf := range ws.ConditionalFormatting {

image

Steps to reproduce the issue:

  1. Create a XLSX with a conditional formating on only a cell
  2. Try to get ConditionalFormating
  3. nothing returned

Describe the results you received:

no conditional format from GetConditionalFormats

Describe the results you expected:

all the conditional format

Output of go version:

go version go1.22.2 linux/amd64

Excelize version or commit ID:

	github.com/xuri/excelize/v2 v2.8.1

Environment details (OS, Microsoft Excel™ version, physical, etc.):
Linux,
LibreOffice

@xuri
Copy link
Member

xuri commented Jul 26, 2024

Thanks for your feedback. Could you show us a complete, standalone example program or reproducible demo? If you open an existing workbook, please provide the file attachment without confidential info.

@xuri xuri added the needs more info This issue can't reproduce, need more info label Jul 26, 2024
@OlivierMary
Copy link
Author

Hi there,

while producing example, that really happen if delete a line in the *excelize.File:

code:

package main

import "github.com/xuri/excelize/v2"

func main() {
	exampleFile, err:=excelize.OpenFile(".../example.excelize.conditional.xlsx")
	if err != nil {
		panic(err)
	}
	sheetName:=exampleFile.GetSheetName(0)



	println("before removing line")
	conditionalFromats, err := exampleFile.GetConditionalFormats(sheetName)
	if err != nil {
		panic(err)
	}

	for rangeKey, conditionalFormat := range conditionalFromats {
		println(rangeKey)
		println(len(conditionalFormat))
	}


	exampleFile.RemoveRow(sheetName, 1)
	println("after removing line")

	conditionalFromats, err = exampleFile.GetConditionalFormats(sheetName)
	if err != nil {
		panic(err)
	}

	for rangeKey, conditionalFormat := range conditionalFromats {
		println(rangeKey)
		println(len(conditionalFormat))
	}

}

example file:
example.excelize.conditional.xlsx

with this conditional:
image

I remove line 1 so not line in the conditional format,
I tested removing line 8 (after conditional in case of shifting line in cause) it's the same.

Regards,

@xuri xuri added bug Something isn't working and removed needs more info This issue can't reproduce, need more info labels Jul 29, 2024
@xuri xuri moved this to Bugfix in Excelize v2.9.0 Jul 29, 2024
@xuri xuri added the in progress Working in progress label Jul 29, 2024
@xuri xuri closed this as completed in d21b598 Jul 31, 2024
@xuri
Copy link
Member

xuri commented Jul 31, 2024

Thanks for your issue. This issue has been fixed, please upgrade to the master branch code by go get -u github.com/xuri/excelize/v2@master, and this patch will be released in the next version.

@xuri xuri removed the in progress Working in progress label Jul 31, 2024
zhangyimingdatiancai pushed a commit to zhangyimingdatiancai/excelize that referenced this issue Aug 6, 2024
- Fix missing conditional formatting after remove column
- Fix the SetSheetVisible function panic on none views sheet
- Updated unit tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
No open projects
Status: Bugfix
Development

No branches or pull requests

2 participants