calc_test.go 102 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597
  1. package excelize
  2. import (
  3. "container/list"
  4. "path/filepath"
  5. "strings"
  6. "testing"
  7. "github.com/stretchr/testify/assert"
  8. "github.com/xuri/efp"
  9. )
  10. func prepareCalcData(cellData [][]interface{}) *File {
  11. f := NewFile()
  12. for r, row := range cellData {
  13. for c, value := range row {
  14. cell, _ := CoordinatesToCellName(c+1, r+1)
  15. _ = f.SetCellValue("Sheet1", cell, value)
  16. }
  17. }
  18. return f
  19. }
  20. func TestCalcCellValue(t *testing.T) {
  21. cellData := [][]interface{}{
  22. {1, 4, nil, "Month", "Team", "Sales"},
  23. {2, 5, nil, "Jan", "North 1", 36693},
  24. {3, nil, nil, "Jan", "North 2", 22100},
  25. {0, nil, nil, "Jan", "South 1", 53321},
  26. {nil, nil, nil, "Jan", "South 2", 34440},
  27. {nil, nil, nil, "Feb", "North 1", 29889},
  28. {nil, nil, nil, "Feb", "North 2", 50090},
  29. {nil, nil, nil, "Feb", "South 1", 32080},
  30. {nil, nil, nil, "Feb", "South 2", 45500},
  31. }
  32. mathCalc := map[string]string{
  33. "=2^3": "8",
  34. "=1=1": "TRUE",
  35. "=1=2": "FALSE",
  36. "=1<2": "TRUE",
  37. "=3<2": "FALSE",
  38. "=2<=3": "TRUE",
  39. "=2<=1": "FALSE",
  40. "=2>1": "TRUE",
  41. "=2>3": "FALSE",
  42. "=2>=1": "TRUE",
  43. "=2>=3": "FALSE",
  44. "=1&2": "12",
  45. // Engineering Functions
  46. // BESSELI
  47. "=BESSELI(4.5,1)": "15.389222753735925",
  48. "=BESSELI(32,1)": "5.502845511211247e+12",
  49. // BESSELJ
  50. "=BESSELJ(1.9,2)": "0.329925727692387",
  51. // BESSELK
  52. "=BESSELK(0.05,0)": "3.114234034289662",
  53. "=BESSELK(0.05,1)": "19.90967432724863",
  54. "=BESSELK(0.05,2)": "799.501207124235",
  55. "=BESSELK(3,2)": "0.061510458561912",
  56. // BESSELY
  57. "=BESSELY(0.05,0)": "-1.979311006841528",
  58. "=BESSELY(0.05,1)": "-12.789855163794034",
  59. "=BESSELY(0.05,2)": "-509.61489554491976",
  60. "=BESSELY(9,2)": "-0.229082087487741",
  61. // BIN2DEC
  62. "=BIN2DEC(\"10\")": "2",
  63. "=BIN2DEC(\"11\")": "3",
  64. "=BIN2DEC(\"0000000010\")": "2",
  65. "=BIN2DEC(\"1111111110\")": "-2",
  66. "=BIN2DEC(\"110\")": "6",
  67. // BIN2HEX
  68. "=BIN2HEX(\"10\")": "2",
  69. "=BIN2HEX(\"0000000001\")": "1",
  70. "=BIN2HEX(\"10\",10)": "0000000002",
  71. "=BIN2HEX(\"1111111110\")": "FFFFFFFFFE",
  72. "=BIN2HEX(\"11101\")": "1D",
  73. // BIN2OCT
  74. "=BIN2OCT(\"101\")": "5",
  75. "=BIN2OCT(\"0000000001\")": "1",
  76. "=BIN2OCT(\"10\",10)": "0000000002",
  77. "=BIN2OCT(\"1111111110\")": "7777777776",
  78. "=BIN2OCT(\"1110\")": "16",
  79. // BITAND
  80. "=BITAND(13,14)": "12",
  81. // BITLSHIFT
  82. "=BITLSHIFT(5,2)": "20",
  83. "=BITLSHIFT(3,5)": "96",
  84. // BITOR
  85. "=BITOR(9,12)": "13",
  86. // BITRSHIFT
  87. "=BITRSHIFT(20,2)": "5",
  88. "=BITRSHIFT(52,4)": "3",
  89. // BITXOR
  90. "=BITXOR(5,6)": "3",
  91. "=BITXOR(9,12)": "5",
  92. // COMPLEX
  93. "=COMPLEX(5,2)": "5+2i",
  94. "=COMPLEX(5,-9)": "5-9i",
  95. "=COMPLEX(-1,2,\"j\")": "-1+2j",
  96. "=COMPLEX(10,-5,\"i\")": "10-5i",
  97. "=COMPLEX(0,5)": "5i",
  98. "=COMPLEX(3,0)": "3",
  99. "=COMPLEX(0,-2)": "-2i",
  100. "=COMPLEX(0,0)": "0",
  101. "=COMPLEX(0,-1,\"j\")": "-j",
  102. // DEC2BIN
  103. "=DEC2BIN(2)": "10",
  104. "=DEC2BIN(3)": "11",
  105. "=DEC2BIN(2,10)": "0000000010",
  106. "=DEC2BIN(-2)": "1111111110",
  107. "=DEC2BIN(6)": "110",
  108. // DEC2HEX
  109. "=DEC2HEX(10)": "A",
  110. "=DEC2HEX(31)": "1F",
  111. "=DEC2HEX(16,10)": "0000000010",
  112. "=DEC2HEX(-16)": "FFFFFFFFF0",
  113. "=DEC2HEX(273)": "111",
  114. // DEC2OCT
  115. "=DEC2OCT(8)": "10",
  116. "=DEC2OCT(18)": "22",
  117. "=DEC2OCT(8,10)": "0000000010",
  118. "=DEC2OCT(-8)": "7777777770",
  119. "=DEC2OCT(237)": "355",
  120. // HEX2BIN
  121. "=HEX2BIN(\"2\")": "10",
  122. "=HEX2BIN(\"0000000001\")": "1",
  123. "=HEX2BIN(\"2\",10)": "0000000010",
  124. "=HEX2BIN(\"F0\")": "11110000",
  125. "=HEX2BIN(\"1D\")": "11101",
  126. // HEX2DEC
  127. "=HEX2DEC(\"A\")": "10",
  128. "=HEX2DEC(\"1F\")": "31",
  129. "=HEX2DEC(\"0000000010\")": "16",
  130. "=HEX2DEC(\"FFFFFFFFF0\")": "-16",
  131. "=HEX2DEC(\"111\")": "273",
  132. "=HEX2DEC(\"\")": "0",
  133. // HEX2OCT
  134. "=HEX2OCT(\"A\")": "12",
  135. "=HEX2OCT(\"000000000F\")": "17",
  136. "=HEX2OCT(\"8\",10)": "0000000010",
  137. "=HEX2OCT(\"FFFFFFFFF8\")": "7777777770",
  138. "=HEX2OCT(\"1F3\")": "763",
  139. // IMABS
  140. "=IMABS(\"2j\")": "2",
  141. "=IMABS(\"-1+2i\")": "2.23606797749979",
  142. "=IMABS(COMPLEX(-1,2,\"j\"))": "2.23606797749979",
  143. // IMAGINARY
  144. "=IMAGINARY(\"5+2i\")": "2",
  145. "=IMAGINARY(\"2-i\")": "-1",
  146. "=IMAGINARY(6)": "0",
  147. "=IMAGINARY(\"3i\")": "3",
  148. "=IMAGINARY(\"4+i\")": "1",
  149. // IMARGUMENT
  150. "=IMARGUMENT(\"5+2i\")": "0.380506377112365",
  151. "=IMARGUMENT(\"2-i\")": "-0.463647609000806",
  152. "=IMARGUMENT(6)": "0",
  153. // IMCONJUGATE
  154. "=IMCONJUGATE(\"5+2i\")": "5-2i",
  155. "=IMCONJUGATE(\"2-i\")": "2+i",
  156. "=IMCONJUGATE(6)": "6",
  157. "=IMCONJUGATE(\"3i\")": "-3i",
  158. "=IMCONJUGATE(\"4+i\")": "4-i",
  159. // IMCOS
  160. "=IMCOS(0)": "1",
  161. "=IMCOS(0.5)": "0.877582561890373",
  162. "=IMCOS(\"3+0.5i\")": "-1.1163412445261518-0.0735369737112366i",
  163. // IMCOSH
  164. "=IMCOSH(0.5)": "1.127625965206381",
  165. "=IMCOSH(\"3+0.5i\")": "8.835204606500994+4.802825082743033i",
  166. "=IMCOSH(\"2-i\")": "2.0327230070196656-3.0518977991518i",
  167. "=IMCOSH(COMPLEX(1,-1))": "0.8337300251311491-0.9888977057628651i",
  168. // IMCOT
  169. "=IMCOT(0.5)": "1.830487721712452",
  170. "=IMCOT(\"3+0.5i\")": "-0.4793455787473728-2.016092521506228i",
  171. "=IMCOT(\"2-i\")": "-0.171383612909185+0.8213297974938518i",
  172. "=IMCOT(COMPLEX(1,-1))": "0.21762156185440268+0.868014142895925i",
  173. // IMCSC
  174. "=IMCSC(\"j\")": "-0.8509181282393216i",
  175. // IMCSCH
  176. "=IMCSCH(COMPLEX(1,-1))": "0.30393100162842646+0.6215180171704284i",
  177. // IMDIV
  178. "=IMDIV(\"5+2i\",\"1+i\")": "3.5-1.5i",
  179. "=IMDIV(\"2+2i\",\"2+i\")": "1.2+0.4i",
  180. "=IMDIV(COMPLEX(5,2),COMPLEX(0,1))": "2-5i",
  181. // IMEXP
  182. "=IMEXP(0)": "1",
  183. "=IMEXP(0.5)": "1.648721270700128",
  184. "=IMEXP(\"1-2i\")": "-1.1312043837568135-2.4717266720048183i",
  185. "=IMEXP(COMPLEX(1,-1))": "1.4686939399158851-2.2873552871788423i",
  186. // IMLN
  187. "=IMLN(0.5)": "-0.693147180559945",
  188. "=IMLN(\"3+0.5i\")": "1.1123117757621668+0.16514867741462683i",
  189. "=IMLN(\"2-i\")": "0.8047189562170503-0.4636476090008061i",
  190. "=IMLN(COMPLEX(1,-1))": "0.3465735902799727-0.7853981633974483i",
  191. // IMLOG10
  192. "=IMLOG10(0.5)": "-0.301029995663981",
  193. "=IMLOG10(\"3+0.5i\")": "0.48307086636951624+0.07172315929479262i",
  194. "=IMLOG10(\"2-i\")": "0.34948500216800943-0.20135959813668655i",
  195. "=IMLOG10(COMPLEX(1,-1))": "0.1505149978319906-0.3410940884604603i",
  196. // IMREAL
  197. "=IMREAL(\"5+2i\")": "5",
  198. "=IMREAL(\"2+2i\")": "2",
  199. "=IMREAL(6)": "6",
  200. "=IMREAL(\"3i\")": "0",
  201. "=IMREAL(COMPLEX(4,1))": "4",
  202. // IMSEC
  203. "=IMSEC(0.5)": "1.139493927324549",
  204. "=IMSEC(\"3+0.5i\")": "-0.8919131797403304+0.05875317818173977i",
  205. "=IMSEC(\"2-i\")": "-0.4131493442669401-0.687527438655479i",
  206. "=IMSEC(COMPLEX(1,-1))": "0.49833703055518686-0.5910838417210451i",
  207. // IMSECH
  208. "=IMSECH(0.5)": "0.886818883970074",
  209. "=IMSECH(\"3+0.5i\")": "0.08736657796213027-0.047492549490160664i",
  210. "=IMSECH(\"2-i\")": "0.1511762982655772+0.22697367539372157i",
  211. "=IMSECH(COMPLEX(1,-1))": "0.49833703055518686+0.5910838417210451i",
  212. // IMSIN
  213. "=IMSIN(0.5)": "0.479425538604203",
  214. "=IMSIN(\"3+0.5i\")": "0.15913058529843999-0.5158804424525267i",
  215. "=IMSIN(\"2-i\")": "1.4031192506220405+0.4890562590412937i",
  216. "=IMSIN(COMPLEX(1,-1))": "1.2984575814159773-0.6349639147847361i",
  217. // IMSINH
  218. "=IMSINH(-0)": "0",
  219. "=IMSINH(0.5)": "0.521095305493747",
  220. "=IMSINH(\"3+0.5i\")": "8.791512343493714+4.82669427481082i",
  221. "=IMSINH(\"2-i\")": "1.9596010414216063-3.165778513216168i",
  222. "=IMSINH(COMPLEX(1,-1))": "0.6349639147847361-1.2984575814159773i",
  223. // IMSQRT
  224. "=IMSQRT(\"i\")": "0.7071067811865476+0.7071067811865476i",
  225. "=IMSQRT(\"2-i\")": "1.455346690225355-0.34356074972251244i",
  226. "=IMSQRT(\"5+2i\")": "2.27872385417085+0.4388421169022545i",
  227. "=IMSQRT(6)": "2.449489742783178",
  228. "=IMSQRT(\"-2-4i\")": "1.1117859405028423-1.7989074399478673i",
  229. // IMSUB
  230. "=IMSUB(\"5+i\",\"1+4i\")": "4-3i",
  231. "=IMSUB(\"9+2i\",6)": "3+2i",
  232. "=IMSUB(COMPLEX(5,2),COMPLEX(0,1))": "5+i",
  233. // IMSUM
  234. "=IMSUM(\"1-i\",\"5+10i\",2)": "8+9i",
  235. "=IMSUM(COMPLEX(5,2),COMPLEX(0,1))": "5+3i",
  236. // IMTAN
  237. "=IMTAN(-0)": "0",
  238. "=IMTAN(0.5)": "0.546302489843791",
  239. "=IMTAN(\"3+0.5i\")": "-0.11162105077158344+0.46946999342588536i",
  240. "=IMTAN(\"2-i\")": "-0.24345820118572523-1.16673625724092i",
  241. "=IMTAN(COMPLEX(1,-1))": "0.2717525853195117-1.0839233273386948i",
  242. // OCT2BIN
  243. "=OCT2BIN(\"5\")": "101",
  244. "=OCT2BIN(\"0000000001\")": "1",
  245. "=OCT2BIN(\"2\",10)": "0000000010",
  246. "=OCT2BIN(\"7777777770\")": "1111111000",
  247. "=OCT2BIN(\"16\")": "1110",
  248. // OCT2DEC
  249. "=OCT2DEC(\"10\")": "8",
  250. "=OCT2DEC(\"22\")": "18",
  251. "=OCT2DEC(\"0000000010\")": "8",
  252. "=OCT2DEC(\"7777777770\")": "-8",
  253. "=OCT2DEC(\"355\")": "237",
  254. // OCT2HEX
  255. "=OCT2HEX(\"10\")": "8",
  256. "=OCT2HEX(\"0000000007\")": "7",
  257. "=OCT2HEX(\"10\",10)": "0000000008",
  258. "=OCT2HEX(\"7777777770\")": "FFFFFFFFF8",
  259. "=OCT2HEX(\"763\")": "1F3",
  260. // Math and Trigonometric Functions
  261. // ABS
  262. "=ABS(-1)": "1",
  263. "=ABS(-6.5)": "6.5",
  264. "=ABS(6.5)": "6.5",
  265. "=ABS(0)": "0",
  266. "=ABS(2-4.5)": "2.5",
  267. "=ABS(ABS(-1))": "1",
  268. // ACOS
  269. "=ACOS(-1)": "3.141592653589793",
  270. "=ACOS(0)": "1.570796326794897",
  271. "=ACOS(ABS(0))": "1.570796326794897",
  272. // ACOSH
  273. "=ACOSH(1)": "0",
  274. "=ACOSH(2.5)": "1.566799236972411",
  275. "=ACOSH(5)": "2.292431669561178",
  276. "=ACOSH(ACOSH(5))": "1.471383321536679",
  277. // ACOT
  278. "=_xlfn.ACOT(1)": "0.785398163397448",
  279. "=_xlfn.ACOT(-2)": "2.677945044588987",
  280. "=_xlfn.ACOT(0)": "1.570796326794897",
  281. "=_xlfn.ACOT(_xlfn.ACOT(0))": "0.566911504941009",
  282. // ACOTH
  283. "=_xlfn.ACOTH(-5)": "-0.202732554054082",
  284. "=_xlfn.ACOTH(1.1)": "1.522261218861711",
  285. "=_xlfn.ACOTH(2)": "0.549306144334055",
  286. "=_xlfn.ACOTH(ABS(-2))": "0.549306144334055",
  287. // ARABIC
  288. "=_xlfn.ARABIC(\"IV\")": "4",
  289. "=_xlfn.ARABIC(\"-IV\")": "-4",
  290. "=_xlfn.ARABIC(\"MCXX\")": "1120",
  291. "=_xlfn.ARABIC(\"\")": "0",
  292. "=_xlfn.ARABIC(\" ll lc \")": "-50",
  293. // ASIN
  294. "=ASIN(-1)": "-1.570796326794897",
  295. "=ASIN(0)": "0",
  296. "=ASIN(ASIN(0))": "0",
  297. // ASINH
  298. "=ASINH(0)": "0",
  299. "=ASINH(-0.5)": "-0.481211825059604",
  300. "=ASINH(2)": "1.44363547517881",
  301. "=ASINH(ASINH(0))": "0",
  302. // ATAN
  303. "=ATAN(-1)": "-0.785398163397448",
  304. "=ATAN(0)": "0",
  305. "=ATAN(1)": "0.785398163397448",
  306. "=ATAN(ATAN(0))": "0",
  307. // ATANH
  308. "=ATANH(-0.8)": "-1.09861228866811",
  309. "=ATANH(0)": "0",
  310. "=ATANH(0.5)": "0.549306144334055",
  311. "=ATANH(ATANH(0))": "0",
  312. // ATAN2
  313. "=ATAN2(1,1)": "0.785398163397448",
  314. "=ATAN2(1,-1)": "-0.785398163397448",
  315. "=ATAN2(4,0)": "0",
  316. "=ATAN2(4,ATAN2(4,0))": "0",
  317. // BASE
  318. "=BASE(12,2)": "1100",
  319. "=BASE(12,2,8)": "00001100",
  320. "=BASE(100000,16)": "186A0",
  321. "=BASE(BASE(12,2),16)": "44C",
  322. // CEILING
  323. "=CEILING(22.25,0.1)": "22.3",
  324. "=CEILING(22.25,0.5)": "22.5",
  325. "=CEILING(22.25,1)": "23",
  326. "=CEILING(22.25,10)": "30",
  327. "=CEILING(22.25,20)": "40",
  328. "=CEILING(-22.25,-0.1)": "-22.3",
  329. "=CEILING(-22.25,-1)": "-23",
  330. "=CEILING(-22.25,-5)": "-25",
  331. "=CEILING(22.25)": "23",
  332. "=CEILING(CEILING(22.25,0.1),0.1)": "22.3",
  333. // _xlfn.CEILING.MATH
  334. "=_xlfn.CEILING.MATH(15.25,1)": "16",
  335. "=_xlfn.CEILING.MATH(15.25,0.1)": "15.3",
  336. "=_xlfn.CEILING.MATH(15.25,5)": "20",
  337. "=_xlfn.CEILING.MATH(-15.25,1)": "-15",
  338. "=_xlfn.CEILING.MATH(-15.25,1,1)": "-15", // should be 16
  339. "=_xlfn.CEILING.MATH(-15.25,10)": "-10",
  340. "=_xlfn.CEILING.MATH(-15.25)": "-15",
  341. "=_xlfn.CEILING.MATH(-15.25,-5,-1)": "-10",
  342. "=_xlfn.CEILING.MATH(_xlfn.CEILING.MATH(15.25,1),1)": "16",
  343. // _xlfn.CEILING.PRECISE
  344. "=_xlfn.CEILING.PRECISE(22.25,0.1)": "22.3",
  345. "=_xlfn.CEILING.PRECISE(22.25,0.5)": "22.5",
  346. "=_xlfn.CEILING.PRECISE(22.25,1)": "23",
  347. "=_xlfn.CEILING.PRECISE(22.25)": "23",
  348. "=_xlfn.CEILING.PRECISE(22.25,10)": "30",
  349. "=_xlfn.CEILING.PRECISE(22.25,0)": "0",
  350. "=_xlfn.CEILING.PRECISE(-22.25,1)": "-22",
  351. "=_xlfn.CEILING.PRECISE(-22.25,-1)": "-22",
  352. "=_xlfn.CEILING.PRECISE(-22.25,5)": "-20",
  353. "=_xlfn.CEILING.PRECISE(_xlfn.CEILING.PRECISE(22.25,0.1),5)": "25",
  354. // COMBIN
  355. "=COMBIN(6,1)": "6",
  356. "=COMBIN(6,2)": "15",
  357. "=COMBIN(6,3)": "20",
  358. "=COMBIN(6,4)": "15",
  359. "=COMBIN(6,5)": "6",
  360. "=COMBIN(6,6)": "1",
  361. "=COMBIN(0,0)": "1",
  362. "=COMBIN(6,COMBIN(0,0))": "6",
  363. // _xlfn.COMBINA
  364. "=_xlfn.COMBINA(6,1)": "6",
  365. "=_xlfn.COMBINA(6,2)": "21",
  366. "=_xlfn.COMBINA(6,3)": "56",
  367. "=_xlfn.COMBINA(6,4)": "126",
  368. "=_xlfn.COMBINA(6,5)": "252",
  369. "=_xlfn.COMBINA(6,6)": "462",
  370. "=_xlfn.COMBINA(0,0)": "0",
  371. "=_xlfn.COMBINA(0,_xlfn.COMBINA(0,0))": "0",
  372. // COS
  373. "=COS(0.785398163)": "0.707106781467586",
  374. "=COS(0)": "1",
  375. "=COS(COS(0))": "0.54030230586814",
  376. // COSH
  377. "=COSH(0)": "1",
  378. "=COSH(0.5)": "1.127625965206381",
  379. "=COSH(-2)": "3.762195691083632",
  380. "=COSH(COSH(0))": "1.543080634815244",
  381. // _xlfn.COT
  382. "=_xlfn.COT(0.785398163397448)": "1.000000000000001",
  383. "=_xlfn.COT(_xlfn.COT(0.45))": "-0.545473116787229",
  384. // _xlfn.COTH
  385. "=_xlfn.COTH(-3.14159265358979)": "-1.003741873197322",
  386. "=_xlfn.COTH(_xlfn.COTH(1))": "1.156014018113954",
  387. // _xlfn.CSC
  388. "=_xlfn.CSC(-6)": "3.578899547254406",
  389. "=_xlfn.CSC(1.5707963267949)": "1",
  390. "=_xlfn.CSC(_xlfn.CSC(1))": "1.077851840310882",
  391. // _xlfn.CSCH
  392. "=_xlfn.CSCH(-3.14159265358979)": "-0.086589537530047",
  393. "=_xlfn.CSCH(_xlfn.CSCH(1))": "1.044510103955183",
  394. // _xlfn.DECIMAL
  395. `=_xlfn.DECIMAL("1100",2)`: "12",
  396. `=_xlfn.DECIMAL("186A0",16)`: "100000",
  397. `=_xlfn.DECIMAL("31L0",32)`: "100000",
  398. `=_xlfn.DECIMAL("70122",8)`: "28754",
  399. `=_xlfn.DECIMAL("0x70122",8)`: "28754",
  400. // DEGREES
  401. "=DEGREES(1)": "57.29577951308232",
  402. "=DEGREES(2.5)": "143.2394487827058",
  403. "=DEGREES(DEGREES(1))": "3282.806350011744",
  404. // EVEN
  405. "=EVEN(23)": "24",
  406. "=EVEN(2.22)": "4",
  407. "=EVEN(0)": "0",
  408. "=EVEN(-0.3)": "-2",
  409. "=EVEN(-11)": "-12",
  410. "=EVEN(-4)": "-4",
  411. "=EVEN((0))": "0",
  412. // EXP
  413. "=EXP(100)": "2.6881171418161356E+43",
  414. "=EXP(0.1)": "1.105170918075648",
  415. "=EXP(0)": "1",
  416. "=EXP(-5)": "0.006737946999085",
  417. "=EXP(EXP(0))": "2.718281828459045",
  418. // FACT
  419. "=FACT(3)": "6",
  420. "=FACT(6)": "720",
  421. "=FACT(10)": "3.6288e+06",
  422. "=FACT(FACT(3))": "720",
  423. // FACTDOUBLE
  424. "=FACTDOUBLE(5)": "15",
  425. "=FACTDOUBLE(8)": "384",
  426. "=FACTDOUBLE(13)": "135135",
  427. "=FACTDOUBLE(FACTDOUBLE(1))": "1",
  428. // FLOOR
  429. "=FLOOR(26.75,0.1)": "26.700000000000003",
  430. "=FLOOR(26.75,0.5)": "26.5",
  431. "=FLOOR(26.75,1)": "26",
  432. "=FLOOR(26.75,10)": "20",
  433. "=FLOOR(26.75,20)": "20",
  434. "=FLOOR(-26.75,-0.1)": "-26.700000000000003",
  435. "=FLOOR(-26.75,-1)": "-26",
  436. "=FLOOR(-26.75,-5)": "-25",
  437. "=FLOOR(FLOOR(26.75,1),1)": "26",
  438. // _xlfn.FLOOR.MATH
  439. "=_xlfn.FLOOR.MATH(58.55)": "58",
  440. "=_xlfn.FLOOR.MATH(58.55,0.1)": "58.5",
  441. "=_xlfn.FLOOR.MATH(58.55,5)": "55",
  442. "=_xlfn.FLOOR.MATH(58.55,1,1)": "58",
  443. "=_xlfn.FLOOR.MATH(-58.55,1)": "-59",
  444. "=_xlfn.FLOOR.MATH(-58.55,1,-1)": "-58",
  445. "=_xlfn.FLOOR.MATH(-58.55,1,1)": "-59", // should be -58
  446. "=_xlfn.FLOOR.MATH(-58.55,10)": "-60",
  447. "=_xlfn.FLOOR.MATH(_xlfn.FLOOR.MATH(1),10)": "0",
  448. // _xlfn.FLOOR.PRECISE
  449. "=_xlfn.FLOOR.PRECISE(26.75,0.1)": "26.700000000000003",
  450. "=_xlfn.FLOOR.PRECISE(26.75,0.5)": "26.5",
  451. "=_xlfn.FLOOR.PRECISE(26.75,1)": "26",
  452. "=_xlfn.FLOOR.PRECISE(26.75)": "26",
  453. "=_xlfn.FLOOR.PRECISE(26.75,10)": "20",
  454. "=_xlfn.FLOOR.PRECISE(26.75,0)": "0",
  455. "=_xlfn.FLOOR.PRECISE(-26.75,1)": "-27",
  456. "=_xlfn.FLOOR.PRECISE(-26.75,-1)": "-27",
  457. "=_xlfn.FLOOR.PRECISE(-26.75,-5)": "-30",
  458. "=_xlfn.FLOOR.PRECISE(_xlfn.FLOOR.PRECISE(26.75),-5)": "25",
  459. // GCD
  460. "=GCD(0)": "0",
  461. "=GCD(1,0)": "1",
  462. "=GCD(1,5)": "1",
  463. "=GCD(15,10,25)": "5",
  464. "=GCD(0,8,12)": "4",
  465. "=GCD(7,2)": "1",
  466. "=GCD(1,GCD(1))": "1",
  467. // INT
  468. "=INT(100.9)": "100",
  469. "=INT(5.22)": "5",
  470. "=INT(5.99)": "5",
  471. "=INT(-6.1)": "-7",
  472. "=INT(-100.9)": "-101",
  473. "=INT(INT(0))": "0",
  474. // ISO.CEILING
  475. "=ISO.CEILING(22.25)": "23",
  476. "=ISO.CEILING(22.25,1)": "23",
  477. "=ISO.CEILING(22.25,0.1)": "22.3",
  478. "=ISO.CEILING(22.25,10)": "30",
  479. "=ISO.CEILING(-22.25,1)": "-22",
  480. "=ISO.CEILING(-22.25,0.1)": "-22.200000000000003",
  481. "=ISO.CEILING(-22.25,5)": "-20",
  482. "=ISO.CEILING(-22.25,0)": "0",
  483. "=ISO.CEILING(1,ISO.CEILING(1,0))": "0",
  484. // LCM
  485. "=LCM(1,5)": "5",
  486. "=LCM(15,10,25)": "150",
  487. "=LCM(1,8,12)": "24",
  488. "=LCM(7,2)": "14",
  489. "=LCM(7)": "7",
  490. `=LCM("",1)`: "1",
  491. `=LCM(0,0)`: "0",
  492. `=LCM(0,LCM(0,0))`: "0",
  493. // LN
  494. "=LN(1)": "0",
  495. "=LN(100)": "4.605170185988092",
  496. "=LN(0.5)": "-0.693147180559945",
  497. "=LN(LN(100))": "1.527179625807901",
  498. // LOG
  499. "=LOG(64,2)": "6",
  500. "=LOG(100)": "2",
  501. "=LOG(4,0.5)": "-2",
  502. "=LOG(500)": "2.698970004336019",
  503. "=LOG(LOG(100))": "0.301029995663981",
  504. // LOG10
  505. "=LOG10(100)": "2",
  506. "=LOG10(1000)": "3",
  507. "=LOG10(0.001)": "-3",
  508. "=LOG10(25)": "1.397940008672038",
  509. "=LOG10(LOG10(100))": "0.301029995663981",
  510. // IMLOG2
  511. "=IMLOG2(\"5+2i\")": "2.4289904975637864+0.5489546632866347i",
  512. "=IMLOG2(\"2-i\")": "1.1609640474436813-0.6689021062254881i",
  513. "=IMLOG2(6)": "2.584962500721156",
  514. "=IMLOG2(\"3i\")": "1.584962500721156+2.266180070913597i",
  515. "=IMLOG2(\"4+i\")": "2.04373142062517+0.3534295024167349i",
  516. // IMPOWER
  517. "=IMPOWER(\"2-i\",2)": "3.000000000000001-4i",
  518. "=IMPOWER(\"2-i\",3)": "2.0000000000000018-11.000000000000002i",
  519. "=IMPOWER(9,0.5)": "3",
  520. "=IMPOWER(\"2+4i\",-2)": "-0.029999999999999985-0.039999999999999994i",
  521. // IMPRODUCT
  522. "=IMPRODUCT(3,6)": "18",
  523. `=IMPRODUCT("",3,SUM(6))`: "18",
  524. "=IMPRODUCT(\"1-i\",\"5+10i\",2)": "30+10i",
  525. "=IMPRODUCT(COMPLEX(5,2),COMPLEX(0,1))": "-2+5i",
  526. "=IMPRODUCT(A1:C1)": "4",
  527. // MOD
  528. "=MOD(6,4)": "2",
  529. "=MOD(6,3)": "0",
  530. "=MOD(6,2.5)": "1",
  531. "=MOD(6,1.333)": "0.668",
  532. "=MOD(-10.23,1)": "0.77",
  533. "=MOD(MOD(1,1),1)": "0",
  534. // MROUND
  535. "=MROUND(333.7,0.5)": "333.5",
  536. "=MROUND(333.8,1)": "334",
  537. "=MROUND(333.3,2)": "334",
  538. "=MROUND(555.3,400)": "400",
  539. "=MROUND(555,1000)": "1000",
  540. "=MROUND(-555.7,-1)": "-556",
  541. "=MROUND(-555.4,-1)": "-555",
  542. "=MROUND(-1555,-1000)": "-2000",
  543. "=MROUND(MROUND(1,1),1)": "1",
  544. // MULTINOMIAL
  545. "=MULTINOMIAL(3,1,2,5)": "27720",
  546. `=MULTINOMIAL("",3,1,2,5)`: "27720",
  547. "=MULTINOMIAL(MULTINOMIAL(1))": "1",
  548. // _xlfn.MUNIT
  549. "=_xlfn.MUNIT(4)": "",
  550. // ODD
  551. "=ODD(22)": "23",
  552. "=ODD(1.22)": "3",
  553. "=ODD(1.22+4)": "7",
  554. "=ODD(0)": "1",
  555. "=ODD(-1.3)": "-3",
  556. "=ODD(-10)": "-11",
  557. "=ODD(-3)": "-3",
  558. "=ODD(ODD(1))": "1",
  559. // PI
  560. "=PI()": "3.141592653589793",
  561. // POWER
  562. "=POWER(4,2)": "16",
  563. "=POWER(4,POWER(1,1))": "4",
  564. // PRODUCT
  565. "=PRODUCT(3,6)": "18",
  566. `=PRODUCT("",3,6)`: "18",
  567. `=PRODUCT(PRODUCT(1),3,6)`: "18",
  568. // QUOTIENT
  569. "=QUOTIENT(5,2)": "2",
  570. "=QUOTIENT(4.5,3.1)": "1",
  571. "=QUOTIENT(-10,3)": "-3",
  572. "=QUOTIENT(QUOTIENT(1,2),3)": "0",
  573. // RADIANS
  574. "=RADIANS(50)": "0.872664625997165",
  575. "=RADIANS(-180)": "-3.141592653589793",
  576. "=RADIANS(180)": "3.141592653589793",
  577. "=RADIANS(360)": "6.283185307179586",
  578. "=RADIANS(RADIANS(360))": "0.109662271123215",
  579. // ROMAN
  580. "=ROMAN(499,0)": "CDXCIX",
  581. "=ROMAN(1999,0)": "MCMXCIX",
  582. "=ROMAN(1999,1)": "MLMVLIV",
  583. "=ROMAN(1999,2)": "MXMIX",
  584. "=ROMAN(1999,3)": "MVMIV",
  585. "=ROMAN(1999,4)": "MIM",
  586. "=ROMAN(1999,-1)": "MCMXCIX",
  587. "=ROMAN(1999,5)": "MIM",
  588. "=ROMAN(1999,ODD(1))": "MLMVLIV",
  589. // ROUND
  590. "=ROUND(100.319,1)": "100.30000000000001",
  591. "=ROUND(5.28,1)": "5.300000000000001",
  592. "=ROUND(5.9999,3)": "6.000000000000002",
  593. "=ROUND(99.5,0)": "100",
  594. "=ROUND(-6.3,0)": "-6",
  595. "=ROUND(-100.5,0)": "-101",
  596. "=ROUND(-22.45,1)": "-22.5",
  597. "=ROUND(999,-1)": "1000",
  598. "=ROUND(991,-1)": "990",
  599. "=ROUND(ROUND(100,1),-1)": "100",
  600. // ROUNDDOWN
  601. "=ROUNDDOWN(99.999,1)": "99.9",
  602. "=ROUNDDOWN(99.999,2)": "99.99000000000002",
  603. "=ROUNDDOWN(99.999,0)": "99",
  604. "=ROUNDDOWN(99.999,-1)": "90",
  605. "=ROUNDDOWN(-99.999,2)": "-99.99000000000002",
  606. "=ROUNDDOWN(-99.999,-1)": "-90",
  607. "=ROUNDDOWN(ROUNDDOWN(100,1),-1)": "100",
  608. // ROUNDUP`
  609. "=ROUNDUP(11.111,1)": "11.200000000000001",
  610. "=ROUNDUP(11.111,2)": "11.120000000000003",
  611. "=ROUNDUP(11.111,0)": "12",
  612. "=ROUNDUP(11.111,-1)": "20",
  613. "=ROUNDUP(-11.111,2)": "-11.120000000000003",
  614. "=ROUNDUP(-11.111,-1)": "-20",
  615. "=ROUNDUP(ROUNDUP(100,1),-1)": "100",
  616. // SEC
  617. "=_xlfn.SEC(-3.14159265358979)": "-1",
  618. "=_xlfn.SEC(0)": "1",
  619. "=_xlfn.SEC(_xlfn.SEC(0))": "0.54030230586814",
  620. // SECH
  621. "=_xlfn.SECH(-3.14159265358979)": "0.086266738334055",
  622. "=_xlfn.SECH(0)": "1",
  623. "=_xlfn.SECH(_xlfn.SECH(0))": "0.648054273663886",
  624. // SIGN
  625. "=SIGN(9.5)": "1",
  626. "=SIGN(-9.5)": "-1",
  627. "=SIGN(0)": "0",
  628. "=SIGN(0.00000001)": "1",
  629. "=SIGN(6-7)": "-1",
  630. "=SIGN(SIGN(-1))": "-1",
  631. // SIN
  632. "=SIN(0.785398163)": "0.707106780905509",
  633. "=SIN(SIN(1))": "0.745624141665558",
  634. // SINH
  635. "=SINH(0)": "0",
  636. "=SINH(0.5)": "0.521095305493747",
  637. "=SINH(-2)": "-3.626860407847019",
  638. "=SINH(SINH(0))": "0",
  639. // SQRT
  640. "=SQRT(4)": "2",
  641. "=SQRT(SQRT(16))": "2",
  642. // SQRTPI
  643. "=SQRTPI(5)": "3.963327297606011",
  644. "=SQRTPI(0.2)": "0.792665459521202",
  645. "=SQRTPI(100)": "17.72453850905516",
  646. "=SQRTPI(0)": "0",
  647. "=SQRTPI(SQRTPI(0))": "0",
  648. // STDEV
  649. "=STDEV(F2:F9)": "10724.978287523809",
  650. "=STDEV(MUNIT(2))": "0.577350269189626",
  651. "=STDEV(0,INT(0))": "0",
  652. "=STDEV(INT(1),INT(1))": "0",
  653. // STDEV.S
  654. "=STDEV.S(F2:F9)": "10724.978287523809",
  655. // STDEVA
  656. "=STDEVA(F2:F9)": "10724.978287523809",
  657. "=STDEVA(MUNIT(2))": "0.577350269189626",
  658. "=STDEVA(0,INT(0))": "0",
  659. // POISSON.DIST
  660. "=POISSON.DIST(20,25,FALSE)": "0.051917468608491",
  661. "=POISSON.DIST(35,40,TRUE)": "0.242414197690103",
  662. // POISSON
  663. "=POISSON(20,25,FALSE)": "0.051917468608491",
  664. "=POISSON(35,40,TRUE)": "0.242414197690103",
  665. // SUM
  666. "=SUM(1,2)": "3",
  667. `=SUM("",1,2)`: "3",
  668. "=SUM(1,2+3)": "6",
  669. "=SUM(SUM(1,2),2)": "5",
  670. "=(-2-SUM(-4+7))*5": "-25",
  671. "SUM(1,2,3,4,5,6,7)": "28",
  672. "=SUM(1,2)+SUM(1,2)": "6",
  673. "=1+SUM(SUM(1,2*3),4)": "12",
  674. "=1+SUM(SUM(1,-2*3),4)": "0",
  675. "=(-2-SUM(-4*(7+7)))*5": "270",
  676. "=SUM(SUM(1+2/1)*2-3/2,2)": "6.5",
  677. "=((3+5*2)+3)/5+(-6)/4*2+3": "3.2",
  678. "=1+SUM(SUM(1,2*3),4)*-4/2+5+(4+2)*3": "2",
  679. "=1+SUM(SUM(1,2*3),4)*4/3+5+(4+2)*3": "38.666666666666664",
  680. // SUMIF
  681. `=SUMIF(F1:F5, "")`: "0",
  682. `=SUMIF(A1:A5, "3")`: "3",
  683. `=SUMIF(F1:F5, "=36693")`: "36693",
  684. `=SUMIF(F1:F5, "<100")`: "0",
  685. `=SUMIF(F1:F5, "<=36693")`: "93233",
  686. `=SUMIF(F1:F5, ">100")`: "146554",
  687. `=SUMIF(F1:F5, ">=100")`: "146554",
  688. `=SUMIF(F1:F5, ">=text")`: "0",
  689. `=SUMIF(F1:F5, "*Jan",F2:F5)`: "0",
  690. `=SUMIF(D3:D7,"Jan",F2:F5)`: "112114",
  691. `=SUMIF(D2:D9,"Feb",F2:F9)`: "157559",
  692. `=SUMIF(E2:E9,"North 1",F2:F9)`: "66582",
  693. `=SUMIF(E2:E9,"North*",F2:F9)`: "138772",
  694. // SUMSQ
  695. "=SUMSQ(A1:A4)": "14",
  696. "=SUMSQ(A1,B1,A2,B2,6)": "82",
  697. `=SUMSQ("",A1,B1,A2,B2,6)`: "82",
  698. `=SUMSQ(1,SUMSQ(1))`: "2",
  699. "=SUMSQ(MUNIT(3))": "0",
  700. // TAN
  701. "=TAN(1.047197551)": "1.732050806782486",
  702. "=TAN(0)": "0",
  703. "=TAN(TAN(0))": "0",
  704. // TANH
  705. "=TANH(0)": "0",
  706. "=TANH(0.5)": "0.46211715726001",
  707. "=TANH(-2)": "-0.964027580075817",
  708. "=TANH(TANH(0))": "0",
  709. // TRUNC
  710. "=TRUNC(99.999,1)": "99.9",
  711. "=TRUNC(99.999,2)": "99.99",
  712. "=TRUNC(99.999)": "99",
  713. "=TRUNC(99.999,-1)": "90",
  714. "=TRUNC(-99.999,2)": "-99.99",
  715. "=TRUNC(-99.999,-1)": "-90",
  716. "=TRUNC(TRUNC(1),-1)": "0",
  717. // Statistical Functions
  718. // AVERAGE
  719. "=AVERAGE(INT(1))": "1",
  720. "=AVERAGE(A1)": "1",
  721. "=AVERAGE(A1:A2)": "1.5",
  722. "=AVERAGE(D2:F9)": "38014.125",
  723. // AVERAGEA
  724. "=AVERAGEA(INT(1))": "1",
  725. "=AVERAGEA(A1)": "1",
  726. "=AVERAGEA(A1:A2)": "1.5",
  727. "=AVERAGEA(D2:F9)": "12671.375",
  728. // COUNT
  729. "=COUNT()": "0",
  730. "=COUNT(E1:F2,\"text\",1,INT(2))": "3",
  731. // COUNTA
  732. "=COUNTA()": "0",
  733. "=COUNTA(A1:A5,B2:B5,\"text\",1,INT(2))": "8",
  734. "=COUNTA(COUNTA(1),MUNIT(1))": "2",
  735. // COUNTBLANK
  736. "=COUNTBLANK(MUNIT(1))": "0",
  737. "=COUNTBLANK(1)": "0",
  738. "=COUNTBLANK(B1:C1)": "1",
  739. "=COUNTBLANK(C1)": "1",
  740. // FISHER
  741. "=FISHER(-0.9)": "-1.47221948958322",
  742. "=FISHER(-0.25)": "-0.255412811882995",
  743. "=FISHER(0.8)": "1.09861228866811",
  744. "=FISHER(INT(0))": "0",
  745. // FISHERINV
  746. "=FISHERINV(-0.2)": "-0.197375320224904",
  747. "=FISHERINV(INT(0))": "0",
  748. "=FISHERINV(2.8)": "0.992631520201128",
  749. // GAMMA
  750. "=GAMMA(0.1)": "9.513507698668732",
  751. "=GAMMA(INT(1))": "1",
  752. "=GAMMA(1.5)": "0.886226925452758",
  753. "=GAMMA(5.5)": "52.34277778455352",
  754. // GAMMALN
  755. "=GAMMALN(4.5)": "2.453736570842443",
  756. "=GAMMALN(INT(1))": "0",
  757. // HARMEAN
  758. "=HARMEAN(2.5,3,0.5,1,3)": "1.229508196721312",
  759. "=HARMEAN(\"2.5\",3,0.5,1,INT(3),\"\")": "1.229508196721312",
  760. // KURT
  761. "=KURT(F1:F9)": "-1.033503502551368",
  762. "=KURT(F1,F2:F9)": "-1.033503502551368",
  763. "=KURT(INT(1),MUNIT(2))": "-3.333333333333336",
  764. // NORM.DIST
  765. "=NORM.DIST(0.8,1,0.3,TRUE)": "0.252492537546923",
  766. "=NORM.DIST(50,40,20,FALSE)": "0.017603266338215",
  767. // NORMDIST
  768. "=NORMDIST(0.8,1,0.3,TRUE)": "0.252492537546923",
  769. "=NORMDIST(50,40,20,FALSE)": "0.017603266338215",
  770. // NORM.INV
  771. "=NORM.INV(0.6,5,2)": "5.506694205719997",
  772. // NORMINV
  773. "=NORMINV(0.6,5,2)": "5.506694205719997",
  774. "=NORMINV(0.99,40,1.5)": "43.489521811582044",
  775. "=NORMINV(0.02,40,1.5)": "36.91937663649545",
  776. // NORM.S.DIST
  777. "=NORM.S.DIST(0.8,TRUE)": "0.788144601416603",
  778. // NORMSDIST
  779. "=NORMSDIST(1.333333)": "0.908788725604095",
  780. "=NORMSDIST(0)": "0.5",
  781. // NORM.S.INV
  782. "=NORM.S.INV(0.25)": "-0.674489750223423",
  783. // NORMSINV
  784. "=NORMSINV(0.25)": "-0.674489750223423",
  785. // LARGE
  786. "=LARGE(A1:A5,1)": "3",
  787. "=LARGE(A1:B5,2)": "4",
  788. "=LARGE(A1,1)": "1",
  789. "=LARGE(A1:F2,1)": "36693",
  790. // MAX
  791. "=MAX(1)": "1",
  792. "=MAX(TRUE())": "1",
  793. "=MAX(0.5,TRUE())": "1",
  794. "=MAX(FALSE())": "0",
  795. "=MAX(MUNIT(2))": "1",
  796. "=MAX(INT(1))": "1",
  797. // MAXA
  798. "=MAXA(1)": "1",
  799. "=MAXA(TRUE())": "1",
  800. "=MAXA(0.5,TRUE())": "1",
  801. "=MAXA(FALSE())": "0",
  802. "=MAXA(MUNIT(2))": "1",
  803. "=MAXA(INT(1))": "1",
  804. "=MAXA(A1:B4,MUNIT(1),INT(0),1,E1:F2,\"\")": "36693",
  805. // MEDIAN
  806. "=MEDIAN(A1:A5,12)": "2",
  807. "=MEDIAN(A1:A5)": "1.5",
  808. "=MEDIAN(A1:A5,MEDIAN(A1:A5,12))": "2",
  809. // MIN
  810. "=MIN(1)": "1",
  811. "=MIN(TRUE())": "1",
  812. "=MIN(0.5,FALSE())": "0",
  813. "=MIN(FALSE())": "0",
  814. "=MIN(MUNIT(2))": "0",
  815. "=MIN(INT(1))": "1",
  816. // MINA
  817. "=MINA(1)": "1",
  818. "=MINA(TRUE())": "1",
  819. "=MINA(0.5,FALSE())": "0",
  820. "=MINA(FALSE())": "0",
  821. "=MINA(MUNIT(2))": "0",
  822. "=MINA(INT(1))": "1",
  823. "=MINA(A1:B4,MUNIT(1),INT(0),1,E1:F2,\"\")": "0",
  824. // PERCENTILE.INC
  825. "=PERCENTILE.INC(A1:A4,0.2)": "0.6",
  826. // PERCENTILE
  827. "=PERCENTILE(A1:A4,0.2)": "0.6",
  828. "=PERCENTILE(0,0)": "0",
  829. // PERMUT
  830. "=PERMUT(6,6)": "720",
  831. "=PERMUT(7,6)": "5040",
  832. "=PERMUT(10,6)": "151200",
  833. // PERMUTATIONA
  834. "=PERMUTATIONA(6,6)": "46656",
  835. "=PERMUTATIONA(7,6)": "117649",
  836. // QUARTILE
  837. "=QUARTILE(A1:A4,2)": "1.5",
  838. // QUARTILE.INC
  839. "=QUARTILE.INC(A1:A4,0)": "0",
  840. // SKEW
  841. "=SKEW(1,2,3,4,3)": "-0.404796008910937",
  842. "=SKEW(A1:B2)": "0",
  843. "=SKEW(A1:D3)": "0",
  844. // SMALL
  845. "=SMALL(A1:A5,1)": "0",
  846. "=SMALL(A1:B5,2)": "1",
  847. "=SMALL(A1,1)": "1",
  848. "=SMALL(A1:F2,1)": "1",
  849. // VARP
  850. "=VARP(A1:A5)": "1.25",
  851. // VAR.P
  852. "=VAR.P(A1:A5)": "1.25",
  853. // Information Functions
  854. // ISBLANK
  855. "=ISBLANK(A1)": "FALSE",
  856. "=ISBLANK(A5)": "TRUE",
  857. // ISERR
  858. "=ISERR(A1)": "FALSE",
  859. "=ISERR(NA())": "FALSE",
  860. "=ISERR(POWER(0,-1)))": "TRUE",
  861. // ISERROR
  862. "=ISERROR(A1)": "FALSE",
  863. "=ISERROR(NA())": "TRUE",
  864. // ISEVEN
  865. "=ISEVEN(A1)": "FALSE",
  866. "=ISEVEN(A2)": "TRUE",
  867. // ISNA
  868. "=ISNA(A1)": "FALSE",
  869. "=ISNA(NA())": "TRUE",
  870. // ISNONTEXT
  871. "=ISNONTEXT(A1)": "FALSE",
  872. "=ISNONTEXT(A5)": "TRUE",
  873. `=ISNONTEXT("Excelize")`: "FALSE",
  874. "=ISNONTEXT(NA())": "TRUE",
  875. // ISNUMBER
  876. "=ISNUMBER(A1)": "TRUE",
  877. "=ISNUMBER(D1)": "FALSE",
  878. // ISODD
  879. "=ISODD(A1)": "TRUE",
  880. "=ISODD(A2)": "FALSE",
  881. // ISTEXT
  882. "=ISTEXT(D1)": "TRUE",
  883. "=ISTEXT(A1)": "FALSE",
  884. // N
  885. "=N(10)": "10",
  886. "=N(\"10\")": "10",
  887. "=N(\"x\")": "0",
  888. "=N(TRUE)": "1",
  889. "=N(FALSE)": "0",
  890. // SHEET
  891. "=SHEET()": "1",
  892. // T
  893. "=T(\"text\")": "text",
  894. "=T(N(10))": "",
  895. // Logical Functions
  896. // AND
  897. "=AND(0)": "FALSE",
  898. "=AND(1)": "TRUE",
  899. "=AND(1,0)": "FALSE",
  900. "=AND(0,1)": "FALSE",
  901. "=AND(1=1)": "TRUE",
  902. "=AND(1<2)": "TRUE",
  903. "=AND(1>2,2<3,2>0,3>1)": "FALSE",
  904. "=AND(1=1),1=1": "TRUE",
  905. // FALSE
  906. "=FALSE()": "FALSE",
  907. // IFERROR
  908. "=IFERROR(1/2,0)": "0.5",
  909. "=IFERROR(ISERROR(),0)": "0",
  910. "=IFERROR(1/0,0)": "0",
  911. // NOT
  912. "=NOT(FALSE())": "TRUE",
  913. "=NOT(\"false\")": "TRUE",
  914. "=NOT(\"true\")": "FALSE",
  915. "=NOT(ISBLANK(B1))": "TRUE",
  916. // OR
  917. "=OR(1)": "TRUE",
  918. "=OR(0)": "FALSE",
  919. "=OR(1=2,2=2)": "TRUE",
  920. "=OR(1=2,2=3)": "FALSE",
  921. // TRUE
  922. "=TRUE()": "TRUE",
  923. // Date and Time Functions
  924. // DATE
  925. "=DATE(2020,10,21)": "2020-10-21 00:00:00 +0000 UTC",
  926. "=DATE(1900,1,1)": "1899-12-31 00:00:00 +0000 UTC",
  927. // DATEDIF
  928. "=DATEDIF(43101,43101,\"D\")": "0",
  929. "=DATEDIF(43101,43891,\"d\")": "790",
  930. "=DATEDIF(43101,43891,\"Y\")": "2",
  931. "=DATEDIF(42156,44242,\"y\")": "5",
  932. "=DATEDIF(43101,43891,\"M\")": "26",
  933. "=DATEDIF(42171,44242,\"m\")": "67",
  934. "=DATEDIF(42156,44454,\"MD\")": "14",
  935. "=DATEDIF(42171,44242,\"md\")": "30",
  936. "=DATEDIF(43101,43891,\"YM\")": "2",
  937. "=DATEDIF(42171,44242,\"ym\")": "7",
  938. "=DATEDIF(43101,43891,\"YD\")": "59",
  939. "=DATEDIF(36526,73110,\"YD\")": "60",
  940. "=DATEDIF(42171,44242,\"yd\")": "244",
  941. // Text Functions
  942. // CHAR
  943. "=CHAR(65)": "A",
  944. "=CHAR(97)": "a",
  945. "=CHAR(63)": "?",
  946. "=CHAR(51)": "3",
  947. // CLEAN
  948. "=CLEAN(\"\u0009clean text\")": "clean text",
  949. "=CLEAN(0)": "0",
  950. // CODE
  951. "=CODE(\"Alpha\")": "65",
  952. "=CODE(\"alpha\")": "97",
  953. "=CODE(\"?\")": "63",
  954. "=CODE(\"3\")": "51",
  955. "=CODE(\"\")": "0",
  956. // CONCAT
  957. "=CONCAT(TRUE(),1,FALSE(),\"0\",INT(2))": "TRUE1FALSE02",
  958. // CONCATENATE
  959. "=CONCATENATE(TRUE(),1,FALSE(),\"0\",INT(2))": "TRUE1FALSE02",
  960. // EXACT
  961. "=EXACT(1,\"1\")": "TRUE",
  962. "=EXACT(1,1)": "TRUE",
  963. "=EXACT(\"A\",\"a\")": "FALSE",
  964. // FIXED
  965. "=FIXED(5123.591)": "5,123.591",
  966. "=FIXED(5123.591,1)": "5,123.6",
  967. "=FIXED(5123.591,0)": "5,124",
  968. "=FIXED(5123.591,-1)": "5,120",
  969. "=FIXED(5123.591,-2)": "5,100",
  970. "=FIXED(5123.591,-3,TRUE)": "5000",
  971. "=FIXED(5123.591,-5)": "0",
  972. "=FIXED(-77262.23973,-5)": "-100,000",
  973. // FIND
  974. "=FIND(\"T\",\"Original Text\")": "10",
  975. "=FIND(\"t\",\"Original Text\")": "13",
  976. "=FIND(\"i\",\"Original Text\")": "3",
  977. "=FIND(\"i\",\"Original Text\",4)": "5",
  978. "=FIND(\"\",\"Original Text\")": "1",
  979. "=FIND(\"\",\"Original Text\",2)": "2",
  980. // FINDB
  981. "=FINDB(\"T\",\"Original Text\")": "10",
  982. "=FINDB(\"t\",\"Original Text\")": "13",
  983. "=FINDB(\"i\",\"Original Text\")": "3",
  984. "=FINDB(\"i\",\"Original Text\",4)": "5",
  985. "=FINDB(\"\",\"Original Text\")": "1",
  986. "=FINDB(\"\",\"Original Text\",2)": "2",
  987. // LEFT
  988. "=LEFT(\"Original Text\")": "O",
  989. "=LEFT(\"Original Text\",4)": "Orig",
  990. "=LEFT(\"Original Text\",0)": "",
  991. "=LEFT(\"Original Text\",13)": "Original Text",
  992. "=LEFT(\"Original Text\",20)": "Original Text",
  993. // LEFTB
  994. "=LEFTB(\"Original Text\")": "O",
  995. "=LEFTB(\"Original Text\",4)": "Orig",
  996. "=LEFTB(\"Original Text\",0)": "",
  997. "=LEFTB(\"Original Text\",13)": "Original Text",
  998. "=LEFTB(\"Original Text\",20)": "Original Text",
  999. // LEN
  1000. "=LEN(\"\")": "0",
  1001. "=LEN(D1)": "5",
  1002. // LENB
  1003. "=LENB(\"\")": "0",
  1004. "=LENB(D1)": "5",
  1005. // LOWER
  1006. "=LOWER(\"test\")": "test",
  1007. "=LOWER(\"TEST\")": "test",
  1008. "=LOWER(\"Test\")": "test",
  1009. "=LOWER(\"TEST 123\")": "test 123",
  1010. // MID
  1011. "=MID(\"Original Text\",7,1)": "a",
  1012. "=MID(\"Original Text\",4,7)": "ginal T",
  1013. "=MID(\"255 years\",3,1)": "5",
  1014. "=MID(\"text\",3,6)": "xt",
  1015. "=MID(\"text\",6,0)": "",
  1016. // MIDB
  1017. "=MIDB(\"Original Text\",7,1)": "a",
  1018. "=MIDB(\"Original Text\",4,7)": "ginal T",
  1019. "=MIDB(\"255 years\",3,1)": "5",
  1020. "=MIDB(\"text\",3,6)": "xt",
  1021. "=MIDB(\"text\",6,0)": "",
  1022. // PROPER
  1023. "=PROPER(\"this is a test sentence\")": "This Is A Test Sentence",
  1024. "=PROPER(\"THIS IS A TEST SENTENCE\")": "This Is A Test Sentence",
  1025. "=PROPER(\"123tEST teXT\")": "123Test Text",
  1026. "=PROPER(\"Mr. SMITH's address\")": "Mr. Smith'S Address",
  1027. // REPLACE
  1028. "=REPLACE(\"test string\",7,3,\"X\")": "test sXng",
  1029. "=REPLACE(\"second test string\",8,4,\"XXX\")": "second XXX string",
  1030. "=REPLACE(\"text\",5,0,\" and char\")": "text and char",
  1031. "=REPLACE(\"text\",1,20,\"char and \")": "char and ",
  1032. // REPLACEB
  1033. "=REPLACEB(\"test string\",7,3,\"X\")": "test sXng",
  1034. "=REPLACEB(\"second test string\",8,4,\"XXX\")": "second XXX string",
  1035. "=REPLACEB(\"text\",5,0,\" and char\")": "text and char",
  1036. "=REPLACEB(\"text\",1,20,\"char and \")": "char and ",
  1037. // REPT
  1038. "=REPT(\"*\",0)": "",
  1039. "=REPT(\"*\",1)": "*",
  1040. "=REPT(\"**\",2)": "****",
  1041. // RIGHT
  1042. "=RIGHT(\"Original Text\")": "t",
  1043. "=RIGHT(\"Original Text\",4)": "Text",
  1044. "=RIGHT(\"Original Text\",0)": "",
  1045. "=RIGHT(\"Original Text\",13)": "Original Text",
  1046. "=RIGHT(\"Original Text\",20)": "Original Text",
  1047. // RIGHTB
  1048. "=RIGHTB(\"Original Text\")": "t",
  1049. "=RIGHTB(\"Original Text\",4)": "Text",
  1050. "=RIGHTB(\"Original Text\",0)": "",
  1051. "=RIGHTB(\"Original Text\",13)": "Original Text",
  1052. "=RIGHTB(\"Original Text\",20)": "Original Text",
  1053. // SUBSTITUTE
  1054. "=SUBSTITUTE(\"abab\",\"a\",\"X\")": "XbXb",
  1055. "=SUBSTITUTE(\"abab\",\"a\",\"X\",2)": "abXb",
  1056. "=SUBSTITUTE(\"abab\",\"x\",\"X\",2)": "abab",
  1057. "=SUBSTITUTE(\"John is 5 years old\",\"John\",\"Jack\")": "Jack is 5 years old",
  1058. "=SUBSTITUTE(\"John is 5 years old\",\"5\",\"6\")": "John is 6 years old",
  1059. // TRIM
  1060. "=TRIM(\" trim text \")": "trim text",
  1061. "=TRIM(0)": "0",
  1062. // UNICHAR
  1063. "=UNICHAR(65)": "A",
  1064. "=UNICHAR(97)": "a",
  1065. "=UNICHAR(63)": "?",
  1066. "=UNICHAR(51)": "3",
  1067. // UNICODE
  1068. "=UNICODE(\"Alpha\")": "65",
  1069. "=UNICODE(\"alpha\")": "97",
  1070. "=UNICODE(\"?\")": "63",
  1071. "=UNICODE(\"3\")": "51",
  1072. // UPPER
  1073. "=UPPER(\"test\")": "TEST",
  1074. "=UPPER(\"TEST\")": "TEST",
  1075. "=UPPER(\"Test\")": "TEST",
  1076. "=UPPER(\"TEST 123\")": "TEST 123",
  1077. // Conditional Functions
  1078. // IF
  1079. "=IF(1=1)": "TRUE",
  1080. "=IF(1<>1)": "FALSE",
  1081. "=IF(5<0, \"negative\", \"positive\")": "positive",
  1082. "=IF(-2<0, \"negative\", \"positive\")": "negative",
  1083. // Excel Lookup and Reference Functions
  1084. // CHOOSE
  1085. "=CHOOSE(4,\"red\",\"blue\",\"green\",\"brown\")": "brown",
  1086. "=CHOOSE(1,\"red\",\"blue\",\"green\",\"brown\")": "red",
  1087. "=SUM(CHOOSE(A2,A1,B1:B2,A1:A3,A1:A4))": "9",
  1088. // COLUMN
  1089. "=COLUMN()": "3",
  1090. "=COLUMN(Sheet1!A1)": "1",
  1091. "=COLUMN(Sheet1!A1:B1:C1)": "1",
  1092. "=COLUMN(Sheet1!F1:G1)": "6",
  1093. "=COLUMN(H1)": "8",
  1094. // COLUMNS
  1095. "=COLUMNS(B1)": "1",
  1096. "=COLUMNS(1:1)": "16384",
  1097. "=COLUMNS(Sheet1!1:1)": "16384",
  1098. "=COLUMNS(B1:E5)": "4",
  1099. "=COLUMNS(Sheet1!E5:H7:B1)": "7",
  1100. "=COLUMNS(E5:H7:B1:C1:Z1:C1:B1)": "25",
  1101. "=COLUMNS(E5:B1)": "4",
  1102. "=COLUMNS(EM38:HZ81)": "92",
  1103. // HLOOKUP
  1104. "=HLOOKUP(D2,D2:D8,1,FALSE)": "Jan",
  1105. "=HLOOKUP(F3,F3:F8,3,FALSE)": "34440",
  1106. "=HLOOKUP(INT(F3),F3:F8,3,FALSE)": "34440",
  1107. "=HLOOKUP(MUNIT(1),MUNIT(1),1,FALSE)": "1",
  1108. // VLOOKUP
  1109. "=VLOOKUP(D2,D:D,1,FALSE)": "Jan",
  1110. "=VLOOKUP(D2,D1:D10,1)": "Jan",
  1111. "=VLOOKUP(D2,D1:D11,1)": "Feb",
  1112. "=VLOOKUP(D2,D1:D10,1,FALSE)": "Jan",
  1113. "=VLOOKUP(INT(36693),F2:F2,1,FALSE)": "36693",
  1114. "=VLOOKUP(INT(F2),F3:F9,1)": "32080",
  1115. "=VLOOKUP(INT(F2),F3:F9,1,TRUE)": "32080",
  1116. "=VLOOKUP(MUNIT(3),MUNIT(3),1)": "0",
  1117. "=VLOOKUP(A1,A3:B5,1)": "0",
  1118. "=VLOOKUP(MUNIT(1),MUNIT(1),1,FALSE)": "1",
  1119. // LOOKUP
  1120. "=LOOKUP(F8,F8:F9,F8:F9)": "32080",
  1121. "=LOOKUP(F8,F8:F9,D8:D9)": "Feb",
  1122. "=LOOKUP(1,MUNIT(1),MUNIT(1))": "1",
  1123. // ROW
  1124. "=ROW()": "1",
  1125. "=ROW(Sheet1!A1)": "1",
  1126. "=ROW(Sheet1!A1:B2:C3)": "1",
  1127. "=ROW(Sheet1!F5:G6)": "5",
  1128. "=ROW(A8)": "8",
  1129. // ROWS
  1130. "=ROWS(B1)": "1",
  1131. "=ROWS(B:B)": "1048576",
  1132. "=ROWS(Sheet1!B:B)": "1048576",
  1133. "=ROWS(B1:E5)": "5",
  1134. "=ROWS(Sheet1!E5:H7:B1)": "7",
  1135. "=ROWS(E5:H8:B2:C3:Z26:C3:B2)": "25",
  1136. "=ROWS(E5:B1)": "5",
  1137. "=ROWS(EM38:HZ81)": "44",
  1138. // Web Functions
  1139. // ENCODEURL
  1140. "=ENCODEURL(\"https://xuri.me/excelize/en/?q=Save As\")": "https%3A%2F%2Fxuri.me%2Fexcelize%2Fen%2F%3Fq%3DSave%20As",
  1141. // Financial Functions
  1142. // CUMIPMT
  1143. "=CUMIPMT(0.05/12,60,50000,1,12,0)": "-2294.97753732664",
  1144. "=CUMIPMT(0.05/12,60,50000,13,24,0)": "-1833.1000665738893",
  1145. // CUMPRINC
  1146. "=CUMPRINC(0.05/12,60,50000,1,12,0)": "-9027.762649079885",
  1147. "=CUMPRINC(0.05/12,60,50000,13,24,0)": "-9489.640119832635",
  1148. // DB
  1149. "=DB(0,1000,5,1)": "0",
  1150. "=DB(10000,1000,5,1)": "3690",
  1151. "=DB(10000,1000,5,2)": "2328.39",
  1152. "=DB(10000,1000,5,1,6)": "1845",
  1153. "=DB(10000,1000,5,6,6)": "238.52712458788187",
  1154. // DDB
  1155. "=DDB(0,1000,5,1)": "0",
  1156. "=DDB(10000,1000,5,1)": "4000",
  1157. "=DDB(10000,1000,5,2)": "2400",
  1158. "=DDB(10000,1000,5,3)": "1440",
  1159. "=DDB(10000,1000,5,4)": "864",
  1160. "=DDB(10000,1000,5,5)": "296",
  1161. // DOLLARDE
  1162. "=DOLLARDE(1.01,16)": "1.0625",
  1163. // DOLLARFR
  1164. "=DOLLARFR(1.0625,16)": "1.01",
  1165. // EFFECT
  1166. "=EFFECT(0.1,4)": "0.103812890625",
  1167. "=EFFECT(0.025,2)": "0.02515625",
  1168. // FV
  1169. "=FV(0.05/12,60,-1000)": "68006.08284084337",
  1170. "=FV(0.1/4,16,-2000,0,1)": "39729.46089416617",
  1171. "=FV(0,16,-2000)": "32000",
  1172. // FVSCHEDULE
  1173. "=FVSCHEDULE(10000,A1:A5)": "240000",
  1174. "=FVSCHEDULE(10000,0.5)": "15000",
  1175. // IPMT
  1176. "=IPMT(0.05/12,2,60,50000)": "-205.26988187971995",
  1177. "=IPMT(0.035/4,2,8,0,5000,1)": "5.257455237829077",
  1178. // ISPMT
  1179. "=ISPMT(0.05/12,1,60,50000)": "-204.8611111111111",
  1180. "=ISPMT(0.05/12,2,60,50000)": "-201.38888888888886",
  1181. "=ISPMT(0.05/12,2,1,50000)": "208.33333333333334",
  1182. // NOMINAL
  1183. "=NOMINAL(0.025,12)": "0.024718035238113",
  1184. // NPER
  1185. "=NPER(0.04,-6000,50000)": "10.338035071507665",
  1186. "=NPER(0,-6000,50000)": "8.333333333333334",
  1187. "=NPER(0.06/4,-2000,60000,30000,1)": "52.794773709274764",
  1188. // NPV
  1189. "=NPV(0.02,-5000,\"\",800)": "-4133.025759323337",
  1190. // PDURATION
  1191. "=PDURATION(0.04,10000,15000)": "10.33803507150765",
  1192. // PMT
  1193. "=PMT(0,8,0,5000,1)": "-625",
  1194. "=PMT(0.035/4,8,0,5000,1)": "-600.8520271804658",
  1195. // PPMT
  1196. "=PPMT(0.05/12,2,60,50000)": "-738.2918003208238",
  1197. "=PPMT(0.035/4,2,8,0,5000,1)": "-606.1094824182949",
  1198. }
  1199. for formula, expected := range mathCalc {
  1200. f := prepareCalcData(cellData)
  1201. assert.NoError(t, f.SetCellFormula("Sheet1", "C1", formula))
  1202. result, err := f.CalcCellValue("Sheet1", "C1")
  1203. assert.NoError(t, err, formula)
  1204. assert.Equal(t, expected, result, formula)
  1205. }
  1206. mathCalcError := map[string]string{
  1207. "=1/0": "#DIV/0!",
  1208. // Engineering Functions
  1209. // BESSELI
  1210. "=BESSELI()": "BESSELI requires 2 numeric arguments",
  1211. "=BESSELI(\"\",0)": "strconv.ParseFloat: parsing \"\": invalid syntax",
  1212. "=BESSELI(0,\"\")": "strconv.ParseFloat: parsing \"\": invalid syntax",
  1213. // BESSELJ
  1214. "=BESSELJ()": "BESSELJ requires 2 numeric arguments",
  1215. "=BESSELJ(\"\",0)": "strconv.ParseFloat: parsing \"\": invalid syntax",
  1216. "=BESSELJ(0,\"\")": "strconv.ParseFloat: parsing \"\": invalid syntax",
  1217. // BESSELK
  1218. "=BESSELK()": "BESSELK requires 2 numeric arguments",
  1219. "=BESSELK(\"\",0)": "strconv.ParseFloat: parsing \"\": invalid syntax",
  1220. "=BESSELK(0,\"\")": "strconv.ParseFloat: parsing \"\": invalid syntax",
  1221. "=BESSELK(-1,0)": "#NUM!",
  1222. "=BESSELK(1,-1)": "#NUM!",
  1223. // BESSELY
  1224. "=BESSELY()": "BESSELY requires 2 numeric arguments",
  1225. "=BESSELY(\"\",0)": "strconv.ParseFloat: parsing \"\": invalid syntax",
  1226. "=BESSELY(0,\"\")": "strconv.ParseFloat: parsing \"\": invalid syntax",
  1227. "=BESSELY(-1,0)": "#NUM!",
  1228. "=BESSELY(1,-1)": "#NUM!",
  1229. // BIN2DEC
  1230. "=BIN2DEC()": "BIN2DEC requires 1 numeric argument",
  1231. "=BIN2DEC(\"\")": "strconv.ParseFloat: parsing \"\": invalid syntax",
  1232. // BIN2HEX
  1233. "=BIN2HEX()": "BIN2HEX requires at least 1 argument",
  1234. "=BIN2HEX(1,1,1)": "BIN2HEX allows at most 2 arguments",
  1235. "=BIN2HEX(\"\",1)": "strconv.ParseFloat: parsing \"\": invalid syntax",
  1236. "=BIN2HEX(1,\"\")": "strconv.ParseFloat: parsing \"\": invalid syntax",
  1237. "=BIN2HEX(12345678901,10)": "#NUM!",
  1238. "=BIN2HEX(1,-1)": "#NUM!",
  1239. "=BIN2HEX(31,1)": "#NUM!",
  1240. // BIN2OCT
  1241. "=BIN2OCT()": "BIN2OCT requires at least 1 argument",
  1242. "=BIN2OCT(1,1,1)": "BIN2OCT allows at most 2 arguments",
  1243. "=BIN2OCT(\"\",1)": "strconv.ParseFloat: parsing \"\": invalid syntax",
  1244. "=BIN2OCT(1,\"\")": "strconv.ParseFloat: parsing \"\": invalid syntax",
  1245. "=BIN2OCT(-12345678901 ,10)": "#NUM!",
  1246. "=BIN2OCT(1,-1)": "#NUM!",
  1247. "=BIN2OCT(8,1)": "#NUM!",
  1248. // BITAND
  1249. "=BITAND()": "BITAND requires 2 numeric arguments",
  1250. "=BITAND(-1,2)": "#NUM!",
  1251. "=BITAND(2^48,2)": "#NUM!",
  1252. "=BITAND(1,-1)": "#NUM!",
  1253. "=BITAND(\"\",-1)": "#NUM!",
  1254. "=BITAND(1,\"\")": "#NUM!",
  1255. "=BITAND(1,2^48)": "#NUM!",
  1256. // BITLSHIFT
  1257. "=BITLSHIFT()": "BITLSHIFT requires 2 numeric arguments",
  1258. "=BITLSHIFT(-1,2)": "#NUM!",
  1259. "=BITLSHIFT(2^48,2)": "#NUM!",
  1260. "=BITLSHIFT(1,-1)": "#NUM!",
  1261. "=BITLSHIFT(\"\",-1)": "#NUM!",
  1262. "=BITLSHIFT(1,\"\")": "#NUM!",
  1263. "=BITLSHIFT(1,2^48)": "#NUM!",
  1264. // BITOR
  1265. "=BITOR()": "BITOR requires 2 numeric arguments",
  1266. "=BITOR(-1,2)": "#NUM!",
  1267. "=BITOR(2^48,2)": "#NUM!",
  1268. "=BITOR(1,-1)": "#NUM!",
  1269. "=BITOR(\"\",-1)": "#NUM!",
  1270. "=BITOR(1,\"\")": "#NUM!",
  1271. "=BITOR(1,2^48)": "#NUM!",
  1272. // BITRSHIFT
  1273. "=BITRSHIFT()": "BITRSHIFT requires 2 numeric arguments",
  1274. "=BITRSHIFT(-1,2)": "#NUM!",
  1275. "=BITRSHIFT(2^48,2)": "#NUM!",
  1276. "=BITRSHIFT(1,-1)": "#NUM!",
  1277. "=BITRSHIFT(\"\",-1)": "#NUM!",
  1278. "=BITRSHIFT(1,\"\")": "#NUM!",
  1279. "=BITRSHIFT(1,2^48)": "#NUM!",
  1280. // BITXOR
  1281. "=BITXOR()": "BITXOR requires 2 numeric arguments",
  1282. "=BITXOR(-1,2)": "#NUM!",
  1283. "=BITXOR(2^48,2)": "#NUM!",
  1284. "=BITXOR(1,-1)": "#NUM!",
  1285. "=BITXOR(\"\",-1)": "#NUM!",
  1286. "=BITXOR(1,\"\")": "#NUM!",
  1287. "=BITXOR(1,2^48)": "#NUM!",
  1288. // COMPLEX
  1289. "=COMPLEX()": "COMPLEX requires at least 2 arguments",
  1290. "=COMPLEX(10,-5,\"\")": "#VALUE!",
  1291. "=COMPLEX(\"\",0)": "strconv.ParseFloat: parsing \"\": invalid syntax",
  1292. "=COMPLEX(0,\"\")": "strconv.ParseFloat: parsing \"\": invalid syntax",
  1293. "=COMPLEX(10,-5,\"i\",0)": "COMPLEX allows at most 3 arguments",
  1294. // DEC2BIN
  1295. "=DEC2BIN()": "DEC2BIN requires at least 1 argument",
  1296. "=DEC2BIN(1,1,1)": "DEC2BIN allows at most 2 arguments",
  1297. "=DEC2BIN(\"\",1)": "strconv.ParseFloat: parsing \"\": invalid syntax",
  1298. "=DEC2BIN(1,\"\")": "strconv.ParseFloat: parsing \"\": invalid syntax",
  1299. "=DEC2BIN(-513,10)": "#NUM!",
  1300. "=DEC2BIN(1,-1)": "#NUM!",
  1301. "=DEC2BIN(2,1)": "#NUM!",
  1302. // DEC2HEX
  1303. "=DEC2HEX()": "DEC2HEX requires at least 1 argument",
  1304. "=DEC2HEX(1,1,1)": "DEC2HEX allows at most 2 arguments",
  1305. "=DEC2HEX(\"\",1)": "strconv.ParseFloat: parsing \"\": invalid syntax",
  1306. "=DEC2HEX(1,\"\")": "strconv.ParseFloat: parsing \"\": invalid syntax",
  1307. "=DEC2HEX(-549755813888,10)": "#NUM!",
  1308. "=DEC2HEX(1,-1)": "#NUM!",
  1309. "=DEC2HEX(31,1)": "#NUM!",
  1310. // DEC2OCT
  1311. "=DEC2OCT()": "DEC2OCT requires at least 1 argument",
  1312. "=DEC2OCT(1,1,1)": "DEC2OCT allows at most 2 arguments",
  1313. "=DEC2OCT(\"\",1)": "strconv.ParseFloat: parsing \"\": invalid syntax",
  1314. "=DEC2OCT(1,\"\")": "strconv.ParseFloat: parsing \"\": invalid syntax",
  1315. "=DEC2OCT(-536870912 ,10)": "#NUM!",
  1316. "=DEC2OCT(1,-1)": "#NUM!",
  1317. "=DEC2OCT(8,1)": "#NUM!",
  1318. // HEX2BIN
  1319. "=HEX2BIN()": "HEX2BIN requires at least 1 argument",
  1320. "=HEX2BIN(1,1,1)": "HEX2BIN allows at most 2 arguments",
  1321. "=HEX2BIN(\"X\",1)": "strconv.ParseInt: parsing \"X\": invalid syntax",
  1322. "=HEX2BIN(1,\"\")": "strconv.ParseFloat: parsing \"\": invalid syntax",
  1323. "=HEX2BIN(-513,10)": "strconv.ParseInt: parsing \"-\": invalid syntax",
  1324. "=HEX2BIN(1,-1)": "#NUM!",
  1325. "=HEX2BIN(2,1)": "#NUM!",
  1326. // HEX2DEC
  1327. "=HEX2DEC()": "HEX2DEC requires 1 numeric argument",
  1328. "=HEX2DEC(\"X\")": "strconv.ParseInt: parsing \"X\": invalid syntax",
  1329. // HEX2OCT
  1330. "=HEX2OCT()": "HEX2OCT requires at least 1 argument",
  1331. "=HEX2OCT(1,1,1)": "HEX2OCT allows at most 2 arguments",
  1332. "=HEX2OCT(\"X\",1)": "strconv.ParseInt: parsing \"X\": invalid syntax",
  1333. "=HEX2OCT(1,\"\")": "strconv.ParseFloat: parsing \"\": invalid syntax",
  1334. "=HEX2OCT(-513,10)": "strconv.ParseInt: parsing \"-\": invalid syntax",
  1335. "=HEX2OCT(1,-1)": "#NUM!",
  1336. // IMABS
  1337. "=IMABS()": "IMABS requires 1 argument",
  1338. "=IMABS(\"\")": "strconv.ParseComplex: parsing \"\": invalid syntax",
  1339. // IMAGINARY
  1340. "=IMAGINARY()": "IMAGINARY requires 1 argument",
  1341. "=IMAGINARY(\"\")": "strconv.ParseComplex: parsing \"\": invalid syntax",
  1342. // IMARGUMENT
  1343. "=IMARGUMENT()": "IMARGUMENT requires 1 argument",
  1344. "=IMARGUMENT(\"\")": "strconv.ParseComplex: parsing \"\": invalid syntax",
  1345. // IMCONJUGATE
  1346. "=IMCONJUGATE()": "IMCONJUGATE requires 1 argument",
  1347. "=IMCONJUGATE(\"\")": "strconv.ParseComplex: parsing \"\": invalid syntax",
  1348. // IMCOS
  1349. "=IMCOS()": "IMCOS requires 1 argument",
  1350. "=IMCOS(\"\")": "strconv.ParseComplex: parsing \"\": invalid syntax",
  1351. // IMCOSH
  1352. "=IMCOSH()": "IMCOSH requires 1 argument",
  1353. "=IMCOSH(\"\")": "strconv.ParseComplex: parsing \"\": invalid syntax",
  1354. // IMCOT
  1355. "=IMCOT()": "IMCOT requires 1 argument",
  1356. "=IMCOT(\"\")": "strconv.ParseComplex: parsing \"\": invalid syntax",
  1357. // IMCSC
  1358. "=IMCSC()": "IMCSC requires 1 argument",
  1359. "=IMCSC(\"\")": "strconv.ParseComplex: parsing \"\": invalid syntax",
  1360. "=IMCSC(0)": "#NUM!",
  1361. // IMCSCH
  1362. "=IMCSCH()": "IMCSCH requires 1 argument",
  1363. "=IMCSCH(\"\")": "strconv.ParseComplex: parsing \"\": invalid syntax",
  1364. "=IMCSCH(0)": "#NUM!",
  1365. // IMDIV
  1366. "=IMDIV()": "IMDIV requires 2 arguments",
  1367. "=IMDIV(0,\"\")": "strconv.ParseComplex: parsing \"\": invalid syntax",
  1368. "=IMDIV(\"\",0)": "strconv.ParseComplex: parsing \"\": invalid syntax",
  1369. "=IMDIV(1,0)": "#NUM!",
  1370. // IMEXP
  1371. "=IMEXP()": "IMEXP requires 1 argument",
  1372. "=IMEXP(\"\")": "strconv.ParseComplex: parsing \"\": invalid syntax",
  1373. // IMLN
  1374. "=IMLN()": "IMLN requires 1 argument",
  1375. "=IMLN(\"\")": "strconv.ParseComplex: parsing \"\": invalid syntax",
  1376. "=IMLN(0)": "#NUM!",
  1377. // IMLOG10
  1378. "=IMLOG10()": "IMLOG10 requires 1 argument",
  1379. "=IMLOG10(\"\")": "strconv.ParseComplex: parsing \"\": invalid syntax",
  1380. "=IMLOG10(0)": "#NUM!",
  1381. // IMLOG2
  1382. "=IMLOG2()": "IMLOG2 requires 1 argument",
  1383. "=IMLOG2(\"\")": "strconv.ParseComplex: parsing \"\": invalid syntax",
  1384. "=IMLOG2(0)": "#NUM!",
  1385. // IMPOWER
  1386. "=IMPOWER()": "IMPOWER requires 2 arguments",
  1387. "=IMPOWER(0,\"\")": "strconv.ParseComplex: parsing \"\": invalid syntax",
  1388. "=IMPOWER(\"\",0)": "strconv.ParseComplex: parsing \"\": invalid syntax",
  1389. "=IMPOWER(0,0)": "#NUM!",
  1390. "=IMPOWER(0,-1)": "#NUM!",
  1391. // IMPRODUCT
  1392. "=IMPRODUCT(\"x\")": "strconv.ParseComplex: parsing \"x\": invalid syntax",
  1393. "=IMPRODUCT(A1:D1)": "strconv.ParseComplex: parsing \"Month\": invalid syntax",
  1394. // IMREAL
  1395. "=IMREAL()": "IMREAL requires 1 argument",
  1396. "=IMREAL(\"\")": "strconv.ParseComplex: parsing \"\": invalid syntax",
  1397. // IMSEC
  1398. "=IMSEC()": "IMSEC requires 1 argument",
  1399. "=IMSEC(\"\")": "strconv.ParseComplex: parsing \"\": invalid syntax",
  1400. // IMSECH
  1401. "=IMSECH()": "IMSECH requires 1 argument",
  1402. "=IMSECH(\"\")": "strconv.ParseComplex: parsing \"\": invalid syntax",
  1403. // IMSIN
  1404. "=IMSIN()": "IMSIN requires 1 argument",
  1405. "=IMSIN(\"\")": "strconv.ParseComplex: parsing \"\": invalid syntax",
  1406. // IMSINH
  1407. "=IMSINH()": "IMSINH requires 1 argument",
  1408. "=IMSINH(\"\")": "strconv.ParseComplex: parsing \"\": invalid syntax",
  1409. // IMSQRT
  1410. "=IMSQRT()": "IMSQRT requires 1 argument",
  1411. "=IMSQRT(\"\")": "strconv.ParseComplex: parsing \"\": invalid syntax",
  1412. // IMSUB
  1413. "=IMSUB()": "IMSUB requires 2 arguments",
  1414. "=IMSUB(0,\"\")": "strconv.ParseComplex: parsing \"\": invalid syntax",
  1415. "=IMSUB(\"\",0)": "strconv.ParseComplex: parsing \"\": invalid syntax",
  1416. // IMSUM
  1417. "=IMSUM()": "IMSUM requires at least 1 argument",
  1418. "=IMSUM(\"\")": "strconv.ParseComplex: parsing \"\": invalid syntax",
  1419. // IMTAN
  1420. "=IMTAN()": "IMTAN requires 1 argument",
  1421. "=IMTAN(\"\")": "strconv.ParseComplex: parsing \"\": invalid syntax",
  1422. // OCT2BIN
  1423. "=OCT2BIN()": "OCT2BIN requires at least 1 argument",
  1424. "=OCT2BIN(1,1,1)": "OCT2BIN allows at most 2 arguments",
  1425. "=OCT2BIN(\"\",1)": "strconv.ParseFloat: parsing \"\": invalid syntax",
  1426. "=OCT2BIN(1,\"\")": "strconv.ParseFloat: parsing \"\": invalid syntax",
  1427. "=OCT2BIN(-536870912 ,10)": "#NUM!",
  1428. "=OCT2BIN(1,-1)": "#NUM!",
  1429. // OCT2DEC
  1430. "=OCT2DEC()": "OCT2DEC requires 1 numeric argument",
  1431. "=OCT2DEC(\"\")": "strconv.ParseFloat: parsing \"\": invalid syntax",
  1432. // OCT2HEX
  1433. "=OCT2HEX()": "OCT2HEX requires at least 1 argument",
  1434. "=OCT2HEX(1,1,1)": "OCT2HEX allows at most 2 arguments",
  1435. "=OCT2HEX(\"\",1)": "strconv.ParseFloat: parsing \"\": invalid syntax",
  1436. "=OCT2HEX(1,\"\")": "strconv.ParseFloat: parsing \"\": invalid syntax",
  1437. "=OCT2HEX(-536870912 ,10)": "#NUM!",
  1438. "=OCT2HEX(1,-1)": "#NUM!",
  1439. // Math and Trigonometric Functions
  1440. // ABS
  1441. "=ABS()": "ABS requires 1 numeric argument",
  1442. `=ABS("X")`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1443. "=ABS(~)": `invalid column name "~"`,
  1444. // ACOS
  1445. "=ACOS()": "ACOS requires 1 numeric argument",
  1446. `=ACOS("X")`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1447. "=ACOS(ACOS(0))": "#NUM!",
  1448. // ACOSH
  1449. "=ACOSH()": "ACOSH requires 1 numeric argument",
  1450. `=ACOSH("X")`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1451. // _xlfn.ACOT
  1452. "=_xlfn.ACOT()": "ACOT requires 1 numeric argument",
  1453. `=_xlfn.ACOT("X")`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1454. // _xlfn.ACOTH
  1455. "=_xlfn.ACOTH()": "ACOTH requires 1 numeric argument",
  1456. `=_xlfn.ACOTH("X")`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1457. "=_xlfn.ACOTH(_xlfn.ACOTH(2))": "#NUM!",
  1458. // _xlfn.ARABIC
  1459. "=_xlfn.ARABIC()": "ARABIC requires 1 numeric argument",
  1460. "=_xlfn.ARABIC(\"" + strings.Repeat("I", 256) + "\")": "#VALUE!",
  1461. // ASIN
  1462. "=ASIN()": "ASIN requires 1 numeric argument",
  1463. `=ASIN("X")`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1464. // ASINH
  1465. "=ASINH()": "ASINH requires 1 numeric argument",
  1466. `=ASINH("X")`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1467. // ATAN
  1468. "=ATAN()": "ATAN requires 1 numeric argument",
  1469. `=ATAN("X")`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1470. // ATANH
  1471. "=ATANH()": "ATANH requires 1 numeric argument",
  1472. `=ATANH("X")`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1473. // ATAN2
  1474. "=ATAN2()": "ATAN2 requires 2 numeric arguments",
  1475. `=ATAN2("X",0)`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1476. `=ATAN2(0,"X")`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1477. // BASE
  1478. "=BASE()": "BASE requires at least 2 arguments",
  1479. "=BASE(1,2,3,4)": "BASE allows at most 3 arguments",
  1480. "=BASE(1,1)": "radix must be an integer >= 2 and <= 36",
  1481. `=BASE("X",2)`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1482. `=BASE(1,"X")`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1483. `=BASE(1,2,"X")`: "strconv.Atoi: parsing \"X\": invalid syntax",
  1484. // CEILING
  1485. "=CEILING()": "CEILING requires at least 1 argument",
  1486. "=CEILING(1,2,3)": "CEILING allows at most 2 arguments",
  1487. "=CEILING(1,-1)": "negative sig to CEILING invalid",
  1488. `=CEILING("X",0)`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1489. `=CEILING(0,"X")`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1490. // _xlfn.CEILING.MATH
  1491. "=_xlfn.CEILING.MATH()": "CEILING.MATH requires at least 1 argument",
  1492. "=_xlfn.CEILING.MATH(1,2,3,4)": "CEILING.MATH allows at most 3 arguments",
  1493. `=_xlfn.CEILING.MATH("X")`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1494. `=_xlfn.CEILING.MATH(1,"X")`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1495. `=_xlfn.CEILING.MATH(1,2,"X")`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1496. // _xlfn.CEILING.PRECISE
  1497. "=_xlfn.CEILING.PRECISE()": "CEILING.PRECISE requires at least 1 argument",
  1498. "=_xlfn.CEILING.PRECISE(1,2,3)": "CEILING.PRECISE allows at most 2 arguments",
  1499. `=_xlfn.CEILING.PRECISE("X",2)`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1500. `=_xlfn.CEILING.PRECISE(1,"X")`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1501. // COMBIN
  1502. "=COMBIN()": "COMBIN requires 2 argument",
  1503. "=COMBIN(-1,1)": "COMBIN requires number >= number_chosen",
  1504. `=COMBIN("X",1)`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1505. `=COMBIN(-1,"X")`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1506. // _xlfn.COMBINA
  1507. "=_xlfn.COMBINA()": "COMBINA requires 2 argument",
  1508. "=_xlfn.COMBINA(-1,1)": "COMBINA requires number > number_chosen",
  1509. "=_xlfn.COMBINA(-1,-1)": "COMBIN requires number >= number_chosen",
  1510. `=_xlfn.COMBINA("X",1)`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1511. `=_xlfn.COMBINA(-1,"X")`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1512. // COS
  1513. "=COS()": "COS requires 1 numeric argument",
  1514. `=COS("X")`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1515. // COSH
  1516. "=COSH()": "COSH requires 1 numeric argument",
  1517. `=COSH("X")`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1518. // _xlfn.COT
  1519. "=COT()": "COT requires 1 numeric argument",
  1520. `=COT("X")`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1521. "=COT(0)": "#DIV/0!",
  1522. // _xlfn.COTH
  1523. "=COTH()": "COTH requires 1 numeric argument",
  1524. `=COTH("X")`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1525. "=COTH(0)": "#DIV/0!",
  1526. // _xlfn.CSC
  1527. "=_xlfn.CSC()": "CSC requires 1 numeric argument",
  1528. `=_xlfn.CSC("X")`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1529. "=_xlfn.CSC(0)": "#DIV/0!",
  1530. // _xlfn.CSCH
  1531. "=_xlfn.CSCH()": "CSCH requires 1 numeric argument",
  1532. `=_xlfn.CSCH("X")`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1533. "=_xlfn.CSCH(0)": "#DIV/0!",
  1534. // _xlfn.DECIMAL
  1535. "=_xlfn.DECIMAL()": "DECIMAL requires 2 numeric arguments",
  1536. `=_xlfn.DECIMAL("X", 2)`: "strconv.ParseInt: parsing \"X\": invalid syntax",
  1537. `=_xlfn.DECIMAL(2000, "X")`: "strconv.Atoi: parsing \"X\": invalid syntax",
  1538. // DEGREES
  1539. "=DEGREES()": "DEGREES requires 1 numeric argument",
  1540. `=DEGREES("X")`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1541. "=DEGREES(0)": "#DIV/0!",
  1542. // EVEN
  1543. "=EVEN()": "EVEN requires 1 numeric argument",
  1544. `=EVEN("X")`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1545. // EXP
  1546. "=EXP()": "EXP requires 1 numeric argument",
  1547. `=EXP("X")`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1548. // FACT
  1549. "=FACT()": "FACT requires 1 numeric argument",
  1550. `=FACT("X")`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1551. "=FACT(-1)": "#NUM!",
  1552. // FACTDOUBLE
  1553. "=FACTDOUBLE()": "FACTDOUBLE requires 1 numeric argument",
  1554. `=FACTDOUBLE("X")`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1555. "=FACTDOUBLE(-1)": "#NUM!",
  1556. // FLOOR
  1557. "=FLOOR()": "FLOOR requires 2 numeric arguments",
  1558. `=FLOOR("X",-1)`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1559. `=FLOOR(1,"X")`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1560. "=FLOOR(1,-1)": "invalid arguments to FLOOR",
  1561. // _xlfn.FLOOR.MATH
  1562. "=_xlfn.FLOOR.MATH()": "FLOOR.MATH requires at least 1 argument",
  1563. "=_xlfn.FLOOR.MATH(1,2,3,4)": "FLOOR.MATH allows at most 3 arguments",
  1564. `=_xlfn.FLOOR.MATH("X",2,3)`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1565. `=_xlfn.FLOOR.MATH(1,"X",3)`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1566. `=_xlfn.FLOOR.MATH(1,2,"X")`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1567. // _xlfn.FLOOR.PRECISE
  1568. "=_xlfn.FLOOR.PRECISE()": "FLOOR.PRECISE requires at least 1 argument",
  1569. "=_xlfn.FLOOR.PRECISE(1,2,3)": "FLOOR.PRECISE allows at most 2 arguments",
  1570. `=_xlfn.FLOOR.PRECISE("X",2)`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1571. `=_xlfn.FLOOR.PRECISE(1,"X")`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1572. // GCD
  1573. "=GCD()": "GCD requires at least 1 argument",
  1574. "=GCD(\"\")": "strconv.ParseFloat: parsing \"\": invalid syntax",
  1575. "=GCD(-1)": "GCD only accepts positive arguments",
  1576. "=GCD(1,-1)": "GCD only accepts positive arguments",
  1577. `=GCD("X")`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1578. // INT
  1579. "=INT()": "INT requires 1 numeric argument",
  1580. `=INT("X")`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1581. // ISO.CEILING
  1582. "=ISO.CEILING()": "ISO.CEILING requires at least 1 argument",
  1583. "=ISO.CEILING(1,2,3)": "ISO.CEILING allows at most 2 arguments",
  1584. `=ISO.CEILING("X",2)`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1585. `=ISO.CEILING(1,"X")`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1586. // LCM
  1587. "=LCM()": "LCM requires at least 1 argument",
  1588. "=LCM(-1)": "LCM only accepts positive arguments",
  1589. "=LCM(1,-1)": "LCM only accepts positive arguments",
  1590. `=LCM("X")`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1591. // LN
  1592. "=LN()": "LN requires 1 numeric argument",
  1593. `=LN("X")`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1594. // LOG
  1595. "=LOG()": "LOG requires at least 1 argument",
  1596. "=LOG(1,2,3)": "LOG allows at most 2 arguments",
  1597. `=LOG("X",1)`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1598. `=LOG(1,"X")`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1599. "=LOG(0,0)": "#DIV/0!",
  1600. "=LOG(1,0)": "#DIV/0!",
  1601. "=LOG(1,1)": "#DIV/0!",
  1602. // LOG10
  1603. "=LOG10()": "LOG10 requires 1 numeric argument",
  1604. `=LOG10("X")`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1605. // MDETERM
  1606. "MDETERM()": "MDETERM requires at least 1 argument",
  1607. // MOD
  1608. "=MOD()": "MOD requires 2 numeric arguments",
  1609. "=MOD(6,0)": "MOD divide by zero",
  1610. `=MOD("X",0)`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1611. `=MOD(6,"X")`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1612. // MROUND
  1613. "=MROUND()": "MROUND requires 2 numeric arguments",
  1614. "=MROUND(1,0)": "#NUM!",
  1615. "=MROUND(1,-1)": "#NUM!",
  1616. `=MROUND("X",0)`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1617. `=MROUND(1,"X")`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1618. // MULTINOMIAL
  1619. `=MULTINOMIAL("X")`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1620. // _xlfn.MUNIT
  1621. "=_xlfn.MUNIT()": "MUNIT requires 1 numeric argument",
  1622. `=_xlfn.MUNIT("X")`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1623. "=_xlfn.MUNIT(-1)": "",
  1624. // ODD
  1625. "=ODD()": "ODD requires 1 numeric argument",
  1626. `=ODD("X")`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1627. // PI
  1628. "=PI(1)": "PI accepts no arguments",
  1629. // POWER
  1630. `=POWER("X",1)`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1631. `=POWER(1,"X")`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1632. "=POWER(0,0)": "#NUM!",
  1633. "=POWER(0,-1)": "#DIV/0!",
  1634. "=POWER(1)": "POWER requires 2 numeric arguments",
  1635. // PRODUCT
  1636. `=PRODUCT("X")`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1637. // QUOTIENT
  1638. `=QUOTIENT("X",1)`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1639. `=QUOTIENT(1,"X")`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1640. "=QUOTIENT(1,0)": "#DIV/0!",
  1641. "=QUOTIENT(1)": "QUOTIENT requires 2 numeric arguments",
  1642. // RADIANS
  1643. `=RADIANS("X")`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1644. "=RADIANS()": "RADIANS requires 1 numeric argument",
  1645. // RAND
  1646. "=RAND(1)": "RAND accepts no arguments",
  1647. // RANDBETWEEN
  1648. `=RANDBETWEEN("X",1)`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1649. `=RANDBETWEEN(1,"X")`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1650. "=RANDBETWEEN()": "RANDBETWEEN requires 2 numeric arguments",
  1651. "=RANDBETWEEN(2,1)": "#NUM!",
  1652. // ROMAN
  1653. "=ROMAN()": "ROMAN requires at least 1 argument",
  1654. "=ROMAN(1,2,3)": "ROMAN allows at most 2 arguments",
  1655. `=ROMAN("X")`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1656. `=ROMAN("X",1)`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1657. // ROUND
  1658. "=ROUND()": "ROUND requires 2 numeric arguments",
  1659. `=ROUND("X",1)`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1660. `=ROUND(1,"X")`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1661. // ROUNDDOWN
  1662. "=ROUNDDOWN()": "ROUNDDOWN requires 2 numeric arguments",
  1663. `=ROUNDDOWN("X",1)`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1664. `=ROUNDDOWN(1,"X")`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1665. // ROUNDUP
  1666. "=ROUNDUP()": "ROUNDUP requires 2 numeric arguments",
  1667. `=ROUNDUP("X",1)`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1668. `=ROUNDUP(1,"X")`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1669. // SEC
  1670. "=_xlfn.SEC()": "SEC requires 1 numeric argument",
  1671. `=_xlfn.SEC("X")`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1672. // _xlfn.SECH
  1673. "=_xlfn.SECH()": "SECH requires 1 numeric argument",
  1674. `=_xlfn.SECH("X")`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1675. // SIGN
  1676. "=SIGN()": "SIGN requires 1 numeric argument",
  1677. `=SIGN("X")`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1678. // SIN
  1679. "=SIN()": "SIN requires 1 numeric argument",
  1680. `=SIN("X")`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1681. // SINH
  1682. "=SINH()": "SINH requires 1 numeric argument",
  1683. `=SINH("X")`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1684. // SQRT
  1685. "=SQRT()": "SQRT requires 1 numeric argument",
  1686. `=SQRT("")`: "strconv.ParseFloat: parsing \"\": invalid syntax",
  1687. `=SQRT("X")`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1688. "=SQRT(-1)": "#NUM!",
  1689. // SQRTPI
  1690. "=SQRTPI()": "SQRTPI requires 1 numeric argument",
  1691. `=SQRTPI("X")`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1692. // STDEV
  1693. "=STDEV()": "STDEV requires at least 1 argument",
  1694. "=STDEV(E2:E9)": "#DIV/0!",
  1695. // STDEV.S
  1696. "=STDEV.S()": "STDEV.S requires at least 1 argument",
  1697. // STDEVA
  1698. "=STDEVA()": "STDEVA requires at least 1 argument",
  1699. "=STDEVA(E2:E9)": "#DIV/0!",
  1700. // POISSON.DIST
  1701. "=POISSON.DIST()": "POISSON.DIST requires 3 arguments",
  1702. // POISSON
  1703. "=POISSON()": "POISSON requires 3 arguments",
  1704. "=POISSON(\"\",0,FALSE)": "strconv.ParseFloat: parsing \"\": invalid syntax",
  1705. "=POISSON(0,\"\",FALSE)": "strconv.ParseFloat: parsing \"\": invalid syntax",
  1706. "=POISSON(0,0,\"\")": "strconv.ParseBool: parsing \"\": invalid syntax",
  1707. "=POISSON(0,-1,TRUE)": "#N/A",
  1708. // SUM
  1709. "=SUM((": ErrInvalidFormula.Error(),
  1710. "=SUM(-)": ErrInvalidFormula.Error(),
  1711. "=SUM(1+)": ErrInvalidFormula.Error(),
  1712. "=SUM(1-)": ErrInvalidFormula.Error(),
  1713. "=SUM(1*)": ErrInvalidFormula.Error(),
  1714. "=SUM(1/)": ErrInvalidFormula.Error(),
  1715. // SUMIF
  1716. "=SUMIF()": "SUMIF requires at least 2 argument",
  1717. // SUMSQ
  1718. `=SUMSQ("X")`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1719. "=SUMSQ(C1:D2)": "strconv.ParseFloat: parsing \"Month\": invalid syntax",
  1720. // TAN
  1721. "=TAN()": "TAN requires 1 numeric argument",
  1722. `=TAN("X")`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1723. // TANH
  1724. "=TANH()": "TANH requires 1 numeric argument",
  1725. `=TANH("X")`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1726. // TRUNC
  1727. "=TRUNC()": "TRUNC requires at least 1 argument",
  1728. `=TRUNC("X")`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1729. `=TRUNC(1,"X")`: "strconv.ParseFloat: parsing \"X\": invalid syntax",
  1730. // Statistical Functions
  1731. // AVERAGE
  1732. "=AVERAGE(H1)": "AVERAGE divide by zero",
  1733. // AVERAGE
  1734. "=AVERAGEA(H1)": "AVERAGEA divide by zero",
  1735. // COUNTBLANK
  1736. "=COUNTBLANK()": "COUNTBLANK requires 1 argument",
  1737. "=COUNTBLANK(1,2)": "COUNTBLANK requires 1 argument",
  1738. // FISHER
  1739. "=FISHER()": "FISHER requires 1 numeric argument",
  1740. "=FISHER(2)": "#N/A",
  1741. "=FISHER(INT(-2)))": "#N/A",
  1742. "=FISHER(F1)": "FISHER requires 1 numeric argument",
  1743. // FISHERINV
  1744. "=FISHERINV()": "FISHERINV requires 1 numeric argument",
  1745. "=FISHERINV(F1)": "FISHERINV requires 1 numeric argument",
  1746. // GAMMA
  1747. "=GAMMA()": "GAMMA requires 1 numeric argument",
  1748. "=GAMMA(F1)": "GAMMA requires 1 numeric argument",
  1749. "=GAMMA(0)": "#N/A",
  1750. "=GAMMA(INT(0))": "#N/A",
  1751. // GAMMALN
  1752. "=GAMMALN()": "GAMMALN requires 1 numeric argument",
  1753. "=GAMMALN(F1)": "GAMMALN requires 1 numeric argument",
  1754. "=GAMMALN(0)": "#N/A",
  1755. "=GAMMALN(INT(0))": "#N/A",
  1756. // HARMEAN
  1757. "=HARMEAN()": "HARMEAN requires at least 1 argument",
  1758. "=HARMEAN(-1)": "#N/A",
  1759. "=HARMEAN(0)": "#N/A",
  1760. // KURT
  1761. "=KURT()": "KURT requires at least 1 argument",
  1762. "=KURT(F1,INT(1))": "#DIV/0!",
  1763. // NORM.DIST
  1764. "=NORM.DIST()": "NORM.DIST requires 4 arguments",
  1765. // NORMDIST
  1766. "=NORMDIST()": "NORMDIST requires 4 arguments",
  1767. "=NORMDIST(\"\",0,0,FALSE)": "strconv.ParseFloat: parsing \"\": invalid syntax",
  1768. "=NORMDIST(0,\"\",0,FALSE)": "strconv.ParseFloat: parsing \"\": invalid syntax",
  1769. "=NORMDIST(0,0,\"\",FALSE)": "strconv.ParseFloat: parsing \"\": invalid syntax",
  1770. "=NORMDIST(0,0,0,\"\")": "strconv.ParseBool: parsing \"\": invalid syntax",
  1771. "=NORMDIST(0,0,-1,TRUE)": "#N/A",
  1772. // NORM.INV
  1773. "=NORM.INV()": "NORM.INV requires 3 arguments",
  1774. // NORMINV
  1775. "=NORMINV()": "NORMINV requires 3 arguments",
  1776. "=NORMINV(\"\",0,0)": "strconv.ParseFloat: parsing \"\": invalid syntax",
  1777. "=NORMINV(0,\"\",0)": "strconv.ParseFloat: parsing \"\": invalid syntax",
  1778. "=NORMINV(0,0,\"\")": "strconv.ParseFloat: parsing \"\": invalid syntax",
  1779. "=NORMINV(0,0,-1)": "#N/A",
  1780. "=NORMINV(-1,0,0)": "#N/A",
  1781. "=NORMINV(0,0,0)": "#NUM!",
  1782. // NORM.S.DIST
  1783. "=NORM.S.DIST()": "NORM.S.DIST requires 2 numeric arguments",
  1784. // NORMSDIST
  1785. "=NORMSDIST()": "NORMSDIST requires 1 numeric argument",
  1786. // NORM.S.INV
  1787. "=NORM.S.INV()": "NORM.S.INV requires 1 numeric argument",
  1788. // NORMSINV
  1789. "=NORMSINV()": "NORMSINV requires 1 numeric argument",
  1790. // LARGE
  1791. "=LARGE()": "LARGE requires 2 arguments",
  1792. "=LARGE(A1:A5,0)": "k should be > 0",
  1793. "=LARGE(A1:A5,6)": "k should be <= length of array",
  1794. "=LARGE(A1:A5,\"\")": "strconv.ParseFloat: parsing \"\": invalid syntax",
  1795. // MAX
  1796. "=MAX()": "MAX requires at least 1 argument",
  1797. "=MAX(NA())": "#N/A",
  1798. // MAXA
  1799. "=MAXA()": "MAXA requires at least 1 argument",
  1800. "=MAXA(NA())": "#N/A",
  1801. // MEDIAN
  1802. "=MEDIAN()": "MEDIAN requires at least 1 argument",
  1803. "=MEDIAN(\"\")": "strconv.ParseFloat: parsing \"\": invalid syntax",
  1804. "=MEDIAN(D1:D2)": "strconv.ParseFloat: parsing \"Month\": invalid syntax",
  1805. // MIN
  1806. "=MIN()": "MIN requires at least 1 argument",
  1807. "=MIN(NA())": "#N/A",
  1808. // MINA
  1809. "=MINA()": "MINA requires at least 1 argument",
  1810. "=MINA(NA())": "#N/A",
  1811. // PERCENTILE.INC
  1812. "=PERCENTILE.INC()": "PERCENTILE.INC requires 2 arguments",
  1813. // PERCENTILE
  1814. "=PERCENTILE()": "PERCENTILE requires 2 arguments",
  1815. "=PERCENTILE(0,\"\")": "strconv.ParseFloat: parsing \"\": invalid syntax",
  1816. "=PERCENTILE(0,-1)": "#N/A",
  1817. "=PERCENTILE(NA(),1)": "#N/A",
  1818. // PERMUT
  1819. "=PERMUT()": "PERMUT requires 2 numeric arguments",
  1820. "=PERMUT(\"\",0)": "strconv.ParseFloat: parsing \"\": invalid syntax",
  1821. "=PERMUT(0,\"\")": "strconv.ParseFloat: parsing \"\": invalid syntax",
  1822. "=PERMUT(6,8)": "#N/A",
  1823. // PERMUTATIONA
  1824. "=PERMUTATIONA()": "PERMUTATIONA requires 2 numeric arguments",
  1825. "=PERMUTATIONA(\"\",0)": "strconv.ParseFloat: parsing \"\": invalid syntax",
  1826. "=PERMUTATIONA(0,\"\")": "strconv.ParseFloat: parsing \"\": invalid syntax",
  1827. "=PERMUTATIONA(-1,0)": "#N/A",
  1828. "=PERMUTATIONA(0,-1)": "#N/A",
  1829. // QUARTILE
  1830. "=QUARTILE()": "QUARTILE requires 2 arguments",
  1831. "=QUARTILE(A1:A4,\"\")": "strconv.ParseFloat: parsing \"\": invalid syntax",
  1832. "=QUARTILE(A1:A4,-1)": "#NUM!",
  1833. "=QUARTILE(A1:A4,5)": "#NUM!",
  1834. // QUARTILE.INC
  1835. "=QUARTILE.INC()": "QUARTILE.INC requires 2 arguments",
  1836. // SKEW
  1837. "=SKEW()": "SKEW requires at least 1 argument",
  1838. "=SKEW(\"\")": "strconv.ParseFloat: parsing \"\": invalid syntax",
  1839. "=SKEW(0)": "#DIV/0!",
  1840. // SMALL
  1841. "=SMALL()": "SMALL requires 2 arguments",
  1842. "=SMALL(A1:A5,0)": "k should be > 0",
  1843. "=SMALL(A1:A5,6)": "k should be <= length of array",
  1844. "=SMALL(A1:A5,\"\")": "strconv.ParseFloat: parsing \"\": invalid syntax",
  1845. // VARP
  1846. "=VARP()": "VARP requires at least 1 argument",
  1847. "=VARP(\"\")": "#DIV/0!",
  1848. // VAR.P
  1849. "=VAR.P()": "VAR.P requires at least 1 argument",
  1850. "=VAR.P(\"\")": "#DIV/0!",
  1851. // Information Functions
  1852. // ISBLANK
  1853. "=ISBLANK(A1,A2)": "ISBLANK requires 1 argument",
  1854. // ISERR
  1855. "=ISERR()": "ISERR requires 1 argument",
  1856. // ISERROR
  1857. "=ISERROR()": "ISERROR requires 1 argument",
  1858. // ISEVEN
  1859. "=ISEVEN()": "ISEVEN requires 1 argument",
  1860. `=ISEVEN("text")`: "strconv.Atoi: parsing \"text\": invalid syntax",
  1861. // ISNA
  1862. "=ISNA()": "ISNA requires 1 argument",
  1863. // ISNONTEXT
  1864. "=ISNONTEXT()": "ISNONTEXT requires 1 argument",
  1865. // ISNUMBER
  1866. "=ISNUMBER()": "ISNUMBER requires 1 argument",
  1867. // ISODD
  1868. "=ISODD()": "ISODD requires 1 argument",
  1869. `=ISODD("text")`: "strconv.Atoi: parsing \"text\": invalid syntax",
  1870. // ISTEXT
  1871. "=ISTEXT()": "ISTEXT requires 1 argument",
  1872. // N
  1873. "=N()": "N requires 1 argument",
  1874. "=N(NA())": "#N/A",
  1875. // NA
  1876. "=NA()": "#N/A",
  1877. "=NA(1)": "NA accepts no arguments",
  1878. // SHEET
  1879. "=SHEET(1)": "SHEET accepts no arguments",
  1880. // T
  1881. "=T()": "T requires 1 argument",
  1882. "=T(NA())": "#N/A",
  1883. // Logical Functions
  1884. // AND
  1885. `=AND("text")`: "strconv.ParseFloat: parsing \"text\": invalid syntax",
  1886. `=AND(A1:B1)`: "#VALUE!",
  1887. "=AND()": "AND requires at least 1 argument",
  1888. "=AND(1" + strings.Repeat(",1", 30) + ")": "AND accepts at most 30 arguments",
  1889. // FALSE
  1890. "=FALSE(A1)": "FALSE takes no arguments",
  1891. // IFERROR
  1892. "=IFERROR()": "IFERROR requires 2 arguments",
  1893. // NOT
  1894. "=NOT()": "NOT requires 1 argument",
  1895. "=NOT(NOT())": "NOT requires 1 argument",
  1896. "=NOT(\"\")": "NOT expects 1 boolean or numeric argument",
  1897. // OR
  1898. `=OR("text")`: "strconv.ParseFloat: parsing \"text\": invalid syntax",
  1899. `=OR(A1:B1)`: "#VALUE!",
  1900. "=OR()": "OR requires at least 1 argument",
  1901. "=OR(1" + strings.Repeat(",1", 30) + ")": "OR accepts at most 30 arguments",
  1902. // TRUE
  1903. "=TRUE(A1)": "TRUE takes no arguments",
  1904. // Date and Time Functions
  1905. // DATE
  1906. "=DATE()": "DATE requires 3 number arguments",
  1907. `=DATE("text",10,21)`: "DATE requires 3 number arguments",
  1908. `=DATE(2020,"text",21)`: "DATE requires 3 number arguments",
  1909. `=DATE(2020,10,"text")`: "DATE requires 3 number arguments",
  1910. // DATEDIF
  1911. "=DATEDIF()": "DATEDIF requires 3 number arguments",
  1912. "=DATEDIF(\"\",\"\",\"\")": "strconv.ParseFloat: parsing \"\": invalid syntax",
  1913. "=DATEDIF(43891,43101,\"Y\")": "start_date > end_date",
  1914. "=DATEDIF(43101,43891,\"x\")": "DATEDIF has invalid unit",
  1915. // NOW
  1916. "=NOW(A1)": "NOW accepts no arguments",
  1917. // TODAY
  1918. "=TODAY(A1)": "TODAY accepts no arguments",
  1919. // Text Functions
  1920. // CHAR
  1921. "=CHAR()": "CHAR requires 1 argument",
  1922. "=CHAR(-1)": "#VALUE!",
  1923. "=CHAR(256)": "#VALUE!",
  1924. "=CHAR(\"\")": "strconv.ParseFloat: parsing \"\": invalid syntax",
  1925. // CLEAN
  1926. "=CLEAN()": "CLEAN requires 1 argument",
  1927. "=CLEAN(1,2)": "CLEAN requires 1 argument",
  1928. // CODE
  1929. "=CODE()": "CODE requires 1 argument",
  1930. "=CODE(1,2)": "CODE requires 1 argument",
  1931. // CONCAT
  1932. "=CONCAT(MUNIT(2))": "CONCAT requires arguments to be strings",
  1933. // CONCATENATE
  1934. "=CONCATENATE(MUNIT(2))": "CONCATENATE requires arguments to be strings",
  1935. // EXACT
  1936. "=EXACT()": "EXACT requires 2 arguments",
  1937. "=EXACT(1,2,3)": "EXACT requires 2 arguments",
  1938. // FIXED
  1939. "=FIXED()": "FIXED requires at least 1 argument",
  1940. "=FIXED(0,1,2,3)": "FIXED allows at most 3 arguments",
  1941. "=FIXED(\"\")": "strconv.ParseFloat: parsing \"\": invalid syntax",
  1942. "=FIXED(0,\"\")": "strconv.ParseFloat: parsing \"\": invalid syntax",
  1943. "=FIXED(0,0,\"\")": "strconv.ParseBool: parsing \"\": invalid syntax",
  1944. // FIND
  1945. "=FIND()": "FIND requires at least 2 arguments",
  1946. "=FIND(1,2,3,4)": "FIND allows at most 3 arguments",
  1947. "=FIND(\"x\",\"\")": "#VALUE!",
  1948. "=FIND(\"x\",\"x\",-1)": "#VALUE!",
  1949. "=FIND(\"x\",\"x\",\"\")": "strconv.ParseFloat: parsing \"\": invalid syntax",
  1950. // FINDB
  1951. "=FINDB()": "FINDB requires at least 2 arguments",
  1952. "=FINDB(1,2,3,4)": "FINDB allows at most 3 arguments",
  1953. "=FINDB(\"x\",\"\")": "#VALUE!",
  1954. "=FINDB(\"x\",\"x\",-1)": "#VALUE!",
  1955. "=FINDB(\"x\",\"x\",\"\")": "strconv.ParseFloat: parsing \"\": invalid syntax",
  1956. // LEFT
  1957. "=LEFT()": "LEFT requires at least 1 argument",
  1958. "=LEFT(\"\",2,3)": "LEFT allows at most 2 arguments",
  1959. "=LEFT(\"\",\"\")": "strconv.ParseFloat: parsing \"\": invalid syntax",
  1960. "=LEFT(\"\",-1)": "#VALUE!",
  1961. // LEFTB
  1962. "=LEFTB()": "LEFTB requires at least 1 argument",
  1963. "=LEFTB(\"\",2,3)": "LEFTB allows at most 2 arguments",
  1964. "=LEFTB(\"\",\"\")": "strconv.ParseFloat: parsing \"\": invalid syntax",
  1965. "=LEFTB(\"\",-1)": "#VALUE!",
  1966. // LEN
  1967. "=LEN()": "LEN requires 1 string argument",
  1968. // LENB
  1969. "=LENB()": "LENB requires 1 string argument",
  1970. // LOWER
  1971. "=LOWER()": "LOWER requires 1 argument",
  1972. "=LOWER(1,2)": "LOWER requires 1 argument",
  1973. // MID
  1974. "=MID()": "MID requires 3 arguments",
  1975. "=MID(\"\",-1,1)": "#VALUE!",
  1976. "=MID(\"\",\"\",1)": "strconv.ParseFloat: parsing \"\": invalid syntax",
  1977. "=MID(\"\",1,\"\")": "strconv.ParseFloat: parsing \"\": invalid syntax",
  1978. // MIDB
  1979. "=MIDB()": "MIDB requires 3 arguments",
  1980. "=MIDB(\"\",-1,1)": "#VALUE!",
  1981. "=MIDB(\"\",\"\",1)": "strconv.ParseFloat: parsing \"\": invalid syntax",
  1982. "=MIDB(\"\",1,\"\")": "strconv.ParseFloat: parsing \"\": invalid syntax",
  1983. // PROPER
  1984. "=PROPER()": "PROPER requires 1 argument",
  1985. "=PROPER(1,2)": "PROPER requires 1 argument",
  1986. // REPLACE
  1987. "=REPLACE()": "REPLACE requires 4 arguments",
  1988. "=REPLACE(\"text\",0,4,\"string\")": "#VALUE!",
  1989. "=REPLACE(\"text\",\"\",0,\"string\")": "strconv.ParseFloat: parsing \"\": invalid syntax",
  1990. "=REPLACE(\"text\",1,\"\",\"string\")": "strconv.ParseFloat: parsing \"\": invalid syntax",
  1991. // REPLACEB
  1992. "=REPLACEB()": "REPLACEB requires 4 arguments",
  1993. "=REPLACEB(\"text\",0,4,\"string\")": "#VALUE!",
  1994. "=REPLACEB(\"text\",\"\",0,\"string\")": "strconv.ParseFloat: parsing \"\": invalid syntax",
  1995. "=REPLACEB(\"text\",1,\"\",\"string\")": "strconv.ParseFloat: parsing \"\": invalid syntax",
  1996. // REPT
  1997. "=REPT()": "REPT requires 2 arguments",
  1998. "=REPT(INT(0),2)": "REPT requires first argument to be a string",
  1999. "=REPT(\"*\",\"*\")": "REPT requires second argument to be a number",
  2000. "=REPT(\"*\",-1)": "REPT requires second argument to be >= 0",
  2001. // RIGHT
  2002. "=RIGHT()": "RIGHT requires at least 1 argument",
  2003. "=RIGHT(\"\",2,3)": "RIGHT allows at most 2 arguments",
  2004. "=RIGHT(\"\",\"\")": "strconv.ParseFloat: parsing \"\": invalid syntax",
  2005. "=RIGHT(\"\",-1)": "#VALUE!",
  2006. // RIGHTB
  2007. "=RIGHTB()": "RIGHTB requires at least 1 argument",
  2008. "=RIGHTB(\"\",2,3)": "RIGHTB allows at most 2 arguments",
  2009. "=RIGHTB(\"\",\"\")": "strconv.ParseFloat: parsing \"\": invalid syntax",
  2010. "=RIGHTB(\"\",-1)": "#VALUE!",
  2011. // SUBSTITUTE
  2012. "=SUBSTITUTE()": "SUBSTITUTE requires 3 or 4 arguments",
  2013. "=SUBSTITUTE(\"\",\"\",\"\",\"\")": "strconv.ParseFloat: parsing \"\": invalid syntax",
  2014. "=SUBSTITUTE(\"\",\"\",\"\",0)": "instance_num should be > 0",
  2015. // TRIM
  2016. "=TRIM()": "TRIM requires 1 argument",
  2017. "=TRIM(1,2)": "TRIM requires 1 argument",
  2018. // UNICHAR
  2019. "=UNICHAR()": "UNICHAR requires 1 argument",
  2020. "=UNICHAR(\"\")": "strconv.ParseFloat: parsing \"\": invalid syntax",
  2021. "=UNICHAR(55296)": "#VALUE!",
  2022. "=UNICHAR(0)": "#VALUE!",
  2023. // UNICODE
  2024. "=UNICODE()": "UNICODE requires 1 argument",
  2025. "=UNICODE(\"\")": "#VALUE!",
  2026. // UPPER
  2027. "=UPPER()": "UPPER requires 1 argument",
  2028. "=UPPER(1,2)": "UPPER requires 1 argument",
  2029. // Conditional Functions
  2030. // IF
  2031. "=IF()": "IF requires at least 1 argument",
  2032. "=IF(0,1,2,3)": "IF accepts at most 3 arguments",
  2033. "=IF(D1,1,2)": "strconv.ParseBool: parsing \"Month\": invalid syntax",
  2034. // Excel Lookup and Reference Functions
  2035. // CHOOSE
  2036. "=CHOOSE()": "CHOOSE requires 2 arguments",
  2037. "=CHOOSE(\"index_num\",0)": "CHOOSE requires first argument of type number",
  2038. "=CHOOSE(2,0)": "index_num should be <= to the number of values",
  2039. // COLUMN
  2040. "=COLUMN(1,2)": "COLUMN requires at most 1 argument",
  2041. "=COLUMN(\"\")": "invalid reference",
  2042. "=COLUMN(Sheet1)": "invalid column name \"Sheet1\"",
  2043. "=COLUMN(Sheet1!A1!B1)": "invalid column name \"Sheet1\"",
  2044. // COLUMNS
  2045. "=COLUMNS()": "COLUMNS requires 1 argument",
  2046. "=COLUMNS(1)": "invalid reference",
  2047. "=COLUMNS(\"\")": "invalid reference",
  2048. "=COLUMNS(Sheet1)": "invalid column name \"Sheet1\"",
  2049. "=COLUMNS(Sheet1!A1!B1)": "invalid column name \"Sheet1\"",
  2050. "=COLUMNS(Sheet1!Sheet1)": "invalid column name \"Sheet1\"",
  2051. // HLOOKUP
  2052. "=HLOOKUP()": "HLOOKUP requires at least 3 arguments",
  2053. "=HLOOKUP(D2,D1,1,FALSE)": "HLOOKUP requires second argument of table array",
  2054. "=HLOOKUP(D2,D:D,FALSE,FALSE)": "HLOOKUP requires numeric row argument",
  2055. "=HLOOKUP(D2,D:D,1,FALSE,FALSE)": "HLOOKUP requires at most 4 arguments",
  2056. "=HLOOKUP(D2,D:D,1,2)": "strconv.ParseBool: parsing \"2\": invalid syntax",
  2057. "=HLOOKUP(D2,D10:D10,1,FALSE)": "HLOOKUP no result found",
  2058. "=HLOOKUP(D2,D2:D3,4,FALSE)": "HLOOKUP has invalid row index",
  2059. "=HLOOKUP(D2,C:C,1,FALSE)": "HLOOKUP no result found",
  2060. "=HLOOKUP(ISNUMBER(1),F3:F9,1)": "HLOOKUP no result found",
  2061. "=HLOOKUP(INT(1),E2:E9,1)": "HLOOKUP no result found",
  2062. "=HLOOKUP(MUNIT(2),MUNIT(3),1)": "HLOOKUP no result found",
  2063. "=HLOOKUP(A1:B2,B2:B3,1)": "HLOOKUP no result found",
  2064. // VLOOKUP
  2065. "=VLOOKUP()": "VLOOKUP requires at least 3 arguments",
  2066. "=VLOOKUP(D2,D1,1,FALSE)": "VLOOKUP requires second argument of table array",
  2067. "=VLOOKUP(D2,D:D,FALSE,FALSE)": "VLOOKUP requires numeric col argument",
  2068. "=VLOOKUP(D2,D:D,1,FALSE,FALSE)": "VLOOKUP requires at most 4 arguments",
  2069. "=VLOOKUP(D2,D:D,1,2)": "strconv.ParseBool: parsing \"2\": invalid syntax",
  2070. "=VLOOKUP(D2,D10:D10,1,FALSE)": "VLOOKUP no result found",
  2071. "=VLOOKUP(D2,D:D,2,FALSE)": "VLOOKUP has invalid column index",
  2072. "=VLOOKUP(D2,C:C,1,FALSE)": "VLOOKUP no result found",
  2073. "=VLOOKUP(ISNUMBER(1),F3:F9,1)": "VLOOKUP no result found",
  2074. "=VLOOKUP(INT(1),E2:E9,1)": "VLOOKUP no result found",
  2075. "=VLOOKUP(MUNIT(2),MUNIT(3),1)": "VLOOKUP no result found",
  2076. "=VLOOKUP(1,G1:H2,1,FALSE)": "VLOOKUP no result found",
  2077. // LOOKUP
  2078. "=LOOKUP()": "LOOKUP requires at least 2 arguments",
  2079. "=LOOKUP(D2,D1,D2)": "LOOKUP requires second argument of table array",
  2080. "=LOOKUP(D2,D1,D2,FALSE)": "LOOKUP requires at most 3 arguments",
  2081. "=LOOKUP(D1,MUNIT(1),MUNIT(1))": "LOOKUP no result found",
  2082. // ROW
  2083. "=ROW(1,2)": "ROW requires at most 1 argument",
  2084. "=ROW(\"\")": "invalid reference",
  2085. "=ROW(Sheet1)": "invalid column name \"Sheet1\"",
  2086. "=ROW(Sheet1!A1!B1)": "invalid column name \"Sheet1\"",
  2087. // ROWS
  2088. "=ROWS()": "ROWS requires 1 argument",
  2089. "=ROWS(1)": "invalid reference",
  2090. "=ROWS(\"\")": "invalid reference",
  2091. "=ROWS(Sheet1)": "invalid column name \"Sheet1\"",
  2092. "=ROWS(Sheet1!A1!B1)": "invalid column name \"Sheet1\"",
  2093. "=ROWS(Sheet1!Sheet1)": "invalid column name \"Sheet1\"",
  2094. // Web Functions
  2095. // ENCODEURL
  2096. "=ENCODEURL()": "ENCODEURL requires 1 argument",
  2097. // Financial Functions
  2098. // CUMIPMT
  2099. "=CUMIPMT()": "CUMIPMT requires 6 arguments",
  2100. "=CUMIPMT(0,0,0,0,0,2)": "#N/A",
  2101. "=CUMIPMT(0,0,0,-1,0,0)": "#N/A",
  2102. "=CUMIPMT(0,0,0,1,0,0)": "#N/A",
  2103. "=CUMIPMT(\"\",0,0,0,0,0)": "strconv.ParseFloat: parsing \"\": invalid syntax",
  2104. "=CUMIPMT(0,\"\",0,0,0,0)": "strconv.ParseFloat: parsing \"\": invalid syntax",
  2105. "=CUMIPMT(0,0,\"\",0,0,0)": "strconv.ParseFloat: parsing \"\": invalid syntax",
  2106. "=CUMIPMT(0,0,0,\"\",0,0)": "strconv.ParseFloat: parsing \"\": invalid syntax",
  2107. "=CUMIPMT(0,0,0,0,\"\",0)": "strconv.ParseFloat: parsing \"\": invalid syntax",
  2108. "=CUMIPMT(0,0,0,0,0,\"\")": "strconv.ParseFloat: parsing \"\": invalid syntax",
  2109. // CUMPRINC
  2110. "=CUMPRINC()": "CUMPRINC requires 6 arguments",
  2111. "=CUMPRINC(0,0,0,0,0,2)": "#N/A",
  2112. "=CUMPRINC(0,0,0,-1,0,0)": "#N/A",
  2113. "=CUMPRINC(0,0,0,1,0,0)": "#N/A",
  2114. "=CUMPRINC(\"\",0,0,0,0,0)": "strconv.ParseFloat: parsing \"\": invalid syntax",
  2115. "=CUMPRINC(0,\"\",0,0,0,0)": "strconv.ParseFloat: parsing \"\": invalid syntax",
  2116. "=CUMPRINC(0,0,\"\",0,0,0)": "strconv.ParseFloat: parsing \"\": invalid syntax",
  2117. "=CUMPRINC(0,0,0,\"\",0,0)": "strconv.ParseFloat: parsing \"\": invalid syntax",
  2118. "=CUMPRINC(0,0,0,0,\"\",0)": "strconv.ParseFloat: parsing \"\": invalid syntax",
  2119. "=CUMPRINC(0,0,0,0,0,\"\")": "strconv.ParseFloat: parsing \"\": invalid syntax",
  2120. // DB
  2121. "=DB()": "DB requires at least 4 arguments",
  2122. "=DB(0,0,0,0,0,0)": "DB allows at most 5 arguments",
  2123. "=DB(-1,0,0,0)": "#N/A",
  2124. "=DB(\"\",0,0,0,0)": "strconv.ParseFloat: parsing \"\": invalid syntax",
  2125. "=DB(0,\"\",0,0,0)": "strconv.ParseFloat: parsing \"\": invalid syntax",
  2126. "=DB(0,0,\"\",0,0)": "strconv.ParseFloat: parsing \"\": invalid syntax",
  2127. "=DB(0,0,0,\"\",0)": "strconv.ParseFloat: parsing \"\": invalid syntax",
  2128. "=DB(0,0,0,0,\"\")": "strconv.ParseFloat: parsing \"\": invalid syntax",
  2129. // DDB
  2130. "=DDB()": "DDB requires at least 4 arguments",
  2131. "=DDB(0,0,0,0,0,0)": "DDB allows at most 5 arguments",
  2132. "=DDB(-1,0,0,0)": "#N/A",
  2133. "=DDB(\"\",0,0,0,0)": "strconv.ParseFloat: parsing \"\": invalid syntax",
  2134. "=DDB(0,\"\",0,0,0)": "strconv.ParseFloat: parsing \"\": invalid syntax",
  2135. "=DDB(0,0,\"\",0,0)": "strconv.ParseFloat: parsing \"\": invalid syntax",
  2136. "=DDB(0,0,0,\"\",0)": "strconv.ParseFloat: parsing \"\": invalid syntax",
  2137. "=DDB(0,0,0,0,\"\")": "strconv.ParseFloat: parsing \"\": invalid syntax",
  2138. // DOLLARDE
  2139. "=DOLLARDE()": "DOLLARDE requires 2 arguments",
  2140. "=DOLLARDE(\"\",0)": "strconv.ParseFloat: parsing \"\": invalid syntax",
  2141. "=DOLLARDE(0,\"\")": "strconv.ParseFloat: parsing \"\": invalid syntax",
  2142. "=DOLLARDE(0,-1)": "#NUM!",
  2143. "=DOLLARDE(0,0)": "#DIV/0!",
  2144. // DOLLARFR
  2145. "=DOLLARFR()": "DOLLARFR requires 2 arguments",
  2146. "=DOLLARFR(\"\",0)": "strconv.ParseFloat: parsing \"\": invalid syntax",
  2147. "=DOLLARFR(0,\"\")": "strconv.ParseFloat: parsing \"\": invalid syntax",
  2148. "=DOLLARFR(0,-1)": "#NUM!",
  2149. "=DOLLARFR(0,0)": "#DIV/0!",
  2150. // EFFECT
  2151. "=EFFECT()": "EFFECT requires 2 arguments",
  2152. "=EFFECT(\"\",0)": "strconv.ParseFloat: parsing \"\": invalid syntax",
  2153. "=EFFECT(0,\"\")": "strconv.ParseFloat: parsing \"\": invalid syntax",
  2154. "=EFFECT(0,0)": "#NUM!",
  2155. "=EFFECT(1,0)": "#NUM!",
  2156. // FV
  2157. "=FV()": "FV requires at least 3 arguments",
  2158. "=FV(0,0,0,0,0,0,0)": "FV allows at most 5 arguments",
  2159. "=FV(0,0,0,0,2)": "#N/A",
  2160. "=FV(\"\",0,0,0,0)": "strconv.ParseFloat: parsing \"\": invalid syntax",
  2161. "=FV(0,\"\",0,0,0)": "strconv.ParseFloat: parsing \"\": invalid syntax",
  2162. "=FV(0,0,\"\",0,0)": "strconv.ParseFloat: parsing \"\": invalid syntax",
  2163. "=FV(0,0,0,\"\",0)": "strconv.ParseFloat: parsing \"\": invalid syntax",
  2164. "=FV(0,0,0,0,\"\")": "strconv.ParseFloat: parsing \"\": invalid syntax",
  2165. // FVSCHEDULE
  2166. "=FVSCHEDULE()": "FVSCHEDULE requires 2 arguments",
  2167. "=FVSCHEDULE(\"\",0)": "strconv.ParseFloat: parsing \"\": invalid syntax",
  2168. "=FVSCHEDULE(0,\"x\")": "strconv.ParseFloat: parsing \"x\": invalid syntax",
  2169. // IPMT
  2170. "=IPMT()": "IPMT requires at least 4 arguments",
  2171. "=IPMT(0,0,0,0,0,0,0)": "IPMT allows at most 6 arguments",
  2172. "=IPMT(0,0,0,0,0,2)": "#N/A",
  2173. "=IPMT(0,-1,0,0,0,0)": "#N/A",
  2174. "=IPMT(0,1,0,0,0,0)": "#N/A",
  2175. "=IPMT(\"\",0,0,0,0,0)": "strconv.ParseFloat: parsing \"\": invalid syntax",
  2176. "=IPMT(0,\"\",0,0,0,0)": "strconv.ParseFloat: parsing \"\": invalid syntax",
  2177. "=IPMT(0,0,\"\",0,0,0)": "strconv.ParseFloat: parsing \"\": invalid syntax",
  2178. "=IPMT(0,0,0,\"\",0,0)": "strconv.ParseFloat: parsing \"\": invalid syntax",
  2179. "=IPMT(0,0,0,0,\"\",0)": "strconv.ParseFloat: parsing \"\": invalid syntax",
  2180. "=IPMT(0,0,0,0,0,\"\")": "strconv.ParseFloat: parsing \"\": invalid syntax",
  2181. // ISPMT
  2182. "=ISPMT()": "ISPMT requires 4 arguments",
  2183. "=ISPMT(\"\",0,0,0)": "strconv.ParseFloat: parsing \"\": invalid syntax",
  2184. "=ISPMT(0,\"\",0,0)": "strconv.ParseFloat: parsing \"\": invalid syntax",
  2185. "=ISPMT(0,0,\"\",0)": "strconv.ParseFloat: parsing \"\": invalid syntax",
  2186. "=ISPMT(0,0,0,\"\")": "strconv.ParseFloat: parsing \"\": invalid syntax",
  2187. // NOMINAL
  2188. "=NOMINAL()": "NOMINAL requires 2 arguments",
  2189. "=NOMINAL(\"\",0)": "strconv.ParseFloat: parsing \"\": invalid syntax",
  2190. "=NOMINAL(0,\"\")": "strconv.ParseFloat: parsing \"\": invalid syntax",
  2191. "=NOMINAL(0,0)": "#NUM!",
  2192. "=NOMINAL(1,0)": "#NUM!",
  2193. // NPER
  2194. "=NPER()": "NPER requires at least 3 arguments",
  2195. "=NPER(0,0,0,0,0,0)": "NPER allows at most 5 arguments",
  2196. "=NPER(0,0,0)": "#NUM!",
  2197. "=NPER(0,0,0,0,2)": "#N/A",
  2198. "=NPER(\"\",0,0,0,0)": "strconv.ParseFloat: parsing \"\": invalid syntax",
  2199. "=NPER(0,\"\",0,0,0)": "strconv.ParseFloat: parsing \"\": invalid syntax",
  2200. "=NPER(0,0,\"\",0,0)": "strconv.ParseFloat: parsing \"\": invalid syntax",
  2201. "=NPER(0,0,0,\"\",0)": "strconv.ParseFloat: parsing \"\": invalid syntax",
  2202. "=NPER(0,0,0,0,\"\")": "strconv.ParseFloat: parsing \"\": invalid syntax",
  2203. // NPV
  2204. "=NPV()": "NPV requires at least 2 arguments",
  2205. "=NPV(\"\",0)": "strconv.ParseFloat: parsing \"\": invalid syntax",
  2206. // PDURATION
  2207. "=PDURATION()": "PDURATION requires 3 arguments",
  2208. "=PDURATION(\"\",0,0)": "strconv.ParseFloat: parsing \"\": invalid syntax",
  2209. "=PDURATION(0,\"\",0)": "strconv.ParseFloat: parsing \"\": invalid syntax",
  2210. "=PDURATION(0,0,\"\")": "strconv.ParseFloat: parsing \"\": invalid syntax",
  2211. "=PDURATION(0,0,0)": "#NUM!",
  2212. // PMT
  2213. "=PMT()": "PMT requires at least 3 arguments",
  2214. "=PMT(0,0,0,0,0,0)": "PMT allows at most 5 arguments",
  2215. "=PMT(0,0,0,0,2)": "#N/A",
  2216. "=PMT(\"\",0,0,0,0)": "strconv.ParseFloat: parsing \"\": invalid syntax",
  2217. "=PMT(0,\"\",0,0,0)": "strconv.ParseFloat: parsing \"\": invalid syntax",
  2218. "=PMT(0,0,\"\",0,0)": "strconv.ParseFloat: parsing \"\": invalid syntax",
  2219. "=PMT(0,0,0,\"\",0)": "strconv.ParseFloat: parsing \"\": invalid syntax",
  2220. "=PMT(0,0,0,0,\"\")": "strconv.ParseFloat: parsing \"\": invalid syntax",
  2221. // PPMT
  2222. "=PPMT()": "PPMT requires at least 4 arguments",
  2223. "=PPMT(0,0,0,0,0,0,0)": "PPMT allows at most 6 arguments",
  2224. "=PPMT(0,0,0,0,0,2)": "#N/A",
  2225. "=PPMT(0,-1,0,0,0,0)": "#N/A",
  2226. "=PPMT(0,1,0,0,0,0)": "#N/A",
  2227. "=PPMT(\"\",0,0,0,0,0)": "strconv.ParseFloat: parsing \"\": invalid syntax",
  2228. "=PPMT(0,\"\",0,0,0,0)": "strconv.ParseFloat: parsing \"\": invalid syntax",
  2229. "=PPMT(0,0,\"\",0,0,0)": "strconv.ParseFloat: parsing \"\": invalid syntax",
  2230. "=PPMT(0,0,0,\"\",0,0)": "strconv.ParseFloat: parsing \"\": invalid syntax",
  2231. "=PPMT(0,0,0,0,\"\",0)": "strconv.ParseFloat: parsing \"\": invalid syntax",
  2232. "=PPMT(0,0,0,0,0,\"\")": "strconv.ParseFloat: parsing \"\": invalid syntax",
  2233. }
  2234. for formula, expected := range mathCalcError {
  2235. f := prepareCalcData(cellData)
  2236. assert.NoError(t, f.SetCellFormula("Sheet1", "C1", formula))
  2237. result, err := f.CalcCellValue("Sheet1", "C1")
  2238. assert.EqualError(t, err, expected, formula)
  2239. assert.Equal(t, "", result, formula)
  2240. }
  2241. referenceCalc := map[string]string{
  2242. // MDETERM
  2243. "=MDETERM(A1:B2)": "-3",
  2244. // PRODUCT
  2245. "=PRODUCT(Sheet1!A1:Sheet1!A1:A2,A2)": "4",
  2246. // IMPRODUCT
  2247. "=IMPRODUCT(Sheet1!A1:Sheet1!A1:A2,A2)": "4",
  2248. // SUM
  2249. "=A1/A3": "0.333333333333333",
  2250. "=SUM(A1:A2)": "3",
  2251. "=SUM(Sheet1!A1,A2)": "3",
  2252. "=(-2-SUM(-4+A2))*5": "0",
  2253. "=SUM(Sheet1!A1:Sheet1!A1:A2,A2)": "5",
  2254. "=SUM(A1,A2,A3)*SUM(2,3)": "30",
  2255. "=1+SUM(SUM(A1+A2/A3)*(2-3),2)": "1.333333333333334",
  2256. "=A1/A2/SUM(A1:A2:B1)": "0.041666666666667",
  2257. "=A1/A2/SUM(A1:A2:B1)*A3": "0.125",
  2258. "=SUM(B1:D1)": "4",
  2259. "=SUM(\"X\")": "0",
  2260. }
  2261. for formula, expected := range referenceCalc {
  2262. f := prepareCalcData(cellData)
  2263. assert.NoError(t, f.SetCellFormula("Sheet1", "C1", formula))
  2264. result, err := f.CalcCellValue("Sheet1", "C1")
  2265. assert.NoError(t, err)
  2266. assert.Equal(t, expected, result, formula)
  2267. }
  2268. referenceCalcError := map[string]string{
  2269. // MDETERM
  2270. "=MDETERM(A1:B3)": "#VALUE!",
  2271. // SUM
  2272. "=1+SUM(SUM(A1+A2/A4)*(2-3),2)": "#DIV/0!",
  2273. }
  2274. for formula, expected := range referenceCalcError {
  2275. f := prepareCalcData(cellData)
  2276. assert.NoError(t, f.SetCellFormula("Sheet1", "C1", formula))
  2277. result, err := f.CalcCellValue("Sheet1", "C1")
  2278. assert.EqualError(t, err, expected)
  2279. assert.Equal(t, "", result, formula)
  2280. }
  2281. volatileFuncs := []string{
  2282. "=NOW()",
  2283. "=RAND()",
  2284. "=RANDBETWEEN(1,2)",
  2285. "=TODAY()",
  2286. }
  2287. for _, formula := range volatileFuncs {
  2288. f := prepareCalcData(cellData)
  2289. assert.NoError(t, f.SetCellFormula("Sheet1", "C1", formula))
  2290. _, err := f.CalcCellValue("Sheet1", "C1")
  2291. assert.NoError(t, err)
  2292. }
  2293. // Test get calculated cell value on not formula cell.
  2294. f := prepareCalcData(cellData)
  2295. result, err := f.CalcCellValue("Sheet1", "A1")
  2296. assert.NoError(t, err)
  2297. assert.Equal(t, "", result)
  2298. // Test get calculated cell value on not exists worksheet.
  2299. f = prepareCalcData(cellData)
  2300. _, err = f.CalcCellValue("SheetN", "A1")
  2301. assert.EqualError(t, err, "sheet SheetN is not exist")
  2302. // Test get calculated cell value with not support formula.
  2303. f = prepareCalcData(cellData)
  2304. assert.NoError(t, f.SetCellFormula("Sheet1", "A1", "=UNSUPPORT(A1)"))
  2305. _, err = f.CalcCellValue("Sheet1", "A1")
  2306. assert.EqualError(t, err, "not support UNSUPPORT function")
  2307. assert.NoError(t, f.SaveAs(filepath.Join("test", "TestCalcCellValue.xlsx")))
  2308. }
  2309. func TestCalculate(t *testing.T) {
  2310. err := `strconv.ParseFloat: parsing "string": invalid syntax`
  2311. opd := NewStack()
  2312. opd.Push(efp.Token{TValue: "string"})
  2313. opt := efp.Token{TValue: "-", TType: efp.TokenTypeOperatorPrefix}
  2314. assert.EqualError(t, calculate(opd, opt), err)
  2315. opd.Push(efp.Token{TValue: "string"})
  2316. opd.Push(efp.Token{TValue: "string"})
  2317. opt = efp.Token{TValue: "-", TType: efp.TokenTypeOperatorInfix}
  2318. assert.EqualError(t, calculate(opd, opt), err)
  2319. }
  2320. func TestCalcWithDefinedName(t *testing.T) {
  2321. cellData := [][]interface{}{
  2322. {"A1 value", "B1 value", nil},
  2323. }
  2324. f := prepareCalcData(cellData)
  2325. assert.NoError(t, f.SetDefinedName(&DefinedName{Name: "defined_name1", RefersTo: "Sheet1!A1", Scope: "Workbook"}))
  2326. assert.NoError(t, f.SetDefinedName(&DefinedName{Name: "defined_name1", RefersTo: "Sheet1!B1", Scope: "Sheet1"}))
  2327. assert.NoError(t, f.SetCellFormula("Sheet1", "C1", "=defined_name1"))
  2328. result, err := f.CalcCellValue("Sheet1", "C1")
  2329. assert.NoError(t, err)
  2330. // DefinedName with scope WorkSheet takes precedence over DefinedName with scope Workbook, so we should get B1 value
  2331. assert.Equal(t, "B1 value", result, "=defined_name1")
  2332. }
  2333. func TestCalcArithmeticOperations(t *testing.T) {
  2334. err := `strconv.ParseFloat: parsing "text": invalid syntax`
  2335. assert.EqualError(t, calcPow("1", "text", nil), err)
  2336. assert.EqualError(t, calcPow("text", "1", nil), err)
  2337. assert.EqualError(t, calcL("1", "text", nil), err)
  2338. assert.EqualError(t, calcL("text", "1", nil), err)
  2339. assert.EqualError(t, calcLe("1", "text", nil), err)
  2340. assert.EqualError(t, calcLe("text", "1", nil), err)
  2341. assert.EqualError(t, calcG("1", "text", nil), err)
  2342. assert.EqualError(t, calcG("text", "1", nil), err)
  2343. assert.EqualError(t, calcGe("1", "text", nil), err)
  2344. assert.EqualError(t, calcGe("text", "1", nil), err)
  2345. assert.EqualError(t, calcAdd("1", "text", nil), err)
  2346. assert.EqualError(t, calcAdd("text", "1", nil), err)
  2347. assert.EqualError(t, calcAdd("1", "text", nil), err)
  2348. assert.EqualError(t, calcAdd("text", "1", nil), err)
  2349. assert.EqualError(t, calcSubtract("1", "text", nil), err)
  2350. assert.EqualError(t, calcSubtract("text", "1", nil), err)
  2351. assert.EqualError(t, calcMultiply("1", "text", nil), err)
  2352. assert.EqualError(t, calcMultiply("text", "1", nil), err)
  2353. assert.EqualError(t, calcDiv("1", "text", nil), err)
  2354. assert.EqualError(t, calcDiv("text", "1", nil), err)
  2355. }
  2356. func TestCalcISBLANK(t *testing.T) {
  2357. argsList := list.New()
  2358. argsList.PushBack(formulaArg{
  2359. Type: ArgUnknown,
  2360. })
  2361. fn := formulaFuncs{}
  2362. result := fn.ISBLANK(argsList)
  2363. assert.Equal(t, result.String, "TRUE")
  2364. assert.Empty(t, result.Error)
  2365. }
  2366. func TestCalcAND(t *testing.T) {
  2367. argsList := list.New()
  2368. argsList.PushBack(formulaArg{
  2369. Type: ArgUnknown,
  2370. })
  2371. fn := formulaFuncs{}
  2372. result := fn.AND(argsList)
  2373. assert.Equal(t, result.String, "")
  2374. assert.Empty(t, result.Error)
  2375. }
  2376. func TestCalcOR(t *testing.T) {
  2377. argsList := list.New()
  2378. argsList.PushBack(formulaArg{
  2379. Type: ArgUnknown,
  2380. })
  2381. fn := formulaFuncs{}
  2382. result := fn.OR(argsList)
  2383. assert.Equal(t, result.String, "FALSE")
  2384. assert.Empty(t, result.Error)
  2385. }
  2386. func TestCalcDet(t *testing.T) {
  2387. assert.Equal(t, det([][]float64{
  2388. {1, 2, 3, 4},
  2389. {2, 3, 4, 5},
  2390. {3, 4, 5, 6},
  2391. {4, 5, 6, 7},
  2392. }), float64(0))
  2393. }
  2394. func TestCalcToBool(t *testing.T) {
  2395. b := newBoolFormulaArg(true).ToBool()
  2396. assert.Equal(t, b.Boolean, true)
  2397. assert.Equal(t, b.Number, 1.0)
  2398. }
  2399. func TestCalcToList(t *testing.T) {
  2400. assert.Equal(t, []formulaArg(nil), newEmptyFormulaArg().ToList())
  2401. formulaList := []formulaArg{newEmptyFormulaArg()}
  2402. assert.Equal(t, formulaList, newListFormulaArg(formulaList).ToList())
  2403. }
  2404. func TestCalcCompareFormulaArg(t *testing.T) {
  2405. assert.Equal(t, compareFormulaArg(newEmptyFormulaArg(), newEmptyFormulaArg(), false, false), criteriaEq)
  2406. lhs := newListFormulaArg([]formulaArg{newEmptyFormulaArg()})
  2407. rhs := newListFormulaArg([]formulaArg{newEmptyFormulaArg(), newEmptyFormulaArg()})
  2408. assert.Equal(t, compareFormulaArg(lhs, rhs, false, false), criteriaL)
  2409. assert.Equal(t, compareFormulaArg(rhs, lhs, false, false), criteriaG)
  2410. lhs = newListFormulaArg([]formulaArg{newBoolFormulaArg(true)})
  2411. rhs = newListFormulaArg([]formulaArg{newBoolFormulaArg(true)})
  2412. assert.Equal(t, compareFormulaArg(lhs, rhs, false, false), criteriaEq)
  2413. assert.Equal(t, compareFormulaArg(formulaArg{Type: ArgUnknown}, formulaArg{Type: ArgUnknown}, false, false), criteriaErr)
  2414. }
  2415. func TestCalcMatchPattern(t *testing.T) {
  2416. assert.True(t, matchPattern("", ""))
  2417. assert.True(t, matchPattern("file/*", "file/abc/bcd/def"))
  2418. assert.True(t, matchPattern("*", ""))
  2419. assert.False(t, matchPattern("file/?", "file/abc/bcd/def"))
  2420. }
  2421. func TestCalcVLOOKUP(t *testing.T) {
  2422. cellData := [][]interface{}{
  2423. {nil, nil, nil, nil, nil, nil},
  2424. {nil, "Score", "Grade", nil, nil, nil},
  2425. {nil, 0, "F", nil, "Score", 85},
  2426. {nil, 60, "D", nil, "Grade"},
  2427. {nil, 70, "C", nil, nil, nil},
  2428. {nil, 80, "b", nil, nil, nil},
  2429. {nil, 90, "A", nil, nil, nil},
  2430. {nil, 85, "B", nil, nil, nil},
  2431. {nil, nil, nil, nil, nil, nil},
  2432. }
  2433. f := prepareCalcData(cellData)
  2434. calc := map[string]string{
  2435. "=VLOOKUP(F3,B3:C8,2)": "b",
  2436. "=VLOOKUP(F3,B3:C8,2,TRUE)": "b",
  2437. "=VLOOKUP(F3,B3:C8,2,FALSE)": "B",
  2438. }
  2439. for formula, expected := range calc {
  2440. assert.NoError(t, f.SetCellFormula("Sheet1", "F4", formula))
  2441. result, err := f.CalcCellValue("Sheet1", "F4")
  2442. assert.NoError(t, err, formula)
  2443. assert.Equal(t, expected, result, formula)
  2444. }
  2445. calcError := map[string]string{
  2446. "=VLOOKUP(INT(1),C3:C3,1,FALSE)": "VLOOKUP no result found",
  2447. }
  2448. for formula, expected := range calcError {
  2449. assert.NoError(t, f.SetCellFormula("Sheet1", "F4", formula))
  2450. result, err := f.CalcCellValue("Sheet1", "F4")
  2451. assert.EqualError(t, err, expected, formula)
  2452. assert.Equal(t, "", result, formula)
  2453. }
  2454. }
  2455. func TestCalcBoolean(t *testing.T) {
  2456. cellData := [][]interface{}{
  2457. {0.5, "TRUE", -0.5, "FALSE"},
  2458. }
  2459. f := prepareCalcData(cellData)
  2460. formulaList := map[string]string{
  2461. "=AVERAGEA(A1:C1)": "0.333333333333333",
  2462. "=MAX(0.5,B1)": "0.5",
  2463. "=MAX(A1:B1)": "0.5",
  2464. "=MAXA(A1:B1)": "1",
  2465. "=MAXA(0.5,B1)": "1",
  2466. "=MIN(-0.5,D1)": "-0.5",
  2467. "=MIN(C1:D1)": "-0.5",
  2468. "=MINA(C1:D1)": "-0.5",
  2469. "=MINA(-0.5,D1)": "-0.5",
  2470. "=STDEV(A1:C1)": "0.707106781186548",
  2471. "=STDEV(A1,B1,C1)": "0.707106781186548",
  2472. "=STDEVA(A1:C1,B1)": "0.707106781186548",
  2473. }
  2474. for formula, expected := range formulaList {
  2475. assert.NoError(t, f.SetCellFormula("Sheet1", "B10", formula))
  2476. result, err := f.CalcCellValue("Sheet1", "B10")
  2477. assert.NoError(t, err, formula)
  2478. assert.Equal(t, expected, result, formula)
  2479. }
  2480. }
  2481. func TestCalcHLOOKUP(t *testing.T) {
  2482. cellData := [][]interface{}{
  2483. {"Example Result Table"},
  2484. {nil, "A", "B", "C", "E", "F"},
  2485. {"Math", .58, .9, .67, .76, .8},
  2486. {"French", .61, .71, .59, .59, .76},
  2487. {"Physics", .75, .45, .39, .52, .69},
  2488. {"Biology", .39, .55, .77, .61, .45},
  2489. {},
  2490. {"Individual Student Score"},
  2491. {"Student:", "Biology Score:"},
  2492. {"E"},
  2493. }
  2494. f := prepareCalcData(cellData)
  2495. formulaList := map[string]string{
  2496. "=HLOOKUP(A10,A2:F6,5,FALSE)": "0.61",
  2497. "=HLOOKUP(D3,D3:D3,1,TRUE)": "0.67",
  2498. "=HLOOKUP(F3,D3:F3,1,TRUE)": "0.8",
  2499. "=HLOOKUP(A5,A2:F2,1,TRUE)": "F",
  2500. "=HLOOKUP(\"D\",A2:F2,1,TRUE)": "C",
  2501. }
  2502. for formula, expected := range formulaList {
  2503. assert.NoError(t, f.SetCellFormula("Sheet1", "B10", formula))
  2504. result, err := f.CalcCellValue("Sheet1", "B10")
  2505. assert.NoError(t, err, formula)
  2506. assert.Equal(t, expected, result, formula)
  2507. }
  2508. calcError := map[string]string{
  2509. "=HLOOKUP(INT(1),A3:A3,1,FALSE)": "HLOOKUP no result found",
  2510. }
  2511. for formula, expected := range calcError {
  2512. assert.NoError(t, f.SetCellFormula("Sheet1", "B10", formula))
  2513. result, err := f.CalcCellValue("Sheet1", "B10")
  2514. assert.EqualError(t, err, expected, formula)
  2515. assert.Equal(t, "", result, formula)
  2516. }
  2517. }
  2518. func TestCalcIRR(t *testing.T) {
  2519. cellData := [][]interface{}{{-1}, {0.2}, {0.24}, {0.288}, {0.3456}, {0.4147}}
  2520. f := prepareCalcData(cellData)
  2521. formulaList := map[string]string{
  2522. "=IRR(A1:A4)": "-0.136189509034157",
  2523. "=IRR(A1:A6)": "0.130575760006905",
  2524. "=IRR(A1:A4,-0.1)": "-0.136189514994621",
  2525. }
  2526. for formula, expected := range formulaList {
  2527. assert.NoError(t, f.SetCellFormula("Sheet1", "B1", formula))
  2528. result, err := f.CalcCellValue("Sheet1", "B1")
  2529. assert.NoError(t, err, formula)
  2530. assert.Equal(t, expected, result, formula)
  2531. }
  2532. calcError := map[string]string{
  2533. "=IRR()": "IRR requires at least 1 argument",
  2534. "=IRR(0,0,0)": "IRR allows at most 2 arguments",
  2535. "=IRR(0,\"\")": "strconv.ParseFloat: parsing \"\": invalid syntax",
  2536. "=IRR(A2:A3)": "#NUM!",
  2537. }
  2538. for formula, expected := range calcError {
  2539. assert.NoError(t, f.SetCellFormula("Sheet1", "B1", formula))
  2540. result, err := f.CalcCellValue("Sheet1", "B1")
  2541. assert.EqualError(t, err, expected, formula)
  2542. assert.Equal(t, "", result, formula)
  2543. }
  2544. }
  2545. func TestCalcMIRR(t *testing.T) {
  2546. cellData := [][]interface{}{{-100}, {18}, {22.5}, {28}, {35.5}, {45}}
  2547. f := prepareCalcData(cellData)
  2548. formulaList := map[string]string{
  2549. "=MIRR(A1:A5,0.055,0.05)": "0.025376365108071",
  2550. "=MIRR(A1:A6,0.055,0.05)": "0.1000268752662",
  2551. }
  2552. for formula, expected := range formulaList {
  2553. assert.NoError(t, f.SetCellFormula("Sheet1", "B1", formula))
  2554. result, err := f.CalcCellValue("Sheet1", "B1")
  2555. assert.NoError(t, err, formula)
  2556. assert.Equal(t, expected, result, formula)
  2557. }
  2558. calcError := map[string]string{
  2559. "=MIRR()": "MIRR requires 3 arguments",
  2560. "=MIRR(A1:A5,\"\",0)": "strconv.ParseFloat: parsing \"\": invalid syntax",
  2561. "=MIRR(A1:A5,0,\"\")": "strconv.ParseFloat: parsing \"\": invalid syntax",
  2562. "=MIRR(B1:B5,0,0)": "#DIV/0!",
  2563. }
  2564. for formula, expected := range calcError {
  2565. assert.NoError(t, f.SetCellFormula("Sheet1", "B1", formula))
  2566. result, err := f.CalcCellValue("Sheet1", "B1")
  2567. assert.EqualError(t, err, expected, formula)
  2568. assert.Equal(t, "", result, formula)
  2569. }
  2570. }