calc_test.go 101 KB

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