Skip to content

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

@GinSanaduki

Description

@GinSanaduki

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.

Activity

xuri

xuri commented on Jun 13, 2019

@xuri
Member

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

GinSanaduki

GinSanaduki commented on Jun 13, 2019

@GinSanaduki
Author

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

added a commit that references this issue on Oct 23, 2020
e297581
added a commit that references this issue on Mar 14, 2024
e124f60
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmedThis issue can be reproduced

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @xuri@GinSanaduki

        Issue actions

          When set cell font with SetCellStyle function, added forcibly bold and italic qualified. · Issue #425 · qax-os/excelize