|
|
@ -23,7 +23,7 @@ func (f *File) GetCellValue(sheet string, axis string) string {
|
|
|
|
rows = lastRow
|
|
|
|
rows = lastRow
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if rows <= xAxis {
|
|
|
|
if rows < xAxis {
|
|
|
|
return ""
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for _, v := range xlsx.SheetData.Row {
|
|
|
|
for _, v := range xlsx.SheetData.Row {
|
|
|
@ -67,7 +67,7 @@ func (f *File) GetCellFormula(sheet string, axis string) string {
|
|
|
|
rows = lastRow
|
|
|
|
rows = lastRow
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if rows <= xAxis {
|
|
|
|
if rows < xAxis {
|
|
|
|
return ""
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for _, v := range xlsx.SheetData.Row {
|
|
|
|
for _, v := range xlsx.SheetData.Row {
|
|
|
@ -86,29 +86,6 @@ func (f *File) GetCellFormula(sheet string, axis string) string {
|
|
|
|
return ""
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// SetCellHyperLink provides function to set cell hyperlink by given sheet index
|
|
|
|
|
|
|
|
// and link URL address. Only support external link currently.
|
|
|
|
|
|
|
|
func (f *File) SetCellHyperLink(sheet, axis, link string) {
|
|
|
|
|
|
|
|
axis = strings.ToUpper(axis)
|
|
|
|
|
|
|
|
var xlsx xlsxWorksheet
|
|
|
|
|
|
|
|
name := "xl/worksheets/" + strings.ToLower(sheet) + ".xml"
|
|
|
|
|
|
|
|
xml.Unmarshal([]byte(f.readXML(name)), &xlsx)
|
|
|
|
|
|
|
|
rID := f.addSheetRelationships(sheet, SourceRelationshipHyperLink, link, "External")
|
|
|
|
|
|
|
|
hyperlink := xlsxHyperlink{
|
|
|
|
|
|
|
|
Ref: axis,
|
|
|
|
|
|
|
|
RID: "rId" + strconv.Itoa(rID),
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if xlsx.Hyperlinks != nil {
|
|
|
|
|
|
|
|
xlsx.Hyperlinks.Hyperlink = append(xlsx.Hyperlinks.Hyperlink, hyperlink)
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
hyperlinks := xlsxHyperlinks{}
|
|
|
|
|
|
|
|
hyperlinks.Hyperlink = append(hyperlinks.Hyperlink, hyperlink)
|
|
|
|
|
|
|
|
xlsx.Hyperlinks = &hyperlinks
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
output, _ := xml.Marshal(xlsx)
|
|
|
|
|
|
|
|
f.saveFileList(name, replaceWorkSheetsRelationshipsNameSpace(string(output)))
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// SetCellFormula provides function to set cell formula by given string and
|
|
|
|
// SetCellFormula provides function to set cell formula by given string and
|
|
|
|
// sheet index.
|
|
|
|
// sheet index.
|
|
|
|
func (f *File) SetCellFormula(sheet, axis, formula string) {
|
|
|
|
func (f *File) SetCellFormula(sheet, axis, formula string) {
|
|
|
@ -139,3 +116,26 @@ func (f *File) SetCellFormula(sheet, axis, formula string) {
|
|
|
|
output, _ := xml.Marshal(xlsx)
|
|
|
|
output, _ := xml.Marshal(xlsx)
|
|
|
|
f.saveFileList(name, replaceWorkSheetsRelationshipsNameSpace(string(output)))
|
|
|
|
f.saveFileList(name, replaceWorkSheetsRelationshipsNameSpace(string(output)))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// SetCellHyperLink provides function to set cell hyperlink by given sheet index
|
|
|
|
|
|
|
|
// and link URL address. Only support external link currently.
|
|
|
|
|
|
|
|
func (f *File) SetCellHyperLink(sheet, axis, link string) {
|
|
|
|
|
|
|
|
axis = strings.ToUpper(axis)
|
|
|
|
|
|
|
|
var xlsx xlsxWorksheet
|
|
|
|
|
|
|
|
name := "xl/worksheets/" + strings.ToLower(sheet) + ".xml"
|
|
|
|
|
|
|
|
xml.Unmarshal([]byte(f.readXML(name)), &xlsx)
|
|
|
|
|
|
|
|
rID := f.addSheetRelationships(sheet, SourceRelationshipHyperLink, link, "External")
|
|
|
|
|
|
|
|
hyperlink := xlsxHyperlink{
|
|
|
|
|
|
|
|
Ref: axis,
|
|
|
|
|
|
|
|
RID: "rId" + strconv.Itoa(rID),
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if xlsx.Hyperlinks != nil {
|
|
|
|
|
|
|
|
xlsx.Hyperlinks.Hyperlink = append(xlsx.Hyperlinks.Hyperlink, hyperlink)
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
hyperlinks := xlsxHyperlinks{}
|
|
|
|
|
|
|
|
hyperlinks.Hyperlink = append(hyperlinks.Hyperlink, hyperlink)
|
|
|
|
|
|
|
|
xlsx.Hyperlinks = &hyperlinks
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
output, _ := xml.Marshal(xlsx)
|
|
|
|
|
|
|
|
f.saveFileList(name, replaceWorkSheetsRelationshipsNameSpace(string(output)))
|
|
|
|
|
|
|
|
}
|
|
|
|