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

Protected cell #191

Closed
nikencmoscow opened this issue Mar 6, 2018 · 4 comments
Closed

Protected cell #191

nikencmoscow opened this issue Mar 6, 2018 · 4 comments

Comments

@nikencmoscow
Copy link

Hi!

Why does the cell become protected when using SetCellStyle?

style, err := xlsx.NewStyle({"font":{"color":"#FF0000", "size":12}, "border":[{"type":"right","color":"#09600b","style":1}], "alignment":{"horizontal":"right"}})
if err != nil {
fmt.Println(err)
}
xlsx.SetCellStyle(sheetFull, cell, cell, style)

Advance thanks!

@xuri
Copy link
Member

xuri commented Mar 6, 2018

What's the "be protected" means? I have tested and it works well. Please provide the file attachment if you can.

@nikencmoscow
Copy link
Author

nikencmoscow commented Mar 7, 2018

Please, look file before and after.
Sheet 3, Cell F8.
func SetDate(xlsx *excelize.File, sheet int, cell string, data time.Time, isError *bool) {

sheetString := strconv.Itoa(sheet)
sheetFull := "sheet" + sheetString

defaultTime, _ := time.Parse("2006-01-02", "0001-01-01 05:48:48 +0548 LMT")
if data.Format("2006-01-02") == defaultTime.Format("2006-01-02") {
	xlsx.SetCellValue(sheetFull, cell, "ДД.ММ.ГГГГ")
	style, err := xlsx.NewStyle(`{"font":{"color":"#FF0000", "size":12}, "border":[{"type":"right","color":"#09600b","style":1}], "alignment":{"horizontal":"right"}}`)
	if err != nil {
		fmt.Println(err)
	}
	xlsx.SetCellStyle(sheetFull, cell, cell, style)
	*isError = true
} else {
	xlsx.SetCellValue(sheetFull, cell, data.Format("02.01.2006"))
}

}

before.xlsx
after.xlsx

xuri added a commit that referenced this issue Mar 7, 2018
@xuri
Copy link
Member

xuri commented Mar 7, 2018

I have added set protection properties support for the function NewStyle(). You can add "protection":{"locked":false} in the style format set param.

@nikencmoscow
Copy link
Author

Thank You!)

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

No branches or pull requests

2 participants