设置名称
func (f *File) SetDefinedName(definedName *DefinedName) error
根据给定的名称和引用区域设置名称,默认范围是工作簿。例如:
err := f.SetDefinedName(&excelize.DefinedName{
Name: "Amount",
RefersTo: "Sheet1!$A$2:$D$5",
Comment: "defined name comment",
Scope: "Sheet2",
})
工作表的打印区域和打印标题设置:
if err := f.SetDefinedName(&excelize.DefinedName{
Name: "_xlnm.Print_Area",
RefersTo: "Sheet1!$A$1:$Z$100",
Scope: "Sheet1",
}); err != nil {
fmt.Println(err)
}
if err := f.SetDefinedName(&excelize.DefinedName{
Name: "_xlnm.Print_Titles",
RefersTo: "Sheet1!$A:$A,Sheet1!$1:$1",
Scope: "Sheet1",
}); err != nil {
fmt.Println(err)
}