excelize icon indicating copy to clipboard operation
excelize copied to clipboard

Excelize should have GetColStyle and GetRowStyle

Open thomascharbonnel opened this issue 2 years ago • 0 comments

Description

SetColStyle and SetRowStyle exist but there is no equivalent read method to read a column/row's style. Ideally this would return col/row styles without parsing the entire worksheet's XML (if that's possible?).

thomascharbonnel avatar Aug 01 '22 03:08 thomascharbonnel

yes, that would allow to copy style from existing File and have a better designed output

lanfeust21 avatar Sep 05 '22 12:09 lanfeust21

This library supported getting row style ID by the GetRowOpts function since version 2.6.1. For example, get the style ID of each row on Sheet1:

rows, err := f.Rows("Sheet1")
if err != nil {
	fmt.Println(err)
	return
}
var rowNum int
for rows.Next() {
	rowNum++
	rowOpts := rows.GetRowOpts()
	fmt.Printf("the style ID of row %d is %d\n", rowNum, rowOpts.StyleID)
}
if err = rows.Close(); err != nil {
	fmt.Println(err)
}

I have added new a function GetColStyle, now you can get the column style ID by it like this:

styleID, err := f.GetColStyle("Sheet1", "C")

xuri avatar Sep 06 '22 16:09 xuri