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

When set cell font with SetCellStyle function, added forcibly bold and italic qualified. #425

Closed
GinSanaduki opened this issue Jun 11, 2019 · 2 comments
Labels
confirmed This issue can be reproduced

Comments

@GinSanaduki
Copy link

GinSanaduki commented Jun 11, 2019

Case 1:
You should only change the font to "Yu Gothic", but bold and italic are valid.
The same event occurs regardless of the font setting.

// Case01.go
package main

import (
	"fmt"
	"github.com/360EntSecGroup-Skylar/excelize"
)

func main() {
	f := excelize.NewFile();
	style, err := f.NewStyle(`{"font":{"family":"Yu Gothic"}}`);
	if err != nil {
		fmt.Println(err);
	}
	f.SetCellStyle("Sheet1", "A2", "A2", style);
	f.SetCellValue("Sheet1", "A2", "Hello world.");
	f.SaveAs("./Book_Case01.xlsx");
}

case01

Book_Case01.xlsx

・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・

Case 2:
You change the font to "Yu Gothic" and set the bool values of "bold" and "italic" to false, but bold and italic are valid.

// Case02.go
package main

import (
	"fmt"
	"github.com/360EntSecGroup-Skylar/excelize"
)

func main() {
	f := excelize.NewFile();
	style, err := f.NewStyle(`{"font":{"bold":false,"italic":false,"family":"Yu Gothic"}}`);
	if err != nil {
		fmt.Println(err);
	}
	f.SetCellStyle("Sheet1", "B3", "B3", style);
	f.SetCellValue("Sheet1", "B3", "Hello world.");
	f.SaveAs("./Book_Case02.xlsx");
}

case02

Book_Case02.xlsx

・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・

I checked the test code and found that the values set for bold and italic were tested with only "true", so I'm concerned that I can't confirm what happens in the case of "false".

Output of go version:
go version go1.12.1 windows/amd64

Excelize version or commit ID:
2.0.1

Environment details (OS, Microsoft Excel™ version, physical, etc.):
Windows 10, Excel 2016, Excel 2013.

@xuri xuri added confirmed This issue can be reproduced in progress Working in progress labels Jun 12, 2019
@xuri xuri closed this as completed in e124f60 Jun 13, 2019
@xuri xuri removed the in progress Working in progress label Jun 13, 2019
@xuri
Copy link
Member

xuri commented Jun 13, 2019

Hi @GinSanaduki, thanks for your issue. I have fixed it. Please try to upgrade the library with the master branch code.

@GinSanaduki
Copy link
Author

Hi @xuri, thanks for reply.
I'm done checking the fix. It's working properly.
case02
case01

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed This issue can be reproduced
Projects
None yet
Development

No branches or pull requests

2 participants