This support get cell hyperlink for merged cells
This commit is contained in:
parent
9dbba9f34a
commit
3b807c4bfe
9
cell.go
9
cell.go
|
@ -801,12 +801,13 @@ func (f *File) GetCellHyperLink(sheet, cell string) (bool, string, error) {
|
|||
if err != nil {
|
||||
return false, "", err
|
||||
}
|
||||
if cell, err = f.mergeCellsParser(ws, cell); err != nil {
|
||||
return false, "", err
|
||||
}
|
||||
if ws.Hyperlinks != nil {
|
||||
for _, link := range ws.Hyperlinks.Hyperlink {
|
||||
if link.Ref == cell {
|
||||
ok, err := f.checkCellInRangeRef(cell, link.Ref)
|
||||
if err != nil {
|
||||
return false, "", err
|
||||
}
|
||||
if link.Ref == cell || ok {
|
||||
if link.RID != "" {
|
||||
return true, f.getSheetRelationshipsTargetByID(sheet, link.RID), err
|
||||
}
|
||||
|
|
|
@ -87,7 +87,7 @@ func TestDataValidation(t *testing.T) {
|
|||
|
||||
dataValidations, err = f.GetDataValidations("Sheet1")
|
||||
assert.NoError(t, err)
|
||||
assert.Len(t,dataValidations, 3)
|
||||
assert.Len(t, dataValidations, 3)
|
||||
|
||||
// Test get data validation on no exists worksheet
|
||||
_, err = f.GetDataValidations("SheetN")
|
||||
|
|
|
@ -480,7 +480,7 @@ func TestGetCellHyperLink(t *testing.T) {
|
|||
|
||||
ws, ok = f.Sheet.Load("xl/worksheets/sheet1.xml")
|
||||
assert.True(t, ok)
|
||||
ws.(*xlsxWorksheet).MergeCells = &xlsxMergeCells{Cells: []*xlsxMergeCell{{Ref: "A:A"}}}
|
||||
ws.(*xlsxWorksheet).Hyperlinks = &xlsxHyperlinks{Hyperlink: []xlsxHyperlink{{Ref: "A:A"}}}
|
||||
link, target, err = f.GetCellHyperLink("Sheet1", "A1")
|
||||
assert.EqualError(t, err, newCellNameToCoordinatesError("A", newInvalidCellNameError("A")).Error())
|
||||
assert.Equal(t, link, false)
|
||||
|
|
Loading…
Reference in New Issue