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

ColIterator will cause some conditional format information lost. #13

Closed
erdian718 opened this issue Apr 29, 2019 · 14 comments
Closed

ColIterator will cause some conditional format information lost. #13

erdian718 opened this issue Apr 29, 2019 · 14 comments

Comments

@erdian718
Copy link

package main

import (
	"log"

	"github.com/plandem/xlsx"
)

func main() {
	xl, err := xlsx.Open("test.xlsx")
	if err != nil {
		log.Fatal(err)
	}
	defer xl.Close()

	// NOTE If uncomment the code, some conditional format information will lost.
	for cols := xl.Sheet(0).Cols(); cols.HasNext(); {
		cols.Next()
	}

	//	xl.Save() ERROR: Access is denied.
	xl.SaveAs("out.xlsx")
}

test.xlsx
out.xlsx

@plandem
Copy link
Owner

plandem commented Apr 29, 2019

hmmm....it was supposed that 'conditional' were fixed already in prev hotfix. Have you tried last fixes? Because I compared files that you attached and conditional as was in original

@erdian718
Copy link
Author

I've updated the code. I'm sure there's another BUG. My English is not very good. Please run my code, pay attention to the NOTE section. Comment or uncomment, there are differences.

@plandem
Copy link
Owner

plandem commented Apr 29, 2019

Hmm, I will check again, but I compared attached files and conditional formatting info is same in both files, need to find what is difference

@plandem
Copy link
Owner

plandem commented Apr 29, 2019

excel

Even excel show both files same

@erdian718
Copy link
Author

I used MS Office to open test.xlsx and out.xlsx, they are exactly the same. However, I used WPS to open the two files, they are differently, as shown in the screenshot. If column iterations are not performed, they will also be the same in WPS.
test
out

@plandem
Copy link
Owner

plandem commented May 1, 2019

I checked files again and can't see any difference :( All changes are valid, e.g. instead of "1" - "true" for boolean types. That the only differences :(

I can try to edit xlsx and replace manually "true" with "1" and check if styles will work in your program.

@plandem
Copy link
Owner

plandem commented May 1, 2019

https://www.w3.org/TR/xmlschema-2/#boolean

both should work. But as I said, its the only difference that I could find :(

@plandem
Copy link
Owner

plandem commented May 1, 2019

I checked in Open Office (https://www.openoffice.org/download/) and in Libre Office (https://www.libreoffice.org/), works fine :(

@erdian718
Copy link
Author

It looks like it's only has problems with WPS. I'll make a careful comparison after the festival. Please keep the issue open.

@plandem
Copy link
Owner

plandem commented May 3, 2019

I finished "hyperlinks" branch that turned into more than one feature and had deep changes eventually. now it's official release 1.0.0

@erdian718
Copy link
Author

I found the difference:

xl\styles.xml: <dxfs count="3">

test.xlsx has count attribute, but out.xlsx not. If add the count attribute in out.xlsx, it will work fine.

@plandem
Copy link
Owner

plandem commented May 5, 2019

really? It's weird, because it's optional attribute by standard. I afraid that WPS looks for same attribute at other collections too

Ok, I will add that attribute

@plandem
Copy link
Owner

plandem commented May 5, 2019

I added count attribute to all collections at style sheet to be sure. Changes at: https://github.com/plandem/xlsx/tree/feature/conditional

@erdian718
Copy link
Author

It works fine now. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants