forked from p30928647/excelize
ref #65, new formula function: HYPERLINK
This commit is contained in:
parent
61c71caf4f
commit
2e1b0efadc
15
calc.go
15
calc.go
|
@ -14514,6 +14514,21 @@ func (fn *formulaFuncs) HLOOKUP(argsList *list.List) formulaArg {
|
|||
return newErrorFormulaArg(formulaErrorNA, "HLOOKUP no result found")
|
||||
}
|
||||
|
||||
// HYPERLINK function creates a hyperlink to a specified location. The syntax
|
||||
// of the function is:
|
||||
//
|
||||
// HYPERLINK(link_location,[friendly_name])
|
||||
//
|
||||
func (fn *formulaFuncs) HYPERLINK(argsList *list.List) formulaArg {
|
||||
if argsList.Len() < 1 {
|
||||
return newErrorFormulaArg(formulaErrorVALUE, "HYPERLINK requires at least 1 argument")
|
||||
}
|
||||
if argsList.Len() > 2 {
|
||||
return newErrorFormulaArg(formulaErrorVALUE, "HYPERLINK allows at most 2 arguments")
|
||||
}
|
||||
return newStringFormulaArg(argsList.Back().Value.(formulaArg).Value())
|
||||
}
|
||||
|
||||
// calcMatch returns the position of the value by given match type, criteria
|
||||
// and lookup array for the formula function MATCH.
|
||||
func calcMatch(matchType int, criteria *formulaCriteria, lookupArray []formulaArg) formulaArg {
|
||||
|
|
|
@ -1788,6 +1788,9 @@ func TestCalcCellValue(t *testing.T) {
|
|||
"=HLOOKUP(F3,F3:F8,3,FALSE)": "34440",
|
||||
"=HLOOKUP(INT(F3),F3:F8,3,FALSE)": "34440",
|
||||
"=HLOOKUP(MUNIT(1),MUNIT(1),1,FALSE)": "1",
|
||||
// HYPERLINK
|
||||
"=HYPERLINK(\"https://github.com/xuri/excelize\")": "https://github.com/xuri/excelize",
|
||||
"=HYPERLINK(\"https://github.com/xuri/excelize\",\"Excelize\")": "Excelize",
|
||||
// VLOOKUP
|
||||
"=VLOOKUP(D2,D:D,1,FALSE)": "Jan",
|
||||
"=VLOOKUP(D2,D1:D10,1)": "Jan",
|
||||
|
@ -3725,6 +3728,9 @@ func TestCalcCellValue(t *testing.T) {
|
|||
"=MATCH(0,A1:B1)": "MATCH arguments lookup_array should be one-dimensional array",
|
||||
// TRANSPOSE
|
||||
"=TRANSPOSE()": "TRANSPOSE requires 1 argument",
|
||||
// HYPERLINK
|
||||
"=HYPERLINK()": "HYPERLINK requires at least 1 argument",
|
||||
"=HYPERLINK(\"https://github.com/xuri/excelize\",\"Excelize\",\"\")": "HYPERLINK allows at most 2 arguments",
|
||||
// VLOOKUP
|
||||
"=VLOOKUP()": "VLOOKUP requires at least 3 arguments",
|
||||
"=VLOOKUP(D2,D1,1,FALSE)": "VLOOKUP requires second argument of table array",
|
||||
|
|
Loading…
Reference in New Issue