-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Complex border setting #37
Comments
@coolboy0002001 Thanks for your issue. Please reference the full API docs. package main
import (
"fmt"
"github.com/xuri/excelize/v2"
)
func main() {
styles := [][]interface{}{
{"C7", "F15", 7, 7, 7, 7},
{"B6", "B6", 2, 2, 7, 7},
{"C6", "F6", 7, 2, 7, 7},
{"G6", "G6", 7, 2, 7, 2},
{"B7", "B15", 2, 7, 7, 7},
{"G7", "G15", 7, 7, 7, 2},
{"B16", "B16", 2, 7, 2, 7},
{"C16", "F16", 7, 7, 2, 7},
{"G16", "G16", 7, 7, 2, 2},
}
f := excelize.NewFile()
for _, style := range styles {
s, err := f.NewStyle(&excelize.Style{
Border: []excelize.Border{
{
Type: "left",
Color: "#000000",
Style: style[2].(int),
}, {
Type: "top",
Color: "#000000",
Style: style[3].(int),
}, {
Type: "bottom",
Color: "#000000",
Style: style[4].(int),
}, {
Type: "right",
Color: "#000000",
Style: style[5].(int),
},
},
})
if err != nil {
fmt.Println(err)
}
f.SetCellStyle("Sheet1", style[0].(string), style[1].(string), s)
}
// Save spreadsheet file by the given path.
if err := f.SaveAs("Book1.xlsx"); err != nil {
fmt.Println(err)
}
} Please let me know if my answer is helpful to you. |
It works! Thanks a lot and I should make packaged function by my own requirement! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is there a simple way when setting complex border like this.
The text was updated successfully, but these errors were encountered: