styles.go 94 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143
  1. // Copyright 2016 - 2021 The excelize Authors. All rights reserved. Use of
  2. // this source code is governed by a BSD-style license that can be found in
  3. // the LICENSE file.
  4. //
  5. // Package excelize providing a set of functions that allow you to write to
  6. // and read from XLSX / XLSM / XLTM files. Supports reading and writing
  7. // spreadsheet documents generated by Microsoft Excel™ 2007 and later. Supports
  8. // complex components by high compatibility, and provided streaming API for
  9. // generating or reading data from a worksheet with huge amounts of data. This
  10. // library needs Go version 1.15 or later.
  11. package excelize
  12. import (
  13. "bytes"
  14. "encoding/json"
  15. "encoding/xml"
  16. "errors"
  17. "fmt"
  18. "io"
  19. "log"
  20. "math"
  21. "reflect"
  22. "regexp"
  23. "strconv"
  24. "strings"
  25. )
  26. // Excel styles can reference number formats that are built-in, all of which
  27. // have an id less than 164. Note that this number format code list is under
  28. // English localization.
  29. var builtInNumFmt = map[int]string{
  30. 0: "general",
  31. 1: "0",
  32. 2: "0.00",
  33. 3: "#,##0",
  34. 4: "#,##0.00",
  35. 9: "0%",
  36. 10: "0.00%",
  37. 11: "0.00e+00",
  38. 12: "# ?/?",
  39. 13: "# ??/??",
  40. 14: "mm-dd-yy",
  41. 15: "d-mmm-yy",
  42. 16: "d-mmm",
  43. 17: "mmm-yy",
  44. 18: "h:mm am/pm",
  45. 19: "h:mm:ss am/pm",
  46. 20: "h:mm",
  47. 21: "h:mm:ss",
  48. 22: "m/d/yy hh:mm",
  49. 37: "#,##0 ;(#,##0)",
  50. 38: "#,##0 ;[red](#,##0)",
  51. 39: "#,##0.00;(#,##0.00)",
  52. 40: "#,##0.00;[red](#,##0.00)",
  53. 41: `_(* #,##0_);_(* \(#,##0\);_(* "-"_);_(@_)`,
  54. 42: `_("$"* #,##0_);_("$* \(#,##0\);_("$"* "-"_);_(@_)`,
  55. 43: `_(* #,##0.00_);_(* \(#,##0.00\);_(* "-"??_);_(@_)`,
  56. 44: `_("$"* #,##0.00_);_("$"* \(#,##0.00\);_("$"* "-"??_);_(@_)`,
  57. 45: "mm:ss",
  58. 46: "[h]:mm:ss",
  59. 47: "mmss.0",
  60. 48: "##0.0e+0",
  61. 49: "@",
  62. }
  63. // langNumFmt defined number format code (with unicode values provided for
  64. // language glyphs where they occur) in different language.
  65. var langNumFmt = map[string]map[int]string{
  66. "zh-tw": {
  67. 27: "[$-404]e/m/d",
  68. 28: `[$-404]e"年"m"月"d"日"`,
  69. 29: `[$-404]e"年"m"月"d"日"`,
  70. 30: "m/d/yy",
  71. 31: `yyyy"年"m"月"d"日"`,
  72. 32: `hh"時"mm"分"`,
  73. 33: `hh"時"mm"分"ss"秒"`,
  74. 34: `上午/下午 hh"時"mm"分"`,
  75. 35: `上午/下午 hh"時"mm"分"ss"秒"`,
  76. 36: "[$-404]e/m/d",
  77. 50: "[$-404]e/m/d",
  78. 51: `[$-404]e"年"m"月"d"日"`,
  79. 52: `上午/下午 hh"時"mm"分"`,
  80. 53: `上午/下午 hh"時"mm"分"ss"秒"`,
  81. 54: `[$-404]e"年"m"月"d"日"`,
  82. 55: `上午/下午 hh"時"mm"分"`,
  83. 56: `上午/下午 hh"時"mm"分"ss"秒"`,
  84. 57: "[$-404]e/m/d",
  85. 58: `[$-404]e"年"m"月"d"日"`,
  86. },
  87. "zh-cn": {
  88. 27: `yyyy"年"m"月"`,
  89. 28: `m"月"d"日"`,
  90. 29: `m"月"d"日"`,
  91. 30: "m-d-yy",
  92. 31: `yyyy"年"m"月"d"日"`,
  93. 32: `h"时"mm"分"`,
  94. 33: `h"时"mm"分"ss"秒"`,
  95. 34: `上午/下午 h"时"mm"分"`,
  96. 35: `上午/下午 h"时"mm"分"ss"秒"`,
  97. 36: `yyyy"年"m"月"`,
  98. 50: `yyyy"年"m"月"`,
  99. 51: `m"月"d"日"`,
  100. 52: `yyyy"年"m"月"`,
  101. 53: `m"月"d"日"`,
  102. 54: `m"月"d"日"`,
  103. 55: `上午/下午 h"时"mm"分"`,
  104. 56: `上午/下午 h"时"mm"分"ss"秒"`,
  105. 57: `yyyy"年"m"月"`,
  106. 58: `m"月"d"日"`,
  107. },
  108. "zh-tw_unicode": {
  109. 27: "[$-404]e/m/d",
  110. 28: `[$-404]e"5E74"m"6708"d"65E5"`,
  111. 29: `[$-404]e"5E74"m"6708"d"65E5"`,
  112. 30: "m/d/yy",
  113. 31: `yyyy"5E74"m"6708"d"65E5"`,
  114. 32: `hh"6642"mm"5206"`,
  115. 33: `hh"6642"mm"5206"ss"79D2"`,
  116. 34: `4E0A5348/4E0B5348hh"6642"mm"5206"`,
  117. 35: `4E0A5348/4E0B5348hh"6642"mm"5206"ss"79D2"`,
  118. 36: "[$-404]e/m/d",
  119. 50: "[$-404]e/m/d",
  120. 51: `[$-404]e"5E74"m"6708"d"65E5"`,
  121. 52: `4E0A5348/4E0B5348hh"6642"mm"5206"`,
  122. 53: `4E0A5348/4E0B5348hh"6642"mm"5206"ss"79D2"`,
  123. 54: `[$-404]e"5E74"m"6708"d"65E5"`,
  124. 55: `4E0A5348/4E0B5348hh"6642"mm"5206"`,
  125. 56: `4E0A5348/4E0B5348hh"6642"mm"5206"ss"79D2"`,
  126. 57: "[$-404]e/m/d",
  127. 58: `[$-404]e"5E74"m"6708"d"65E5"`,
  128. },
  129. "zh-cn_unicode": {
  130. 27: `yyyy"5E74"m"6708"`,
  131. 28: `m"6708"d"65E5"`,
  132. 29: `m"6708"d"65E5"`,
  133. 30: "m-d-yy",
  134. 31: `yyyy"5E74"m"6708"d"65E5"`,
  135. 32: `h"65F6"mm"5206"`,
  136. 33: `h"65F6"mm"5206"ss"79D2"`,
  137. 34: `4E0A5348/4E0B5348h"65F6"mm"5206"`,
  138. 35: `4E0A5348/4E0B5348h"65F6"mm"5206"ss"79D2"`,
  139. 36: `yyyy"5E74"m"6708"`,
  140. 50: `yyyy"5E74"m"6708"`,
  141. 51: `m"6708"d"65E5"`,
  142. 52: `yyyy"5E74"m"6708"`,
  143. 53: `m"6708"d"65E5"`,
  144. 54: `m"6708"d"65E5"`,
  145. 55: `4E0A5348/4E0B5348h"65F6"mm"5206"`,
  146. 56: `4E0A5348/4E0B5348h"65F6"mm"5206"ss"79D2"`,
  147. 57: `yyyy"5E74"m"6708"`,
  148. 58: `m"6708"d"65E5"`,
  149. },
  150. "ja-jp": {
  151. 27: "[$-411]ge.m.d",
  152. 28: `[$-411]ggge"年"m"月"d"日"`,
  153. 29: `[$-411]ggge"年"m"月"d"日"`,
  154. 30: "m/d/yy",
  155. 31: `yyyy"年"m"月"d"日"`,
  156. 32: `h"時"mm"分"`,
  157. 33: `h"時"mm"分"ss"秒"`,
  158. 34: `yyyy"年"m"月"`,
  159. 35: `m"月"d"日"`,
  160. 36: "[$-411]ge.m.d",
  161. 50: "[$-411]ge.m.d",
  162. 51: `[$-411]ggge"年"m"月"d"日"`,
  163. 52: `yyyy"年"m"月"`,
  164. 53: `m"月"d"日"`,
  165. 54: `[$-411]ggge"年"m"月"d"日"`,
  166. 55: `yyyy"年"m"月"`,
  167. 56: `m"月"d"日"`,
  168. 57: "[$-411]ge.m.d",
  169. 58: `[$-411]ggge"年"m"月"d"日"`,
  170. },
  171. "ko-kr": {
  172. 27: `yyyy"年" mm"月" dd"日"`,
  173. 28: "mm-dd",
  174. 29: "mm-dd",
  175. 30: "mm-dd-yy",
  176. 31: `yyyy"년" mm"월" dd"일"`,
  177. 32: `h"시" mm"분"`,
  178. 33: `h"시" mm"분" ss"초"`,
  179. 34: `yyyy-mm-dd`,
  180. 35: `yyyy-mm-dd`,
  181. 36: `yyyy"年" mm"月" dd"日"`,
  182. 50: `yyyy"年" mm"月" dd"日"`,
  183. 51: "mm-dd",
  184. 52: "yyyy-mm-dd",
  185. 53: "yyyy-mm-dd",
  186. 54: "mm-dd",
  187. 55: "yyyy-mm-dd",
  188. 56: "yyyy-mm-dd",
  189. 57: `yyyy"年" mm"月" dd"日"`,
  190. 58: "mm-dd",
  191. },
  192. "ja-jp_unicode": {
  193. 27: "[$-411]ge.m.d",
  194. 28: `[$-411]ggge"5E74"m"6708"d"65E5"`,
  195. 29: `[$-411]ggge"5E74"m"6708"d"65E5"`,
  196. 30: "m/d/yy",
  197. 31: `yyyy"5E74"m"6708"d"65E5"`,
  198. 32: `h"6642"mm"5206"`,
  199. 33: `h"6642"mm"5206"ss"79D2"`,
  200. 34: `yyyy"5E74"m"6708"`,
  201. 35: `m"6708"d"65E5"`,
  202. 36: "[$-411]ge.m.d",
  203. 50: "[$-411]ge.m.d",
  204. 51: `[$-411]ggge"5E74"m"6708"d"65E5"`,
  205. 52: `yyyy"5E74"m"6708"`,
  206. 53: `m"6708"d"65E5"`,
  207. 54: `[$-411]ggge"5E74"m"6708"d"65E5"`,
  208. 55: `yyyy"5E74"m"6708"`,
  209. 56: `m"6708"d"65E5"`,
  210. 57: "[$-411]ge.m.d",
  211. 58: `[$-411]ggge"5E74"m"6708"d"65E5"`,
  212. },
  213. "ko-kr_unicode": {
  214. 27: `yyyy"5E74" mm"6708" dd"65E5"`,
  215. 28: "mm-dd",
  216. 29: "mm-dd",
  217. 30: "mm-dd-yy",
  218. 31: `yyyy"B144" mm"C6D4" dd"C77C"`,
  219. 32: `h"C2DC" mm"BD84"`,
  220. 33: `h"C2DC" mm"BD84" ss"CD08"`,
  221. 34: "yyyy-mm-dd",
  222. 35: "yyyy-mm-dd",
  223. 36: `yyyy"5E74" mm"6708" dd"65E5"`,
  224. 50: `yyyy"5E74" mm"6708" dd"65E5"`,
  225. 51: "mm-dd",
  226. 52: "yyyy-mm-dd",
  227. 53: "yyyy-mm-dd",
  228. 54: "mm-dd",
  229. 55: "yyyy-mm-dd",
  230. 56: "yyyy-mm-dd",
  231. 57: `yyyy"5E74" mm"6708" dd"65E5"`,
  232. 58: "mm-dd",
  233. },
  234. "th-th": {
  235. 59: "t0",
  236. 60: "t0.00",
  237. 61: "t#,##0",
  238. 62: "t#,##0.00",
  239. 67: "t0%",
  240. 68: "t0.00%",
  241. 69: "t# ?/?",
  242. 70: "t# ??/??",
  243. 71: "ว/ด/ปปปป",
  244. 72: "ว-ดดด-ปป",
  245. 73: "ว-ดดด",
  246. 74: "ดดด-ปป",
  247. 75: "ช:นน",
  248. 76: "ช:นน:ทท",
  249. 77: "ว/ด/ปปปป ช:นน",
  250. 78: "นน:ทท",
  251. 79: "[ช]:นน:ทท",
  252. 80: "นน:ทท.0",
  253. 81: "d/m/bb",
  254. },
  255. "th-th_unicode": {
  256. 59: "t0",
  257. 60: "t0.00",
  258. 61: "t#,##0",
  259. 62: "t#,##0.00",
  260. 67: "t0%",
  261. 68: "t0.00%",
  262. 69: "t# ?/?",
  263. 70: "t# ??/??",
  264. 71: "0E27/0E14/0E1B0E1B0E1B0E1B",
  265. 72: "0E27-0E140E140E14-0E1B0E1B",
  266. 73: "0E27-0E140E140E14",
  267. 74: "0E140E140E14-0E1B0E1B",
  268. 75: "0E0A:0E190E19",
  269. 76: "0E0A:0E190E19:0E170E17",
  270. 77: "0E27/0E14/0E1B0E1B0E1B0E1B 0E0A:0E190E19",
  271. 78: "0E190E19:0E170E17",
  272. 79: "[0E0A]:0E190E19:0E170E17",
  273. 80: "0E190E19:0E170E17.0",
  274. 81: "d/m/bb",
  275. },
  276. }
  277. // currencyNumFmt defined the currency number format map.
  278. var currencyNumFmt = map[int]string{
  279. 164: `"CN¥",##0.00`,
  280. 165: "[$$-409]#,##0.00",
  281. 166: "[$$-45C]#,##0.00",
  282. 167: "[$$-1004]#,##0.00",
  283. 168: "[$$-404]#,##0.00",
  284. 169: "[$$-C09]#,##0.00",
  285. 170: "[$$-2809]#,##0.00",
  286. 171: "[$$-1009]#,##0.00",
  287. 172: "[$$-2009]#,##0.00",
  288. 173: "[$$-1409]#,##0.00",
  289. 174: "[$$-4809]#,##0.00",
  290. 175: "[$$-2C09]#,##0.00",
  291. 176: "[$$-2409]#,##0.00",
  292. 177: "[$$-1000]#,##0.00",
  293. 178: `#,##0.00\ [$$-C0C]`,
  294. 179: "[$$-475]#,##0.00",
  295. 180: "[$$-83E]#,##0.00",
  296. 181: `[$$-86B]\ #,##0.00`,
  297. 182: `[$$-340A]\ #,##0.00`,
  298. 183: "[$$-240A]#,##0.00",
  299. 184: `[$$-300A]\ #,##0.00`,
  300. 185: "[$$-440A]#,##0.00",
  301. 186: "[$$-80A]#,##0.00",
  302. 187: "[$$-500A]#,##0.00",
  303. 188: "[$$-540A]#,##0.00",
  304. 189: `[$$-380A]\ #,##0.00`,
  305. 190: "[$£-809]#,##0.00",
  306. 191: "[$£-491]#,##0.00",
  307. 192: "[$£-452]#,##0.00",
  308. 193: "[$¥-804]#,##0.00",
  309. 194: "[$¥-411]#,##0.00",
  310. 195: "[$¥-478]#,##0.00",
  311. 196: "[$¥-451]#,##0.00",
  312. 197: "[$¥-480]#,##0.00",
  313. 198: "#,##0.00\\ [$\u058F-42B]",
  314. 199: "[$\u060B-463]#,##0.00",
  315. 200: "[$\u060B-48C]#,##0.00",
  316. 201: "[$\u09F3-845]\\ #,##0.00",
  317. 202: "#,##0.00[$\u17DB-453]",
  318. 203: "[$\u20A1-140A]#,##0.00",
  319. 204: "[$\u20A6-468]\\ #,##0.00",
  320. 205: "[$\u20A6-470]\\ #,##0.00",
  321. 206: "[$\u20A9-412]#,##0.00",
  322. 207: "[$\u20AA-40D]\\ #,##0.00",
  323. 208: "#,##0.00\\ [$\u20AB-42A]",
  324. 209: "#,##0.00\\ [$\u20AC-42D]",
  325. 210: "#,##0.00\\ [$\u20AC-47E]",
  326. 211: "#,##0.00\\ [$\u20AC-403]",
  327. 212: "#,##0.00\\ [$\u20AC-483]",
  328. 213: "[$\u20AC-813]\\ #,##0.00",
  329. 214: "[$\u20AC-413]\\ #,##0.00",
  330. 215: "[$\u20AC-1809]#,##0.00",
  331. 216: "#,##0.00\\ [$\u20AC-425]",
  332. 217: "[$\u20AC-2]\\ #,##0.00",
  333. 218: "#,##0.00\\ [$\u20AC-1]",
  334. 219: "#,##0.00\\ [$\u20AC-40B]",
  335. 220: "#,##0.00\\ [$\u20AC-80C]",
  336. 221: "#,##0.00\\ [$\u20AC-40C]",
  337. 222: "#,##0.00\\ [$\u20AC-140C]",
  338. 223: "#,##0.00\\ [$\u20AC-180C]",
  339. 224: "[$\u20AC-200C]#,##0.00",
  340. 225: "#,##0.00\\ [$\u20AC-456]",
  341. 226: "#,##0.00\\ [$\u20AC-C07]",
  342. 227: "#,##0.00\\ [$\u20AC-407]",
  343. 228: "#,##0.00\\ [$\u20AC-1007]",
  344. 229: "#,##0.00\\ [$\u20AC-408]",
  345. 230: "#,##0.00\\ [$\u20AC-243B]",
  346. 231: "[$\u20AC-83C]#,##0.00",
  347. 232: "[$\u20AC-410]\\ #,##0.00",
  348. 233: "[$\u20AC-476]#,##0.00",
  349. 234: "#,##0.00\\ [$\u20AC-2C1A]",
  350. 235: "[$\u20AC-426]\\ #,##0.00",
  351. 236: "#,##0.00\\ [$\u20AC-427]",
  352. 237: "#,##0.00\\ [$\u20AC-82E]",
  353. 238: "#,##0.00\\ [$\u20AC-46E]",
  354. 239: "[$\u20AC-43A]#,##0.00",
  355. 240: "#,##0.00\\ [$\u20AC-C3B]",
  356. 241: "#,##0.00\\ [$\u20AC-482]",
  357. 242: "#,##0.00\\ [$\u20AC-816]",
  358. 243: "#,##0.00\\ [$\u20AC-301A]",
  359. 244: "#,##0.00\\ [$\u20AC-203B]",
  360. 245: "#,##0.00\\ [$\u20AC-41B]",
  361. 246: "#,##0.00\\ [$\u20AC-424]",
  362. 247: "#,##0.00\\ [$\u20AC-C0A]",
  363. 248: "#,##0.00\\ [$\u20AC-81D]",
  364. 249: "#,##0.00\\ [$\u20AC-484]",
  365. 250: "#,##0.00\\ [$\u20AC-42E]",
  366. 251: "[$\u20AC-462]\\ #,##0.00",
  367. 252: "#,##0.00\\ [$₭-454]",
  368. 253: "#,##0.00\\ [$₮-450]",
  369. 254: "[$\u20AE-C50]#,##0.00",
  370. 255: "[$\u20B1-3409]#,##0.00",
  371. 256: "[$\u20B1-464]#,##0.00",
  372. 257: "#,##0.00[$\u20B4-422]",
  373. 258: "[$\u20B8-43F]#,##0.00",
  374. 259: "[$\u20B9-460]#,##0.00",
  375. 260: "[$\u20B9-4009]\\ #,##0.00",
  376. 261: "[$\u20B9-447]\\ #,##0.00",
  377. 262: "[$\u20B9-439]\\ #,##0.00",
  378. 263: "[$\u20B9-44B]\\ #,##0.00",
  379. 264: "[$\u20B9-860]#,##0.00",
  380. 265: "[$\u20B9-457]\\ #,##0.00",
  381. 266: "[$\u20B9-458]#,##0.00",
  382. 267: "[$\u20B9-44E]\\ #,##0.00",
  383. 268: "[$\u20B9-861]#,##0.00",
  384. 269: "[$\u20B9-448]\\ #,##0.00",
  385. 270: "[$\u20B9-446]\\ #,##0.00",
  386. 271: "[$\u20B9-44F]\\ #,##0.00",
  387. 272: "[$\u20B9-459]#,##0.00",
  388. 273: "[$\u20B9-449]\\ #,##0.00",
  389. 274: "[$\u20B9-820]#,##0.00",
  390. 275: "#,##0.00\\ [$\u20BA-41F]",
  391. 276: "#,##0.00\\ [$\u20BC-42C]",
  392. 277: "#,##0.00\\ [$\u20BC-82C]",
  393. 278: "#,##0.00\\ [$\u20BD-419]",
  394. 279: "#,##0.00[$\u20BD-485]",
  395. 280: "#,##0.00\\ [$\u20BE-437]",
  396. 281: "[$B/.-180A]\\ #,##0.00",
  397. 282: "[$Br-472]#,##0.00",
  398. 283: "[$Br-477]#,##0.00",
  399. 284: "#,##0.00[$Br-473]",
  400. 285: "[$Bs-46B]\\ #,##0.00",
  401. 286: "[$Bs-400A]\\ #,##0.00",
  402. 287: "[$Bs.-200A]\\ #,##0.00",
  403. 288: "[$BWP-832]\\ #,##0.00",
  404. 289: "[$C$-4C0A]#,##0.00",
  405. 290: "[$CA$-85D]#,##0.00",
  406. 291: "[$CA$-47C]#,##0.00",
  407. 292: "[$CA$-45D]#,##0.00",
  408. 293: "[$CFA-340C]#,##0.00",
  409. 294: "[$CFA-280C]#,##0.00",
  410. 295: "#,##0.00\\ [$CFA-867]",
  411. 296: "#,##0.00\\ [$CFA-488]",
  412. 297: "#,##0.00\\ [$CHF-100C]",
  413. 298: "[$CHF-1407]\\ #,##0.00",
  414. 299: "[$CHF-807]\\ #,##0.00",
  415. 300: "[$CHF-810]\\ #,##0.00",
  416. 301: "[$CHF-417]\\ #,##0.00",
  417. 302: "[$CLP-47A]\\ #,##0.00",
  418. 303: "[$CN¥-850]#,##0.00",
  419. 304: "#,##0.00\\ [$DZD-85F]",
  420. 305: "[$FCFA-2C0C]#,##0.00",
  421. 306: "#,##0.00\\ [$Ft-40E]",
  422. 307: "[$G-3C0C]#,##0.00",
  423. 308: "[$Gs.-3C0A]\\ #,##0.00",
  424. 309: "[$GTQ-486]#,##0.00",
  425. 310: "[$HK$-C04]#,##0.00",
  426. 311: "[$HK$-3C09]#,##0.00",
  427. 312: "#,##0.00\\ [$HRK-41A]",
  428. 313: "[$IDR-3809]#,##0.00",
  429. 314: "[$IQD-492]#,##0.00",
  430. 315: "#,##0.00\\ [$ISK-40F]",
  431. 316: "[$K-455]#,##0.00",
  432. 317: "#,##0.00\\ [$K\u010D-405]",
  433. 318: "#,##0.00\\ [$KM-141A]",
  434. 319: "#,##0.00\\ [$KM-101A]",
  435. 320: "#,##0.00\\ [$KM-181A]",
  436. 321: "[$kr-438]\\ #,##0.00",
  437. 322: "[$kr-43B]\\ #,##0.00",
  438. 323: "#,##0.00\\ [$kr-83B]",
  439. 324: "[$kr-414]\\ #,##0.00",
  440. 325: "[$kr-814]\\ #,##0.00",
  441. 326: "#,##0.00\\ [$kr-41D]",
  442. 327: "[$kr.-406]\\ #,##0.00",
  443. 328: "[$kr.-46F]\\ #,##0.00",
  444. 329: "[$Ksh-441]#,##0.00",
  445. 330: "[$L-818]#,##0.00",
  446. 331: "[$L-819]#,##0.00",
  447. 332: "[$L-480A]\\ #,##0.00",
  448. 333: "#,##0.00\\ [$Lek\u00EB-41C]",
  449. 334: "[$MAD-45F]#,##0.00",
  450. 335: "[$MAD-380C]#,##0.00",
  451. 336: "#,##0.00\\ [$MAD-105F]",
  452. 337: "[$MOP$-1404]#,##0.00",
  453. 338: "#,##0.00\\ [$MVR-465]_-",
  454. 339: "#,##0.00[$Nfk-873]",
  455. 340: "[$NGN-466]#,##0.00",
  456. 341: "[$NGN-467]#,##0.00",
  457. 342: "[$NGN-469]#,##0.00",
  458. 343: "[$NGN-471]#,##0.00",
  459. 344: "[$NOK-103B]\\ #,##0.00",
  460. 345: "[$NOK-183B]\\ #,##0.00",
  461. 346: "[$NZ$-481]#,##0.00",
  462. 347: "[$PKR-859]\\ #,##0.00",
  463. 348: "[$PYG-474]#,##0.00",
  464. 349: "[$Q-100A]#,##0.00",
  465. 350: "[$R-436]\\ #,##0.00",
  466. 351: "[$R-1C09]\\ #,##0.00",
  467. 352: "[$R-435]\\ #,##0.00",
  468. 353: "[$R$-416]\\ #,##0.00",
  469. 354: "[$RD$-1C0A]#,##0.00",
  470. 355: "#,##0.00\\ [$RF-487]",
  471. 356: "[$RM-4409]#,##0.00",
  472. 357: "[$RM-43E]#,##0.00",
  473. 358: "#,##0.00\\ [$RON-418]",
  474. 359: "[$Rp-421]#,##0.00",
  475. 360: "[$Rs-420]#,##0.00_-",
  476. 361: "[$Rs.-849]\\ #,##0.00",
  477. 362: "#,##0.00\\ [$RSD-81A]",
  478. 363: "#,##0.00\\ [$RSD-C1A]",
  479. 364: "#,##0.00\\ [$RUB-46D]",
  480. 365: "#,##0.00\\ [$RUB-444]",
  481. 366: "[$S/.-C6B]\\ #,##0.00",
  482. 367: "[$S/.-280A]\\ #,##0.00",
  483. 368: "#,##0.00\\ [$SEK-143B]",
  484. 369: "#,##0.00\\ [$SEK-1C3B]",
  485. 370: "#,##0.00\\ [$so\u02BBm-443]",
  486. 371: "#,##0.00\\ [$so\u02BBm-843]",
  487. 372: "#,##0.00\\ [$SYP-45A]",
  488. 373: "[$THB-41E]#,##0.00",
  489. 374: "#,##0.00[$TMT-442]",
  490. 375: "[$US$-3009]#,##0.00",
  491. 376: "[$ZAR-46C]\\ #,##0.00",
  492. 377: "[$ZAR-430]#,##0.00",
  493. 378: "[$ZAR-431]#,##0.00",
  494. 379: "[$ZAR-432]\\ #,##0.00",
  495. 380: "[$ZAR-433]#,##0.00",
  496. 381: "[$ZAR-434]\\ #,##0.00",
  497. 382: "#,##0.00\\ [$z\u0142-415]",
  498. 383: "#,##0.00\\ [$\u0434\u0435\u043D-42F]",
  499. 384: "#,##0.00\\ [$КМ-201A]",
  500. 385: "#,##0.00\\ [$КМ-1C1A]",
  501. 386: "#,##0.00\\ [$\u043B\u0432.-402]",
  502. 387: "#,##0.00\\ [$р.-423]",
  503. 388: "#,##0.00\\ [$\u0441\u043E\u043C-440]",
  504. 389: "#,##0.00\\ [$\u0441\u043E\u043C-428]",
  505. 390: "[$\u062C.\u0645.-C01]\\ #,##0.00_-",
  506. 391: "[$\u062F.\u0623.-2C01]\\ #,##0.00_-",
  507. 392: "[$\u062F.\u0625.-3801]\\ #,##0.00_-",
  508. 393: "[$\u062F.\u0628.-3C01]\\ #,##0.00_-",
  509. 394: "[$\u062F.\u062A.-1C01]\\ #,##0.00_-",
  510. 395: "[$\u062F.\u062C.-1401]\\ #,##0.00_-",
  511. 396: "[$\u062F.\u0639.-801]\\ #,##0.00_-",
  512. 397: "[$\u062F.\u0643.-3401]\\ #,##0.00_-",
  513. 398: "[$\u062F.\u0644.-1001]#,##0.00_-",
  514. 399: "[$\u062F.\u0645.-1801]\\ #,##0.00_-",
  515. 400: "[$\u0631-846]\\ #,##0.00",
  516. 401: "[$\u0631.\u0633.-401]\\ #,##0.00_-",
  517. 402: "[$\u0631.\u0639.-2001]\\ #,##0.00_-",
  518. 403: "[$\u0631.\u0642.-4001]\\ #,##0.00_-",
  519. 404: "[$\u0631.\u064A.-2401]\\ #,##0.00_-",
  520. 405: "[$\u0631\u06CC\u0627\u0644-429]#,##0.00_-",
  521. 406: "[$\u0644.\u0633.-2801]\\ #,##0.00_-",
  522. 407: "[$\u0644.\u0644.-3001]\\ #,##0.00_-",
  523. 408: "[$\u1265\u122D-45E]#,##0.00",
  524. 409: "[$\u0930\u0942-461]#,##0.00",
  525. 410: "[$\u0DBB\u0DD4.-45B]\\ #,##0.00",
  526. 411: "[$ADP]\\ #,##0.00",
  527. 412: "[$AED]\\ #,##0.00",
  528. 413: "[$AFA]\\ #,##0.00",
  529. 414: "[$AFN]\\ #,##0.00",
  530. 415: "[$ALL]\\ #,##0.00",
  531. 416: "[$AMD]\\ #,##0.00",
  532. 417: "[$ANG]\\ #,##0.00",
  533. 418: "[$AOA]\\ #,##0.00",
  534. 419: "[$ARS]\\ #,##0.00",
  535. 420: "[$ATS]\\ #,##0.00",
  536. 421: "[$AUD]\\ #,##0.00",
  537. 422: "[$AWG]\\ #,##0.00",
  538. 423: "[$AZM]\\ #,##0.00",
  539. 424: "[$AZN]\\ #,##0.00",
  540. 425: "[$BAM]\\ #,##0.00",
  541. 426: "[$BBD]\\ #,##0.00",
  542. 427: "[$BDT]\\ #,##0.00",
  543. 428: "[$BEF]\\ #,##0.00",
  544. 429: "[$BGL]\\ #,##0.00",
  545. 430: "[$BGN]\\ #,##0.00",
  546. 431: "[$BHD]\\ #,##0.00",
  547. 432: "[$BIF]\\ #,##0.00",
  548. 433: "[$BMD]\\ #,##0.00",
  549. 434: "[$BND]\\ #,##0.00",
  550. 435: "[$BOB]\\ #,##0.00",
  551. 436: "[$BOV]\\ #,##0.00",
  552. 437: "[$BRL]\\ #,##0.00",
  553. 438: "[$BSD]\\ #,##0.00",
  554. 439: "[$BTN]\\ #,##0.00",
  555. 440: "[$BWP]\\ #,##0.00",
  556. 441: "[$BYR]\\ #,##0.00",
  557. 442: "[$BZD]\\ #,##0.00",
  558. 443: "[$CAD]\\ #,##0.00",
  559. 444: "[$CDF]\\ #,##0.00",
  560. 445: "[$CHE]\\ #,##0.00",
  561. 446: "[$CHF]\\ #,##0.00",
  562. 447: "[$CHW]\\ #,##0.00",
  563. 448: "[$CLF]\\ #,##0.00",
  564. 449: "[$CLP]\\ #,##0.00",
  565. 450: "[$CNY]\\ #,##0.00",
  566. 451: "[$COP]\\ #,##0.00",
  567. 452: "[$COU]\\ #,##0.00",
  568. 453: "[$CRC]\\ #,##0.00",
  569. 454: "[$CSD]\\ #,##0.00",
  570. 455: "[$CUC]\\ #,##0.00",
  571. 456: "[$CVE]\\ #,##0.00",
  572. 457: "[$CYP]\\ #,##0.00",
  573. 458: "[$CZK]\\ #,##0.00",
  574. 459: "[$DEM]\\ #,##0.00",
  575. 460: "[$DJF]\\ #,##0.00",
  576. 461: "[$DKK]\\ #,##0.00",
  577. 462: "[$DOP]\\ #,##0.00",
  578. 463: "[$DZD]\\ #,##0.00",
  579. 464: "[$ECS]\\ #,##0.00",
  580. 465: "[$ECV]\\ #,##0.00",
  581. 466: "[$EEK]\\ #,##0.00",
  582. 467: "[$EGP]\\ #,##0.00",
  583. 468: "[$ERN]\\ #,##0.00",
  584. 469: "[$ESP]\\ #,##0.00",
  585. 470: "[$ETB]\\ #,##0.00",
  586. 471: "[$EUR]\\ #,##0.00",
  587. 472: "[$FIM]\\ #,##0.00",
  588. 473: "[$FJD]\\ #,##0.00",
  589. 474: "[$FKP]\\ #,##0.00",
  590. 475: "[$FRF]\\ #,##0.00",
  591. 476: "[$GBP]\\ #,##0.00",
  592. 477: "[$GEL]\\ #,##0.00",
  593. 478: "[$GHC]\\ #,##0.00",
  594. 479: "[$GHS]\\ #,##0.00",
  595. 480: "[$GIP]\\ #,##0.00",
  596. 481: "[$GMD]\\ #,##0.00",
  597. 482: "[$GNF]\\ #,##0.00",
  598. 483: "[$GRD]\\ #,##0.00",
  599. 484: "[$GTQ]\\ #,##0.00",
  600. 485: "[$GYD]\\ #,##0.00",
  601. 486: "[$HKD]\\ #,##0.00",
  602. 487: "[$HNL]\\ #,##0.00",
  603. 488: "[$HRK]\\ #,##0.00",
  604. 489: "[$HTG]\\ #,##0.00",
  605. 490: "[$HUF]\\ #,##0.00",
  606. 491: "[$IDR]\\ #,##0.00",
  607. 492: "[$IEP]\\ #,##0.00",
  608. 493: "[$ILS]\\ #,##0.00",
  609. 494: "[$INR]\\ #,##0.00",
  610. 495: "[$IQD]\\ #,##0.00",
  611. 496: "[$IRR]\\ #,##0.00",
  612. 497: "[$ISK]\\ #,##0.00",
  613. 498: "[$ITL]\\ #,##0.00",
  614. 499: "[$JMD]\\ #,##0.00",
  615. 500: "[$JOD]\\ #,##0.00",
  616. 501: "[$JPY]\\ #,##0.00",
  617. 502: "[$KAF]\\ #,##0.00",
  618. 503: "[$KES]\\ #,##0.00",
  619. 504: "[$KGS]\\ #,##0.00",
  620. 505: "[$KHR]\\ #,##0.00",
  621. 506: "[$KMF]\\ #,##0.00",
  622. 507: "[$KPW]\\ #,##0.00",
  623. 508: "[$KRW]\\ #,##0.00",
  624. 509: "[$KWD]\\ #,##0.00",
  625. 510: "[$KYD]\\ #,##0.00",
  626. 511: "[$KZT]\\ #,##0.00",
  627. 512: "[$LAK]\\ #,##0.00",
  628. 513: "[$LBP]\\ #,##0.00",
  629. 514: "[$LKR]\\ #,##0.00",
  630. 515: "[$LRD]\\ #,##0.00",
  631. 516: "[$LSL]\\ #,##0.00",
  632. 517: "[$LTL]\\ #,##0.00",
  633. 518: "[$LUF]\\ #,##0.00",
  634. 519: "[$LVL]\\ #,##0.00",
  635. 520: "[$LYD]\\ #,##0.00",
  636. 521: "[$MAD]\\ #,##0.00",
  637. 522: "[$MDL]\\ #,##0.00",
  638. 523: "[$MGA]\\ #,##0.00",
  639. 524: "[$MGF]\\ #,##0.00",
  640. 525: "[$MKD]\\ #,##0.00",
  641. 526: "[$MMK]\\ #,##0.00",
  642. 527: "[$MNT]\\ #,##0.00",
  643. 528: "[$MOP]\\ #,##0.00",
  644. 529: "[$MRO]\\ #,##0.00",
  645. 530: "[$MTL]\\ #,##0.00",
  646. 531: "[$MUR]\\ #,##0.00",
  647. 532: "[$MVR]\\ #,##0.00",
  648. 533: "[$MWK]\\ #,##0.00",
  649. 534: "[$MXN]\\ #,##0.00",
  650. 535: "[$MXV]\\ #,##0.00",
  651. 536: "[$MYR]\\ #,##0.00",
  652. 537: "[$MZM]\\ #,##0.00",
  653. 538: "[$MZN]\\ #,##0.00",
  654. 539: "[$NAD]\\ #,##0.00",
  655. 540: "[$NGN]\\ #,##0.00",
  656. 541: "[$NIO]\\ #,##0.00",
  657. 542: "[$NLG]\\ #,##0.00",
  658. 543: "[$NOK]\\ #,##0.00",
  659. 544: "[$NPR]\\ #,##0.00",
  660. 545: "[$NTD]\\ #,##0.00",
  661. 546: "[$NZD]\\ #,##0.00",
  662. 547: "[$OMR]\\ #,##0.00",
  663. 548: "[$PAB]\\ #,##0.00",
  664. 549: "[$PEN]\\ #,##0.00",
  665. 550: "[$PGK]\\ #,##0.00",
  666. 551: "[$PHP]\\ #,##0.00",
  667. 552: "[$PKR]\\ #,##0.00",
  668. 553: "[$PLN]\\ #,##0.00",
  669. 554: "[$PTE]\\ #,##0.00",
  670. 555: "[$PYG]\\ #,##0.00",
  671. 556: "[$QAR]\\ #,##0.00",
  672. 557: "[$ROL]\\ #,##0.00",
  673. 558: "[$RON]\\ #,##0.00",
  674. 559: "[$RSD]\\ #,##0.00",
  675. 560: "[$RUB]\\ #,##0.00",
  676. 561: "[$RUR]\\ #,##0.00",
  677. 562: "[$RWF]\\ #,##0.00",
  678. 563: "[$SAR]\\ #,##0.00",
  679. 564: "[$SBD]\\ #,##0.00",
  680. 565: "[$SCR]\\ #,##0.00",
  681. 566: "[$SDD]\\ #,##0.00",
  682. 567: "[$SDG]\\ #,##0.00",
  683. 568: "[$SDP]\\ #,##0.00",
  684. 569: "[$SEK]\\ #,##0.00",
  685. 570: "[$SGD]\\ #,##0.00",
  686. 571: "[$SHP]\\ #,##0.00",
  687. 572: "[$SIT]\\ #,##0.00",
  688. 573: "[$SKK]\\ #,##0.00",
  689. 574: "[$SLL]\\ #,##0.00",
  690. 575: "[$SOS]\\ #,##0.00",
  691. 576: "[$SPL]\\ #,##0.00",
  692. 577: "[$SRD]\\ #,##0.00",
  693. 578: "[$SRG]\\ #,##0.00",
  694. 579: "[$STD]\\ #,##0.00",
  695. 580: "[$SVC]\\ #,##0.00",
  696. 581: "[$SYP]\\ #,##0.00",
  697. 582: "[$SZL]\\ #,##0.00",
  698. 583: "[$THB]\\ #,##0.00",
  699. 584: "[$TJR]\\ #,##0.00",
  700. 585: "[$TJS]\\ #,##0.00",
  701. 586: "[$TMM]\\ #,##0.00",
  702. 587: "[$TMT]\\ #,##0.00",
  703. 588: "[$TND]\\ #,##0.00",
  704. 589: "[$TOP]\\ #,##0.00",
  705. 590: "[$TRL]\\ #,##0.00",
  706. 591: "[$TRY]\\ #,##0.00",
  707. 592: "[$TTD]\\ #,##0.00",
  708. 593: "[$TWD]\\ #,##0.00",
  709. 594: "[$TZS]\\ #,##0.00",
  710. 595: "[$UAH]\\ #,##0.00",
  711. 596: "[$UGX]\\ #,##0.00",
  712. 597: "[$USD]\\ #,##0.00",
  713. 598: "[$USN]\\ #,##0.00",
  714. 599: "[$USS]\\ #,##0.00",
  715. 600: "[$UYI]\\ #,##0.00",
  716. 601: "[$UYU]\\ #,##0.00",
  717. 602: "[$UZS]\\ #,##0.00",
  718. 603: "[$VEB]\\ #,##0.00",
  719. 604: "[$VEF]\\ #,##0.00",
  720. 605: "[$VND]\\ #,##0.00",
  721. 606: "[$VUV]\\ #,##0.00",
  722. 607: "[$WST]\\ #,##0.00",
  723. 608: "[$XAF]\\ #,##0.00",
  724. 609: "[$XAG]\\ #,##0.00",
  725. 610: "[$XAU]\\ #,##0.00",
  726. 611: "[$XB5]\\ #,##0.00",
  727. 612: "[$XBA]\\ #,##0.00",
  728. 613: "[$XBB]\\ #,##0.00",
  729. 614: "[$XBC]\\ #,##0.00",
  730. 615: "[$XBD]\\ #,##0.00",
  731. 616: "[$XCD]\\ #,##0.00",
  732. 617: "[$XDR]\\ #,##0.00",
  733. 618: "[$XFO]\\ #,##0.00",
  734. 619: "[$XFU]\\ #,##0.00",
  735. 620: "[$XOF]\\ #,##0.00",
  736. 621: "[$XPD]\\ #,##0.00",
  737. 622: "[$XPF]\\ #,##0.00",
  738. 623: "[$XPT]\\ #,##0.00",
  739. 624: "[$XTS]\\ #,##0.00",
  740. 625: "[$XXX]\\ #,##0.00",
  741. 626: "[$YER]\\ #,##0.00",
  742. 627: "[$YUM]\\ #,##0.00",
  743. 628: "[$ZAR]\\ #,##0.00",
  744. 629: "[$ZMK]\\ #,##0.00",
  745. 630: "[$ZMW]\\ #,##0.00",
  746. 631: "[$ZWD]\\ #,##0.00",
  747. 632: "[$ZWL]\\ #,##0.00",
  748. 633: "[$ZWN]\\ #,##0.00",
  749. 634: "[$ZWR]\\ #,##0.00",
  750. }
  751. // builtInNumFmtFunc defined the format conversion functions map. Partial format
  752. // code doesn't support currently and will return original string.
  753. var builtInNumFmtFunc = map[int]func(v string, format string) string{
  754. 0: formatToString,
  755. 1: formatToInt,
  756. 2: formatToFloat,
  757. 3: formatToInt,
  758. 4: formatToFloat,
  759. 9: formatToC,
  760. 10: formatToD,
  761. 11: formatToE,
  762. 12: formatToString, // Doesn't support currently
  763. 13: formatToString, // Doesn't support currently
  764. 14: parseTime,
  765. 15: parseTime,
  766. 16: parseTime,
  767. 17: parseTime,
  768. 18: parseTime,
  769. 19: parseTime,
  770. 20: parseTime,
  771. 21: parseTime,
  772. 22: parseTime,
  773. 37: formatToA,
  774. 38: formatToA,
  775. 39: formatToB,
  776. 40: formatToB,
  777. 41: formatToString, // Doesn't support currently
  778. 42: formatToString, // Doesn't support currently
  779. 43: formatToString, // Doesn't support currently
  780. 44: formatToString, // Doesn't support currently
  781. 45: parseTime,
  782. 46: parseTime,
  783. 47: parseTime,
  784. 48: formatToE,
  785. 49: formatToString,
  786. }
  787. // validType defined the list of valid validation types.
  788. var validType = map[string]string{
  789. "cell": "cellIs",
  790. "date": "date", // Doesn't support currently
  791. "time": "time", // Doesn't support currently
  792. "average": "aboveAverage",
  793. "duplicate": "duplicateValues",
  794. "unique": "uniqueValues",
  795. "top": "top10",
  796. "bottom": "top10",
  797. "text": "text", // Doesn't support currently
  798. "time_period": "timePeriod", // Doesn't support currently
  799. "blanks": "containsBlanks", // Doesn't support currently
  800. "no_blanks": "notContainsBlanks", // Doesn't support currently
  801. "errors": "containsErrors", // Doesn't support currently
  802. "no_errors": "notContainsErrors", // Doesn't support currently
  803. "2_color_scale": "2_color_scale",
  804. "3_color_scale": "3_color_scale",
  805. "data_bar": "dataBar",
  806. "formula": "expression",
  807. }
  808. // criteriaType defined the list of valid criteria types.
  809. var criteriaType = map[string]string{
  810. "between": "between",
  811. "not between": "notBetween",
  812. "equal to": "equal",
  813. "=": "equal",
  814. "==": "equal",
  815. "not equal to": "notEqual",
  816. "!=": "notEqual",
  817. "<>": "notEqual",
  818. "greater than": "greaterThan",
  819. ">": "greaterThan",
  820. "less than": "lessThan",
  821. "<": "lessThan",
  822. "greater than or equal to": "greaterThanOrEqual",
  823. ">=": "greaterThanOrEqual",
  824. "less than or equal to": "lessThanOrEqual",
  825. "<=": "lessThanOrEqual",
  826. "containing": "containsText",
  827. "not containing": "notContains",
  828. "begins with": "beginsWith",
  829. "ends with": "endsWith",
  830. "yesterday": "yesterday",
  831. "today": "today",
  832. "last 7 days": "last7Days",
  833. "last week": "lastWeek",
  834. "this week": "thisWeek",
  835. "continue week": "continueWeek",
  836. "last month": "lastMonth",
  837. "this month": "thisMonth",
  838. "continue month": "continueMonth",
  839. }
  840. // formatToString provides a function to return original string by given
  841. // built-in number formats code and cell string.
  842. func formatToString(v string, format string) string {
  843. return v
  844. }
  845. // formatToInt provides a function to convert original string to integer
  846. // format as string type by given built-in number formats code and cell
  847. // string.
  848. func formatToInt(v string, format string) string {
  849. f, err := strconv.ParseFloat(v, 64)
  850. if err != nil {
  851. return v
  852. }
  853. return fmt.Sprintf("%d", int64(f))
  854. }
  855. // formatToFloat provides a function to convert original string to float
  856. // format as string type by given built-in number formats code and cell
  857. // string.
  858. func formatToFloat(v string, format string) string {
  859. f, err := strconv.ParseFloat(v, 64)
  860. if err != nil {
  861. return v
  862. }
  863. return fmt.Sprintf("%.2f", f)
  864. }
  865. // formatToA provides a function to convert original string to special format
  866. // as string type by given built-in number formats code and cell string.
  867. func formatToA(v string, format string) string {
  868. f, err := strconv.ParseFloat(v, 64)
  869. if err != nil {
  870. return v
  871. }
  872. if f < 0 {
  873. t := int(math.Abs(f))
  874. return fmt.Sprintf("(%d)", t)
  875. }
  876. t := int(f)
  877. return fmt.Sprintf("%d", t)
  878. }
  879. // formatToB provides a function to convert original string to special format
  880. // as string type by given built-in number formats code and cell string.
  881. func formatToB(v string, format string) string {
  882. f, err := strconv.ParseFloat(v, 64)
  883. if err != nil {
  884. return v
  885. }
  886. if f < 0 {
  887. return fmt.Sprintf("(%.2f)", f)
  888. }
  889. return fmt.Sprintf("%.2f", f)
  890. }
  891. // formatToC provides a function to convert original string to special format
  892. // as string type by given built-in number formats code and cell string.
  893. func formatToC(v string, format string) string {
  894. f, err := strconv.ParseFloat(v, 64)
  895. if err != nil {
  896. return v
  897. }
  898. f = f * 100
  899. return fmt.Sprintf("%.f%%", f)
  900. }
  901. // formatToD provides a function to convert original string to special format
  902. // as string type by given built-in number formats code and cell string.
  903. func formatToD(v string, format string) string {
  904. f, err := strconv.ParseFloat(v, 64)
  905. if err != nil {
  906. return v
  907. }
  908. f = f * 100
  909. return fmt.Sprintf("%.2f%%", f)
  910. }
  911. // formatToE provides a function to convert original string to special format
  912. // as string type by given built-in number formats code and cell string.
  913. func formatToE(v string, format string) string {
  914. f, err := strconv.ParseFloat(v, 64)
  915. if err != nil {
  916. return v
  917. }
  918. return fmt.Sprintf("%.e", f)
  919. }
  920. var dateTimeFormatsCache = map[string]string{}
  921. // parseTime provides a function to returns a string parsed using time.Time.
  922. // Replace Excel placeholders with Go time placeholders. For example, replace
  923. // yyyy with 2006. These are in a specific order, due to the fact that m is
  924. // used in month, minute, and am/pm. It would be easier to fix that with
  925. // regular expressions, but if it's possible to keep this simple it would be
  926. // easier to maintain. Full-length month and days (e.g. March, Tuesday) have
  927. // letters in them that would be replaced by other characters below (such as
  928. // the 'h' in March, or the 'd' in Tuesday) below. First we convert them to
  929. // arbitrary characters unused in Excel Date formats, and then at the end,
  930. // turn them to what they should actually be. Based off:
  931. // http://www.ozgrid.com/Excel/CustomFormats.htm
  932. func parseTime(v string, format string) string {
  933. var (
  934. f float64
  935. err error
  936. goFmt string
  937. )
  938. f, err = strconv.ParseFloat(v, 64)
  939. if err != nil {
  940. return v
  941. }
  942. val := timeFromExcelTime(f, false)
  943. if format == "" {
  944. return v
  945. }
  946. goFmt, found := dateTimeFormatsCache[format]
  947. if found {
  948. return val.Format(goFmt)
  949. }
  950. goFmt = format
  951. if strings.Contains(goFmt, "[") {
  952. var re = regexp.MustCompile(`\[.+\]`)
  953. goFmt = re.ReplaceAllLiteralString(goFmt, "")
  954. }
  955. // use only first variant
  956. if strings.Contains(goFmt, ";") {
  957. goFmt = goFmt[:strings.IndexByte(goFmt, ';')]
  958. }
  959. replacements := []struct{ xltime, gotime string }{
  960. {"YYYY", "2006"},
  961. {"YY", "06"},
  962. {"MM", "01"},
  963. {"M", "1"},
  964. {"DD", "02"},
  965. {"D", "2"},
  966. {"yyyy", "2006"},
  967. {"yy", "06"},
  968. {"mmmm", "%%%%"},
  969. {"dddd", "&&&&"},
  970. {"dd", "02"},
  971. {"d", "2"},
  972. {"mmm", "Jan"},
  973. {"mmss", "0405"},
  974. {"ss", "05"},
  975. {"s", "5"},
  976. {"mm:", "04:"},
  977. {":mm", ":04"},
  978. {"m:", "4:"},
  979. {":m", ":4"},
  980. {"mm", "01"},
  981. {"am/pm", "pm"},
  982. {"m/", "1/"},
  983. {"%%%%", "January"},
  984. {"&&&&", "Monday"},
  985. }
  986. replacementsGlobal := []struct{ xltime, gotime string }{
  987. {"\\-", "-"},
  988. {"\\ ", " "},
  989. {"\\.", "."},
  990. {"\\", ""},
  991. }
  992. // It is the presence of the "am/pm" indicator that determines if this is
  993. // a 12 hour or 24 hours time format, not the number of 'h' characters.
  994. if is12HourTime(format) {
  995. goFmt = strings.Replace(goFmt, "hh", "3", 1)
  996. goFmt = strings.Replace(goFmt, "h", "3", 1)
  997. goFmt = strings.Replace(goFmt, "HH", "3", 1)
  998. goFmt = strings.Replace(goFmt, "H", "3", 1)
  999. } else {
  1000. goFmt = strings.Replace(goFmt, "hh", "15", 1)
  1001. goFmt = strings.Replace(goFmt, "h", "3", 1)
  1002. goFmt = strings.Replace(goFmt, "HH", "15", 1)
  1003. goFmt = strings.Replace(goFmt, "H", "3", 1)
  1004. }
  1005. for _, repl := range replacements {
  1006. goFmt = strings.Replace(goFmt, repl.xltime, repl.gotime, 1)
  1007. }
  1008. for _, repl := range replacementsGlobal {
  1009. goFmt = strings.Replace(goFmt, repl.xltime, repl.gotime, -1)
  1010. }
  1011. // If the hour is optional, strip it out, along with the possible dangling
  1012. // colon that would remain.
  1013. if val.Hour() < 1 {
  1014. goFmt = strings.Replace(goFmt, "]:", "]", 1)
  1015. goFmt = strings.Replace(goFmt, "[03]", "", 1)
  1016. goFmt = strings.Replace(goFmt, "[3]", "", 1)
  1017. goFmt = strings.Replace(goFmt, "[15]", "", 1)
  1018. } else {
  1019. goFmt = strings.Replace(goFmt, "[3]", "3", 1)
  1020. goFmt = strings.Replace(goFmt, "[15]", "15", 1)
  1021. }
  1022. dateTimeFormatsCache[format] = goFmt
  1023. return val.Format(goFmt)
  1024. }
  1025. // is12HourTime checks whether an Excel time format string is a 12 hours form.
  1026. func is12HourTime(format string) bool {
  1027. return strings.Contains(format, "am/pm") || strings.Contains(format, "AM/PM") || strings.Contains(format, "a/p") || strings.Contains(format, "A/P")
  1028. }
  1029. // stylesReader provides a function to get the pointer to the structure after
  1030. // deserialization of xl/styles.xml.
  1031. func (f *File) stylesReader() *xlsxStyleSheet {
  1032. var err error
  1033. if f.Styles == nil {
  1034. f.Styles = new(xlsxStyleSheet)
  1035. if err = f.xmlNewDecoder(bytes.NewReader(namespaceStrictToTransitional(f.readXML("xl/styles.xml")))).
  1036. Decode(f.Styles); err != nil && err != io.EOF {
  1037. log.Printf("xml decode error: %s", err)
  1038. }
  1039. }
  1040. return f.Styles
  1041. }
  1042. // styleSheetWriter provides a function to save xl/styles.xml after serialize
  1043. // structure.
  1044. func (f *File) styleSheetWriter() {
  1045. if f.Styles != nil {
  1046. output, _ := xml.Marshal(f.Styles)
  1047. f.saveFileList("xl/styles.xml", f.replaceNameSpaceBytes("xl/styles.xml", output))
  1048. }
  1049. }
  1050. // sharedStringsWriter provides a function to save xl/sharedStrings.xml after
  1051. // serialize structure.
  1052. func (f *File) sharedStringsWriter() {
  1053. if f.SharedStrings != nil {
  1054. output, _ := xml.Marshal(f.SharedStrings)
  1055. f.saveFileList("xl/sharedStrings.xml", f.replaceNameSpaceBytes("xl/sharedStrings.xml", output))
  1056. }
  1057. }
  1058. // parseFormatStyleSet provides a function to parse the format settings of the
  1059. // cells and conditional formats.
  1060. func parseFormatStyleSet(style interface{}) (*Style, error) {
  1061. fs := Style{}
  1062. var err error
  1063. switch v := style.(type) {
  1064. case string:
  1065. err = json.Unmarshal([]byte(v), &fs)
  1066. case *Style:
  1067. fs = *v
  1068. default:
  1069. err = errors.New("invalid parameter type")
  1070. }
  1071. if fs.Font != nil {
  1072. if len(fs.Font.Family) > MaxFontFamilyLength {
  1073. return &fs, errors.New("the length of the font family name must be smaller than or equal to 31")
  1074. }
  1075. if fs.Font.Size > MaxFontSize {
  1076. return &fs, errors.New("font size must be between 1 and 409 points")
  1077. }
  1078. }
  1079. return &fs, err
  1080. }
  1081. // NewStyle provides a function to create the style for cells by given JSON or
  1082. // structure pointer. Note that the color field uses RGB color code.
  1083. //
  1084. // The following shows the border styles sorted by excelize index number:
  1085. //
  1086. // Index | Name | Weight | Style
  1087. // -------+---------------+--------+-------------
  1088. // 0 | None | 0 |
  1089. // 1 | Continuous | 1 | -----------
  1090. // 2 | Continuous | 2 | -----------
  1091. // 3 | Dash | 1 | - - - - - -
  1092. // 4 | Dot | 1 | . . . . . .
  1093. // 5 | Continuous | 3 | -----------
  1094. // 6 | Double | 3 | ===========
  1095. // 7 | Continuous | 0 | -----------
  1096. // 8 | Dash | 2 | - - - - - -
  1097. // 9 | Dash Dot | 1 | - . - . - .
  1098. // 10 | Dash Dot | 2 | - . - . - .
  1099. // 11 | Dash Dot Dot | 1 | - . . - . .
  1100. // 12 | Dash Dot Dot | 2 | - . . - . .
  1101. // 13 | SlantDash Dot | 2 | / - . / - .
  1102. //
  1103. // The following shows the borders in the order shown in the Excel dialog:
  1104. //
  1105. // Index | Style | Index | Style
  1106. // -------+-------------+-------+-------------
  1107. // 0 | None | 12 | - . . - . .
  1108. // 7 | ----------- | 13 | / - . / - .
  1109. // 4 | . . . . . . | 10 | - . - . - .
  1110. // 11 | - . . - . . | 8 | - - - - - -
  1111. // 9 | - . - . - . | 2 | -----------
  1112. // 3 | - - - - - - | 5 | -----------
  1113. // 1 | ----------- | 6 | ===========
  1114. //
  1115. // The following shows the shading styles sorted by excelize index number:
  1116. //
  1117. // Index | Style | Index | Style
  1118. // -------+-----------------+-------+-----------------
  1119. // 0 | Horizontal | 3 | Diagonal down
  1120. // 1 | Vertical | 4 | From corner
  1121. // 2 | Diagonal Up | 5 | From center
  1122. //
  1123. // The following shows the patterns styles sorted by excelize index number:
  1124. //
  1125. // Index | Style | Index | Style
  1126. // -------+-----------------+-------+-----------------
  1127. // 0 | None | 10 | darkTrellis
  1128. // 1 | solid | 11 | lightHorizontal
  1129. // 2 | mediumGray | 12 | lightVertical
  1130. // 3 | darkGray | 13 | lightDown
  1131. // 4 | lightGray | 14 | lightUp
  1132. // 5 | darkHorizontal | 15 | lightGrid
  1133. // 6 | darkVertical | 16 | lightTrellis
  1134. // 7 | darkDown | 17 | gray125
  1135. // 8 | darkUp | 18 | gray0625
  1136. // 9 | darkGrid | |
  1137. //
  1138. // The following the type of horizontal alignment in cells:
  1139. //
  1140. // Style
  1141. // ------------------
  1142. // left
  1143. // center
  1144. // right
  1145. // fill
  1146. // justify
  1147. // centerContinuous
  1148. // distributed
  1149. //
  1150. // The following the type of vertical alignment in cells:
  1151. //
  1152. // Style
  1153. // ------------------
  1154. // top
  1155. // center
  1156. // justify
  1157. // distributed
  1158. //
  1159. // The following the type of font underline style:
  1160. //
  1161. // Style
  1162. // ------------------
  1163. // single
  1164. // double
  1165. //
  1166. // Excel's built-in all languages formats are shown in the following table:
  1167. //
  1168. // Index | Format String
  1169. // -------+----------------------------------------------------
  1170. // 0 | General
  1171. // 1 | 0
  1172. // 2 | 0.00
  1173. // 3 | #,##0
  1174. // 4 | #,##0.00
  1175. // 5 | ($#,##0_);($#,##0)
  1176. // 6 | ($#,##0_);[Red]($#,##0)
  1177. // 7 | ($#,##0.00_);($#,##0.00)
  1178. // 8 | ($#,##0.00_);[Red]($#,##0.00)
  1179. // 9 | 0%
  1180. // 10 | 0.00%
  1181. // 11 | 0.00E+00
  1182. // 12 | # ?/?
  1183. // 13 | # ??/??
  1184. // 14 | m/d/yy
  1185. // 15 | d-mmm-yy
  1186. // 16 | d-mmm
  1187. // 17 | mmm-yy
  1188. // 18 | h:mm AM/PM
  1189. // 19 | h:mm:ss AM/PM
  1190. // 20 | h:mm
  1191. // 21 | h:mm:ss
  1192. // 22 | m/d/yy h:mm
  1193. // ... | ...
  1194. // 37 | (#,##0_);(#,##0)
  1195. // 38 | (#,##0_);[Red](#,##0)
  1196. // 39 | (#,##0.00_);(#,##0.00)
  1197. // 40 | (#,##0.00_);[Red](#,##0.00)
  1198. // 41 | _(* #,##0_);_(* (#,##0);_(* "-"_);_(@_)
  1199. // 42 | _($* #,##0_);_($* (#,##0);_($* "-"_);_(@_)
  1200. // 43 | _(* #,##0.00_);_(* (#,##0.00);_(* "-"??_);_(@_)
  1201. // 44 | _($* #,##0.00_);_($* (#,##0.00);_($* "-"??_);_(@_)
  1202. // 45 | mm:ss
  1203. // 46 | [h]:mm:ss
  1204. // 47 | mm:ss.0
  1205. // 48 | ##0.0E+0
  1206. // 49 | @
  1207. //
  1208. // Number format code in zh-tw language:
  1209. //
  1210. // Index | Symbol
  1211. // -------+-------------------------------------------
  1212. // 27 | [$-404]e/m/d
  1213. // 28 | [$-404]e"年"m"月"d"日"
  1214. // 29 | [$-404]e"年"m"月"d"日"
  1215. // 30 | m/d/yy
  1216. // 31 | yyyy"年"m"月"d"日"
  1217. // 32 | hh"時"mm"分"
  1218. // 33 | hh"時"mm"分"ss"秒"
  1219. // 34 | 上午/下午 hh"時"mm"分"
  1220. // 35 | 上午/下午 hh"時"mm"分"ss"秒"
  1221. // 36 | [$-404]e/m/d
  1222. // 50 | [$-404]e/m/d
  1223. // 51 | [$-404]e"年"m"月"d"日"
  1224. // 52 | 上午/下午 hh"時"mm"分"
  1225. // 53 | 上午/下午 hh"時"mm"分"ss"秒"
  1226. // 54 | [$-404]e"年"m"月"d"日"
  1227. // 55 | 上午/下午 hh"時"mm"分"
  1228. // 56 | 上午/下午 hh"時"mm"分"ss"秒"
  1229. // 57 | [$-404]e/m/d
  1230. // 58 | [$-404]e"年"m"月"d"日"
  1231. //
  1232. // Number format code in zh-cn language:
  1233. //
  1234. // Index | Symbol
  1235. // -------+-------------------------------------------
  1236. // 27 | yyyy"年"m"月"
  1237. // 28 | m"月"d"日"
  1238. // 29 | m"月"d"日"
  1239. // 30 | m-d-yy
  1240. // 31 | yyyy"年"m"月"d"日"
  1241. // 32 | h"时"mm"分"
  1242. // 33 | h"时"mm"分"ss"秒"
  1243. // 34 | 上午/下午 h"时"mm"分"
  1244. // 35 | 上午/下午 h"时"mm"分"ss"秒
  1245. // 36 | yyyy"年"m"月
  1246. // 50 | yyyy"年"m"月
  1247. // 51 | m"月"d"日
  1248. // 52 | yyyy"年"m"月
  1249. // 53 | m"月"d"日
  1250. // 54 | m"月"d"日
  1251. // 55 | 上午/下午 h"时"mm"分
  1252. // 56 | 上午/下午 h"时"mm"分"ss"秒
  1253. // 57 | yyyy"年"m"月
  1254. // 58 | m"月"d"日"
  1255. //
  1256. // Number format code with unicode values provided for language glyphs where
  1257. // they occur in zh-tw language:
  1258. //
  1259. // Index | Symbol
  1260. // -------+-------------------------------------------
  1261. // 27 | [$-404]e/m/
  1262. // 28 | [$-404]e"5E74"m"6708"d"65E5
  1263. // 29 | [$-404]e"5E74"m"6708"d"65E5
  1264. // 30 | m/d/y
  1265. // 31 | yyyy"5E74"m"6708"d"65E5
  1266. // 32 | hh"6642"mm"5206
  1267. // 33 | hh"6642"mm"5206"ss"79D2
  1268. // 34 | 4E0A5348/4E0B5348hh"6642"mm"5206
  1269. // 35 | 4E0A5348/4E0B5348hh"6642"mm"5206"ss"79D2
  1270. // 36 | [$-404]e/m/
  1271. // 50 | [$-404]e/m/
  1272. // 51 | [$-404]e"5E74"m"6708"d"65E5
  1273. // 52 | 4E0A5348/4E0B5348hh"6642"mm"5206
  1274. // 53 | 4E0A5348/4E0B5348hh"6642"mm"5206"ss"79D2
  1275. // 54 | [$-404]e"5E74"m"6708"d"65E5
  1276. // 55 | 4E0A5348/4E0B5348hh"6642"mm"5206
  1277. // 56 | 4E0A5348/4E0B5348hh"6642"mm"5206"ss"79D2
  1278. // 57 | [$-404]e/m/
  1279. // 58 | [$-404]e"5E74"m"6708"d"65E5"
  1280. //
  1281. // Number format code with unicode values provided for language glyphs where
  1282. // they occur in zh-cn language:
  1283. //
  1284. // Index | Symbol
  1285. // -------+-------------------------------------------
  1286. // 27 | yyyy"5E74"m"6708
  1287. // 28 | m"6708"d"65E5
  1288. // 29 | m"6708"d"65E5
  1289. // 30 | m-d-y
  1290. // 31 | yyyy"5E74"m"6708"d"65E5
  1291. // 32 | h"65F6"mm"5206
  1292. // 33 | h"65F6"mm"5206"ss"79D2
  1293. // 34 | 4E0A5348/4E0B5348h"65F6"mm"5206
  1294. // 35 | 4E0A5348/4E0B5348h"65F6"mm"5206"ss"79D2
  1295. // 36 | yyyy"5E74"m"6708
  1296. // 50 | yyyy"5E74"m"6708
  1297. // 51 | m"6708"d"65E5
  1298. // 52 | yyyy"5E74"m"6708
  1299. // 53 | m"6708"d"65E5
  1300. // 54 | m"6708"d"65E5
  1301. // 55 | 4E0A5348/4E0B5348h"65F6"mm"5206
  1302. // 56 | 4E0A5348/4E0B5348h"65F6"mm"5206"ss"79D2
  1303. // 57 | yyyy"5E74"m"6708
  1304. // 58 | m"6708"d"65E5"
  1305. //
  1306. // Number format code in ja-jp language:
  1307. //
  1308. // Index | Symbol
  1309. // -------+-------------------------------------------
  1310. // 27 | [$-411]ge.m.d
  1311. // 28 | [$-411]ggge"年"m"月"d"日
  1312. // 29 | [$-411]ggge"年"m"月"d"日
  1313. // 30 | m/d/y
  1314. // 31 | yyyy"年"m"月"d"日
  1315. // 32 | h"時"mm"分
  1316. // 33 | h"時"mm"分"ss"秒
  1317. // 34 | yyyy"年"m"月
  1318. // 35 | m"月"d"日
  1319. // 36 | [$-411]ge.m.d
  1320. // 50 | [$-411]ge.m.d
  1321. // 51 | [$-411]ggge"年"m"月"d"日
  1322. // 52 | yyyy"年"m"月
  1323. // 53 | m"月"d"日
  1324. // 54 | [$-411]ggge"年"m"月"d"日
  1325. // 55 | yyyy"年"m"月
  1326. // 56 | m"月"d"日
  1327. // 57 | [$-411]ge.m.d
  1328. // 58 | [$-411]ggge"年"m"月"d"日"
  1329. //
  1330. // Number format code in ko-kr language:
  1331. //
  1332. // Index | Symbol
  1333. // -------+-------------------------------------------
  1334. // 27 | yyyy"年" mm"月" dd"日
  1335. // 28 | mm-d
  1336. // 29 | mm-d
  1337. // 30 | mm-dd-y
  1338. // 31 | yyyy"년" mm"월" dd"일
  1339. // 32 | h"시" mm"분
  1340. // 33 | h"시" mm"분" ss"초
  1341. // 34 | yyyy-mm-d
  1342. // 35 | yyyy-mm-d
  1343. // 36 | yyyy"年" mm"月" dd"日
  1344. // 50 | yyyy"年" mm"月" dd"日
  1345. // 51 | mm-d
  1346. // 52 | yyyy-mm-d
  1347. // 53 | yyyy-mm-d
  1348. // 54 | mm-d
  1349. // 55 | yyyy-mm-d
  1350. // 56 | yyyy-mm-d
  1351. // 57 | yyyy"年" mm"月" dd"日
  1352. // 58 | mm-dd
  1353. //
  1354. // Number format code with unicode values provided for language glyphs where
  1355. // they occur in ja-jp language:
  1356. //
  1357. // Index | Symbol
  1358. // -------+-------------------------------------------
  1359. // 27 | [$-411]ge.m.d
  1360. // 28 | [$-411]ggge"5E74"m"6708"d"65E5
  1361. // 29 | [$-411]ggge"5E74"m"6708"d"65E5
  1362. // 30 | m/d/y
  1363. // 31 | yyyy"5E74"m"6708"d"65E5
  1364. // 32 | h"6642"mm"5206
  1365. // 33 | h"6642"mm"5206"ss"79D2
  1366. // 34 | yyyy"5E74"m"6708
  1367. // 35 | m"6708"d"65E5
  1368. // 36 | [$-411]ge.m.d
  1369. // 50 | [$-411]ge.m.d
  1370. // 51 | [$-411]ggge"5E74"m"6708"d"65E5
  1371. // 52 | yyyy"5E74"m"6708
  1372. // 53 | m"6708"d"65E5
  1373. // 54 | [$-411]ggge"5E74"m"6708"d"65E5
  1374. // 55 | yyyy"5E74"m"6708
  1375. // 56 | m"6708"d"65E5
  1376. // 57 | [$-411]ge.m.d
  1377. // 58 | [$-411]ggge"5E74"m"6708"d"65E5"
  1378. //
  1379. // Number format code with unicode values provided for language glyphs where
  1380. // they occur in ko-kr language:
  1381. //
  1382. // Index | Symbol
  1383. // -------+-------------------------------------------
  1384. // 27 | yyyy"5E74" mm"6708" dd"65E5
  1385. // 28 | mm-d
  1386. // 29 | mm-d
  1387. // 30 | mm-dd-y
  1388. // 31 | yyyy"B144" mm"C6D4" dd"C77C
  1389. // 32 | h"C2DC" mm"BD84
  1390. // 33 | h"C2DC" mm"BD84" ss"CD08
  1391. // 34 | yyyy-mm-d
  1392. // 35 | yyyy-mm-d
  1393. // 36 | yyyy"5E74" mm"6708" dd"65E5
  1394. // 50 | yyyy"5E74" mm"6708" dd"65E5
  1395. // 51 | mm-d
  1396. // 52 | yyyy-mm-d
  1397. // 53 | yyyy-mm-d
  1398. // 54 | mm-d
  1399. // 55 | yyyy-mm-d
  1400. // 56 | yyyy-mm-d
  1401. // 57 | yyyy"5E74" mm"6708" dd"65E5
  1402. // 58 | mm-dd
  1403. //
  1404. // Number format code in th-th language:
  1405. //
  1406. // Index | Symbol
  1407. // -------+-------------------------------------------
  1408. // 59 | t
  1409. // 60 | t0.0
  1410. // 61 | t#,##
  1411. // 62 | t#,##0.0
  1412. // 67 | t0
  1413. // 68 | t0.00
  1414. // 69 | t# ?/
  1415. // 70 | t# ??/?
  1416. // 71 | ว/ด/ปปป
  1417. // 72 | ว-ดดด-ป
  1418. // 73 | ว-ดด
  1419. // 74 | ดดด-ป
  1420. // 75 | ช:น
  1421. // 76 | ช:นน:ท
  1422. // 77 | ว/ด/ปปปป ช:น
  1423. // 78 | นน:ท
  1424. // 79 | [ช]:นน:ท
  1425. // 80 | นน:ทท.
  1426. // 81 | d/m/bb
  1427. //
  1428. // Number format code with unicode values provided for language glyphs where
  1429. // they occur in th-th language:
  1430. //
  1431. // Index | Symbol
  1432. // -------+-------------------------------------------
  1433. // 59 | t
  1434. // 60 | t0.0
  1435. // 61 | t#,##
  1436. // 62 | t#,##0.0
  1437. // 67 | t0
  1438. // 68 | t0.00
  1439. // 69 | t# ?/
  1440. // 70 | t# ??/?
  1441. // 71 | 0E27/0E14/0E1B0E1B0E1B0E1
  1442. // 72 | 0E27-0E140E140E14-0E1B0E1
  1443. // 73 | 0E27-0E140E140E1
  1444. // 74 | 0E140E140E14-0E1B0E1
  1445. // 75 | 0E0A:0E190E1
  1446. // 76 | 0E0A:0E190E19:0E170E1
  1447. // 77 | 0E27/0E14/0E1B0E1B0E1B0E1B 0E0A:0E190E1
  1448. // 78 | 0E190E19:0E170E1
  1449. // 79 | [0E0A]:0E190E19:0E170E1
  1450. // 80 | 0E190E19:0E170E17.
  1451. // 81 | d/m/bb
  1452. //
  1453. // Excelize built-in currency formats are shown in the following table, only
  1454. // support these types in the following table (Index number is used only for
  1455. // markup and is not used inside an Excel file and you can't get formatted value
  1456. // by the function GetCellValue) currently:
  1457. //
  1458. // Index | Symbol
  1459. // -------+---------------------------------------------------------------
  1460. // 164 | CN¥
  1461. // 165 | $ English (China)
  1462. // 166 | $ Cherokee (United States)
  1463. // 167 | $ Chinese (Singapore)
  1464. // 168 | $ Chinese (Taiwan)
  1465. // 169 | $ English (Australia)
  1466. // 170 | $ English (Belize)
  1467. // 171 | $ English (Canada)
  1468. // 172 | $ English (Jamaica)
  1469. // 173 | $ English (New Zealand)
  1470. // 174 | $ English (Singapore)
  1471. // 175 | $ English (Trinidad & Tobago)
  1472. // 176 | $ English (U.S. Virgin Islands)
  1473. // 177 | $ English (United States)
  1474. // 178 | $ French (Canada)
  1475. // 179 | $ Hawaiian (United States)
  1476. // 180 | $ Malay (Brunei)
  1477. // 181 | $ Quechua (Ecuador)
  1478. // 182 | $ Spanish (Chile)
  1479. // 183 | $ Spanish (Colombia)
  1480. // 184 | $ Spanish (Ecuador)
  1481. // 185 | $ Spanish (El Salvador)
  1482. // 186 | $ Spanish (Mexico)
  1483. // 187 | $ Spanish (Puerto Rico)
  1484. // 188 | $ Spanish (United States)
  1485. // 189 | $ Spanish (Uruguay)
  1486. // 190 | £ English (United Kingdom)
  1487. // 191 | £ Scottish Gaelic (United Kingdom)
  1488. // 192 | £ Welsh (United Kindom)
  1489. // 193 | ¥ Chinese (China)
  1490. // 194 | ¥ Japanese (Japan)
  1491. // 195 | ¥ Sichuan Yi (China)
  1492. // 196 | ¥ Tibetan (China)
  1493. // 197 | ¥ Uyghur (China)
  1494. // 198 | ֏ Armenian (Armenia)
  1495. // 199 | ؋ Pashto (Afghanistan)
  1496. // 200 | ؋ Persian (Afghanistan)
  1497. // 201 | ৳ Bengali (Bangladesh)
  1498. // 202 | ៛ Khmer (Cambodia)
  1499. // 203 | ₡ Spanish (Costa Rica)
  1500. // 204 | ₦ Hausa (Nigeria)
  1501. // 205 | ₦ Igbo (Nigeria)
  1502. // 206 | ₦ Yoruba (Nigeria)
  1503. // 207 | ₩ Korean (South Korea)
  1504. // 208 | ₪ Hebrew (Israel)
  1505. // 209 | ₫ Vietnamese (Vietnam)
  1506. // 210 | € Basque (Spain)
  1507. // 211 | € Breton (France)
  1508. // 212 | € Catalan (Spain)
  1509. // 213 | € Corsican (France)
  1510. // 214 | € Dutch (Belgium)
  1511. // 215 | € Dutch (Netherlands)
  1512. // 216 | € English (Ireland)
  1513. // 217 | € Estonian (Estonia)
  1514. // 218 | € Euro (€ 123)
  1515. // 219 | € Euro (123 €)
  1516. // 220 | € Finnish (Finland)
  1517. // 221 | € French (Belgium)
  1518. // 222 | € French (France)
  1519. // 223 | € French (Luxembourg)
  1520. // 224 | € French (Monaco)
  1521. // 225 | € French (Réunion)
  1522. // 226 | € Galician (Spain)
  1523. // 227 | € German (Austria)
  1524. // 228 | € German (Luxembourg)
  1525. // 229 | € Greek (Greece)
  1526. // 230 | € Inari Sami (Finland)
  1527. // 231 | € Irish (Ireland)
  1528. // 232 | € Italian (Italy)
  1529. // 233 | € Latin (Italy)
  1530. // 234 | € Latin, Serbian (Montenegro)
  1531. // 235 | € Larvian (Latvia)
  1532. // 236 | € Lithuanian (Lithuania)
  1533. // 237 | € Lower Sorbian (Germany)
  1534. // 238 | € Luxembourgish (Luxembourg)
  1535. // 239 | € Maltese (Malta)
  1536. // 240 | € Northern Sami (Finland)
  1537. // 241 | € Occitan (France)
  1538. // 242 | € Portuguese (Portugal)
  1539. // 243 | € Serbian (Montenegro)
  1540. // 244 | € Skolt Sami (Finland)
  1541. // 245 | € Slovak (Slovakia)
  1542. // 246 | € Slovenian (Slovenia)
  1543. // 247 | € Spanish (Spain)
  1544. // 248 | € Swedish (Finland)
  1545. // 249 | € Swiss German (France)
  1546. // 250 | € Upper Sorbian (Germany)
  1547. // 251 | € Western Frisian (Netherlands)
  1548. // 252 | ₭ Lao (Laos)
  1549. // 253 | ₮ Mongolian (Mongolia)
  1550. // 254 | ₮ Mongolian, Mongolian (Mongolia)
  1551. // 255 | ₱ English (Philippines)
  1552. // 256 | ₱ Filipino (Philippines)
  1553. // 257 | ₴ Ukrainian (Ukraine)
  1554. // 258 | ₸ Kazakh (Kazakhstan)
  1555. // 259 | ₹ Arabic, Kashmiri (India)
  1556. // 260 | ₹ English (India)
  1557. // 261 | ₹ Gujarati (India)
  1558. // 262 | ₹ Hindi (India)
  1559. // 263 | ₹ Kannada (India)
  1560. // 264 | ₹ Kashmiri (India)
  1561. // 265 | ₹ Konkani (India)
  1562. // 266 | ₹ Manipuri (India)
  1563. // 267 | ₹ Marathi (India)
  1564. // 268 | ₹ Nepali (India)
  1565. // 269 | ₹ Oriya (India)
  1566. // 270 | ₹ Punjabi (India)
  1567. // 271 | ₹ Sanskrit (India)
  1568. // 272 | ₹ Sindhi (India)
  1569. // 273 | ₹ Tamil (India)
  1570. // 274 | ₹ Urdu (India)
  1571. // 275 | ₺ Turkish (Turkey)
  1572. // 276 | ₼ Azerbaijani (Azerbaijan)
  1573. // 277 | ₼ Cyrillic, Azerbaijani (Azerbaijan)
  1574. // 278 | ₽ Russian (Russia)
  1575. // 279 | ₽ Sakha (Russia)
  1576. // 280 | ₾ Georgian (Georgia)
  1577. // 281 | B/. Spanish (Panama)
  1578. // 282 | Br Oromo (Ethiopia)
  1579. // 283 | Br Somali (Ethiopia)
  1580. // 284 | Br Tigrinya (Ethiopia)
  1581. // 285 | Bs Quechua (Bolivia)
  1582. // 286 | Bs Spanish (Bolivia)
  1583. // 287 | BS. Spanish (Venezuela)
  1584. // 288 | BWP Tswana (Botswana)
  1585. // 289 | C$ Spanish (Nicaragua)
  1586. // 290 | CA$ Latin, Inuktitut (Canada)
  1587. // 291 | CA$ Mohawk (Canada)
  1588. // 292 | CA$ Unified Canadian Aboriginal Syllabics, Inuktitut (Canada)
  1589. // 293 | CFA French (Mali)
  1590. // 294 | CFA French (Senegal)
  1591. // 295 | CFA Fulah (Senegal)
  1592. // 296 | CFA Wolof (Senegal)
  1593. // 297 | CHF French (Switzerland)
  1594. // 298 | CHF German (Liechtenstein)
  1595. // 299 | CHF German (Switzerland)
  1596. // 300 | CHF Italian (Switzerland)
  1597. // 301 | CHF Romansh (Switzerland)
  1598. // 302 | CLP Mapuche (Chile)
  1599. // 303 | CN¥ Mongolian, Mongolian (China)
  1600. // 304 | DZD Central Atlas Tamazight (Algeria)
  1601. // 305 | FCFA French (Cameroon)
  1602. // 306 | Ft Hungarian (Hungary)
  1603. // 307 | G French (Haiti)
  1604. // 308 | Gs. Spanish (Paraguay)
  1605. // 309 | GTQ K'iche' (Guatemala)
  1606. // 310 | HK$ Chinese (Hong Kong (China))
  1607. // 311 | HK$ English (Hong Kong (China))
  1608. // 312 | HRK Croatian (Croatia)
  1609. // 313 | IDR English (Indonesia)
  1610. // 314 | IQD Arbic, Central Kurdish (Iraq)
  1611. // 315 | ISK Icelandic (Iceland)
  1612. // 316 | K Burmese (Myanmar (Burma))
  1613. // 317 | Kč Czech (Czech Republic)
  1614. // 318 | KM Bosnian (Bosnia & Herzegovina)
  1615. // 319 | KM Croatian (Bosnia & Herzegovina)
  1616. // 320 | KM Latin, Serbian (Bosnia & Herzegovina)
  1617. // 321 | kr Faroese (Faroe Islands)
  1618. // 322 | kr Northern Sami (Norway)
  1619. // 323 | kr Northern Sami (Sweden)
  1620. // 324 | kr Norwegian Bokmål (Norway)
  1621. // 325 | kr Norwegian Nynorsk (Norway)
  1622. // 326 | kr Swedish (Sweden)
  1623. // 327 | kr. Danish (Denmark)
  1624. // 328 | kr. Kalaallisut (Greenland)
  1625. // 329 | Ksh Swahili (kenya)
  1626. // 330 | L Romanian (Moldova)
  1627. // 331 | L Russian (Moldova)
  1628. // 332 | L Spanish (Honduras)
  1629. // 333 | Lekë Albanian (Albania)
  1630. // 334 | MAD Arabic, Central Atlas Tamazight (Morocco)
  1631. // 335 | MAD French (Morocco)
  1632. // 336 | MAD Tifinagh, Central Atlas Tamazight (Morocco)
  1633. // 337 | MOP$ Chinese (Macau (China))
  1634. // 338 | MVR Divehi (Maldives)
  1635. // 339 | Nfk Tigrinya (Eritrea)
  1636. // 340 | NGN Bini (Nigeria)
  1637. // 341 | NGN Fulah (Nigeria)
  1638. // 342 | NGN Ibibio (Nigeria)
  1639. // 343 | NGN Kanuri (Nigeria)
  1640. // 344 | NOK Lule Sami (Norway)
  1641. // 345 | NOK Southern Sami (Norway)
  1642. // 346 | NZ$ Maori (New Zealand)
  1643. // 347 | PKR Sindhi (Pakistan)
  1644. // 348 | PYG Guarani (Paraguay)
  1645. // 349 | Q Spanish (Guatemala)
  1646. // 350 | R Afrikaans (South Africa)
  1647. // 351 | R English (South Africa)
  1648. // 352 | R Zulu (South Africa)
  1649. // 353 | R$ Portuguese (Brazil)
  1650. // 354 | RD$ Spanish (Dominican Republic)
  1651. // 355 | RF Kinyarwanda (Rwanda)
  1652. // 356 | RM English (Malaysia)
  1653. // 357 | RM Malay (Malaysia)
  1654. // 358 | RON Romanian (Romania)
  1655. // 359 | Rp Indonesoan (Indonesia)
  1656. // 360 | Rs Urdu (Pakistan)
  1657. // 361 | Rs. Tamil (Sri Lanka)
  1658. // 362 | RSD Latin, Serbian (Serbia)
  1659. // 363 | RSD Serbian (Serbia)
  1660. // 364 | RUB Bashkir (Russia)
  1661. // 365 | RUB Tatar (Russia)
  1662. // 366 | S/. Quechua (Peru)
  1663. // 367 | S/. Spanish (Peru)
  1664. // 368 | SEK Lule Sami (Sweden)
  1665. // 369 | SEK Southern Sami (Sweden)
  1666. // 370 | soʻm Latin, Uzbek (Uzbekistan)
  1667. // 371 | soʻm Uzbek (Uzbekistan)
  1668. // 372 | SYP Syriac (Syria)
  1669. // 373 | THB Thai (Thailand)
  1670. // 374 | TMT Turkmen (Turkmenistan)
  1671. // 375 | US$ English (Zimbabwe)
  1672. // 376 | ZAR Northern Sotho (South Africa)
  1673. // 377 | ZAR Southern Sotho (South Africa)
  1674. // 378 | ZAR Tsonga (South Africa)
  1675. // 379 | ZAR Tswana (south Africa)
  1676. // 380 | ZAR Venda (South Africa)
  1677. // 381 | ZAR Xhosa (South Africa)
  1678. // 382 | zł Polish (Poland)
  1679. // 383 | ден Macedonian (Macedonia)
  1680. // 384 | KM Cyrillic, Bosnian (Bosnia & Herzegovina)
  1681. // 385 | KM Serbian (Bosnia & Herzegovina)
  1682. // 386 | лв. Bulgarian (Bulgaria)
  1683. // 387 | p. Belarusian (Belarus)
  1684. // 388 | сом Kyrgyz (Kyrgyzstan)
  1685. // 389 | сом Tajik (Tajikistan)
  1686. // 390 | ج.م. Arabic (Egypt)
  1687. // 391 | د.أ. Arabic (Jordan)
  1688. // 392 | د.أ. Arabic (United Arab Emirates)
  1689. // 393 | د.ب. Arabic (Bahrain)
  1690. // 394 | د.ت. Arabic (Tunisia)
  1691. // 395 | د.ج. Arabic (Algeria)
  1692. // 396 | د.ع. Arabic (Iraq)
  1693. // 397 | د.ك. Arabic (Kuwait)
  1694. // 398 | د.ل. Arabic (Libya)
  1695. // 399 | د.م. Arabic (Morocco)
  1696. // 400 | ر Punjabi (Pakistan)
  1697. // 401 | ر.س. Arabic (Saudi Arabia)
  1698. // 402 | ر.ع. Arabic (Oman)
  1699. // 403 | ر.ق. Arabic (Qatar)
  1700. // 404 | ر.ي. Arabic (Yemen)
  1701. // 405 | ریال Persian (Iran)
  1702. // 406 | ل.س. Arabic (Syria)
  1703. // 407 | ل.ل. Arabic (Lebanon)
  1704. // 408 | ብር Amharic (Ethiopia)
  1705. // 409 | रू Nepaol (Nepal)
  1706. // 410 | රු. Sinhala (Sri Lanka)
  1707. // 411 | ADP
  1708. // 412 | AED
  1709. // 413 | AFA
  1710. // 414 | AFN
  1711. // 415 | ALL
  1712. // 416 | AMD
  1713. // 417 | ANG
  1714. // 418 | AOA
  1715. // 419 | ARS
  1716. // 420 | ATS
  1717. // 421 | AUD
  1718. // 422 | AWG
  1719. // 423 | AZM
  1720. // 424 | AZN
  1721. // 425 | BAM
  1722. // 426 | BBD
  1723. // 427 | BDT
  1724. // 428 | BEF
  1725. // 429 | BGL
  1726. // 430 | BGN
  1727. // 431 | BHD
  1728. // 432 | BIF
  1729. // 433 | BMD
  1730. // 434 | BND
  1731. // 435 | BOB
  1732. // 436 | BOV
  1733. // 437 | BRL
  1734. // 438 | BSD
  1735. // 439 | BTN
  1736. // 440 | BWP
  1737. // 441 | BYR
  1738. // 442 | BZD
  1739. // 443 | CAD
  1740. // 444 | CDF
  1741. // 445 | CHE
  1742. // 446 | CHF
  1743. // 447 | CHW
  1744. // 448 | CLF
  1745. // 449 | CLP
  1746. // 450 | CNY
  1747. // 451 | COP
  1748. // 452 | COU
  1749. // 453 | CRC
  1750. // 454 | CSD
  1751. // 455 | CUC
  1752. // 456 | CVE
  1753. // 457 | CYP
  1754. // 458 | CZK
  1755. // 459 | DEM
  1756. // 460 | DJF
  1757. // 461 | DKK
  1758. // 462 | DOP
  1759. // 463 | DZD
  1760. // 464 | ECS
  1761. // 465 | ECV
  1762. // 466 | EEK
  1763. // 467 | EGP
  1764. // 468 | ERN
  1765. // 469 | ESP
  1766. // 470 | ETB
  1767. // 471 | EUR
  1768. // 472 | FIM
  1769. // 473 | FJD
  1770. // 474 | FKP
  1771. // 475 | FRF
  1772. // 476 | GBP
  1773. // 477 | GEL
  1774. // 478 | GHC
  1775. // 479 | GHS
  1776. // 480 | GIP
  1777. // 481 | GMD
  1778. // 482 | GNF
  1779. // 483 | GRD
  1780. // 484 | GTQ
  1781. // 485 | GYD
  1782. // 486 | HKD
  1783. // 487 | HNL
  1784. // 488 | HRK
  1785. // 489 | HTG
  1786. // 490 | HUF
  1787. // 491 | IDR
  1788. // 492 | IEP
  1789. // 493 | ILS
  1790. // 494 | INR
  1791. // 495 | IQD
  1792. // 496 | IRR
  1793. // 497 | ISK
  1794. // 498 | ITL
  1795. // 499 | JMD
  1796. // 500 | JOD
  1797. // 501 | JPY
  1798. // 502 | KAF
  1799. // 503 | KES
  1800. // 504 | KGS
  1801. // 505 | KHR
  1802. // 506 | KMF
  1803. // 507 | KPW
  1804. // 508 | KRW
  1805. // 509 | KWD
  1806. // 510 | KYD
  1807. // 511 | KZT
  1808. // 512 | LAK
  1809. // 513 | LBP
  1810. // 514 | LKR
  1811. // 515 | LRD
  1812. // 516 | LSL
  1813. // 517 | LTL
  1814. // 518 | LUF
  1815. // 519 | LVL
  1816. // 520 | LYD
  1817. // 521 | MAD
  1818. // 522 | MDL
  1819. // 523 | MGA
  1820. // 524 | MGF
  1821. // 525 | MKD
  1822. // 526 | MMK
  1823. // 527 | MNT
  1824. // 528 | MOP
  1825. // 529 | MRO
  1826. // 530 | MTL
  1827. // 531 | MUR
  1828. // 532 | MVR
  1829. // 533 | MWK
  1830. // 534 | MXN
  1831. // 535 | MXV
  1832. // 536 | MYR
  1833. // 537 | MZM
  1834. // 538 | MZN
  1835. // 539 | NAD
  1836. // 540 | NGN
  1837. // 541 | NIO
  1838. // 542 | NLG
  1839. // 543 | NOK
  1840. // 544 | NPR
  1841. // 545 | NTD
  1842. // 546 | NZD
  1843. // 547 | OMR
  1844. // 548 | PAB
  1845. // 549 | PEN
  1846. // 550 | PGK
  1847. // 551 | PHP
  1848. // 552 | PKR
  1849. // 553 | PLN
  1850. // 554 | PTE
  1851. // 555 | PYG
  1852. // 556 | QAR
  1853. // 557 | ROL
  1854. // 558 | RON
  1855. // 559 | RSD
  1856. // 560 | RUB
  1857. // 561 | RUR
  1858. // 562 | RWF
  1859. // 563 | SAR
  1860. // 564 | SBD
  1861. // 565 | SCR
  1862. // 566 | SDD
  1863. // 567 | SDG
  1864. // 568 | SDP
  1865. // 569 | SEK
  1866. // 570 | SGD
  1867. // 571 | SHP
  1868. // 572 | SIT
  1869. // 573 | SKK
  1870. // 574 | SLL
  1871. // 575 | SOS
  1872. // 576 | SPL
  1873. // 577 | SRD
  1874. // 578 | SRG
  1875. // 579 | STD
  1876. // 580 | SVC
  1877. // 581 | SYP
  1878. // 582 | SZL
  1879. // 583 | THB
  1880. // 584 | TJR
  1881. // 585 | TJS
  1882. // 586 | TMM
  1883. // 587 | TMT
  1884. // 588 | TND
  1885. // 589 | TOP
  1886. // 590 | TRL
  1887. // 591 | TRY
  1888. // 592 | TTD
  1889. // 593 | TWD
  1890. // 594 | TZS
  1891. // 595 | UAH
  1892. // 596 | UGX
  1893. // 597 | USD
  1894. // 598 | USN
  1895. // 599 | USS
  1896. // 600 | UYI
  1897. // 601 | UYU
  1898. // 602 | UZS
  1899. // 603 | VEB
  1900. // 604 | VEF
  1901. // 605 | VND
  1902. // 606 | VUV
  1903. // 607 | WST
  1904. // 608 | XAF
  1905. // 609 | XAG
  1906. // 610 | XAU
  1907. // 611 | XB5
  1908. // 612 | XBA
  1909. // 613 | XBB
  1910. // 614 | XBC
  1911. // 615 | XBD
  1912. // 616 | XCD
  1913. // 617 | XDR
  1914. // 618 | XFO
  1915. // 619 | XFU
  1916. // 620 | XOF
  1917. // 621 | XPD
  1918. // 622 | XPF
  1919. // 623 | XPT
  1920. // 624 | XTS
  1921. // 625 | XXX
  1922. // 626 | YER
  1923. // 627 | YUM
  1924. // 628 | ZAR
  1925. // 629 | ZMK
  1926. // 630 | ZMW
  1927. // 631 | ZWD
  1928. // 632 | ZWL
  1929. // 633 | ZWN
  1930. // 634 | ZWR
  1931. //
  1932. // Excelize support set custom number format for cell. For example, set number
  1933. // as date type in Uruguay (Spanish) format for Sheet1!A6:
  1934. //
  1935. // f := excelize.NewFile()
  1936. // f.SetCellValue("Sheet1", "A6", 42920.5)
  1937. // exp := "[$-380A]dddd\\,\\ dd\" de \"mmmm\" de \"yyyy;@"
  1938. // style, err := f.NewStyle(&excelize.Style{CustomNumFmt: &exp})
  1939. // err = f.SetCellStyle("Sheet1", "A6", "A6", style)
  1940. //
  1941. // Cell Sheet1!A6 in the Excel Application: martes, 04 de Julio de 2017
  1942. //
  1943. func (f *File) NewStyle(style interface{}) (int, error) {
  1944. var fs *Style
  1945. var err error
  1946. var cellXfsID, fontID, borderID, fillID int
  1947. fs, err = parseFormatStyleSet(style)
  1948. if err != nil {
  1949. return cellXfsID, err
  1950. }
  1951. if fs.DecimalPlaces == 0 {
  1952. fs.DecimalPlaces = 2
  1953. }
  1954. s := f.stylesReader()
  1955. // check given style already exist.
  1956. if cellXfsID = f.getStyleID(s, fs); cellXfsID != -1 {
  1957. return cellXfsID, err
  1958. }
  1959. numFmtID := newNumFmt(s, fs)
  1960. if fs.Font != nil {
  1961. fontID = f.getFontID(s, fs)
  1962. if fontID == -1 {
  1963. s.Fonts.Count++
  1964. s.Fonts.Font = append(s.Fonts.Font, f.newFont(fs))
  1965. fontID = s.Fonts.Count - 1
  1966. }
  1967. }
  1968. borderID = getBorderID(s, fs)
  1969. if borderID == -1 {
  1970. if len(fs.Border) == 0 {
  1971. borderID = 0
  1972. } else {
  1973. s.Borders.Count++
  1974. s.Borders.Border = append(s.Borders.Border, newBorders(fs))
  1975. borderID = s.Borders.Count - 1
  1976. }
  1977. }
  1978. if fillID = getFillID(s, fs); fillID == -1 {
  1979. if fill := newFills(fs, true); fill != nil {
  1980. s.Fills.Count++
  1981. s.Fills.Fill = append(s.Fills.Fill, fill)
  1982. fillID = s.Fills.Count - 1
  1983. } else {
  1984. fillID = 0
  1985. }
  1986. }
  1987. applyAlignment, alignment := fs.Alignment != nil, newAlignment(fs)
  1988. applyProtection, protection := fs.Protection != nil, newProtection(fs)
  1989. cellXfsID = setCellXfs(s, fontID, numFmtID, fillID, borderID, applyAlignment, applyProtection, alignment, protection)
  1990. return cellXfsID, nil
  1991. }
  1992. var getXfIDFuncs = map[string]func(int, xlsxXf, *Style) bool{
  1993. "numFmt": func(numFmtID int, xf xlsxXf, style *Style) bool {
  1994. if style.NumFmt == 0 && style.CustomNumFmt == nil && numFmtID == -1 {
  1995. return xf.NumFmtID != nil || *xf.NumFmtID == 0
  1996. }
  1997. if style.NegRed || style.Lang != "" || style.DecimalPlaces != 2 {
  1998. return false
  1999. }
  2000. return xf.NumFmtID != nil && *xf.NumFmtID == numFmtID
  2001. },
  2002. "font": func(fontID int, xf xlsxXf, style *Style) bool {
  2003. if style.Font == nil {
  2004. return (xf.FontID == nil || *xf.FontID == 0) && (xf.ApplyFont == nil || !*xf.ApplyFont)
  2005. }
  2006. return xf.FontID != nil && *xf.FontID == fontID && xf.ApplyFont != nil && *xf.ApplyFont
  2007. },
  2008. "fill": func(fillID int, xf xlsxXf, style *Style) bool {
  2009. if style.Fill.Type == "" {
  2010. return (xf.FillID == nil || *xf.FillID == 0) && (xf.ApplyFill == nil || !*xf.ApplyFill)
  2011. }
  2012. return xf.FillID != nil && *xf.FillID == fillID && xf.ApplyFill != nil && *xf.ApplyFill
  2013. },
  2014. "border": func(borderID int, xf xlsxXf, style *Style) bool {
  2015. if len(style.Border) == 0 {
  2016. return (xf.BorderID == nil || *xf.BorderID == 0) && (xf.ApplyBorder == nil || !*xf.ApplyBorder)
  2017. }
  2018. return xf.BorderID != nil && *xf.BorderID == borderID && xf.ApplyBorder != nil && *xf.ApplyBorder
  2019. },
  2020. "alignment": func(ID int, xf xlsxXf, style *Style) bool {
  2021. if style.Alignment == nil {
  2022. return xf.ApplyAlignment == nil || !*xf.ApplyAlignment
  2023. }
  2024. return reflect.DeepEqual(xf.Alignment, newAlignment(style))
  2025. },
  2026. "protection": func(ID int, xf xlsxXf, style *Style) bool {
  2027. if style.Protection == nil {
  2028. return xf.ApplyProtection == nil || !*xf.ApplyProtection
  2029. }
  2030. return reflect.DeepEqual(xf.Protection, newProtection(style)) && xf.ApplyProtection != nil && *xf.ApplyProtection
  2031. },
  2032. }
  2033. // getStyleID provides a function to get styleID by given style. If given
  2034. // style is not exist, will return -1.
  2035. func (f *File) getStyleID(ss *xlsxStyleSheet, style *Style) (styleID int) {
  2036. styleID = -1
  2037. if ss.CellXfs == nil {
  2038. return
  2039. }
  2040. numFmtID, borderID, fillID, fontID := getNumFmtID(ss, style), getBorderID(ss, style), getFillID(ss, style), f.getFontID(ss, style)
  2041. if style.CustomNumFmt != nil {
  2042. numFmtID = getCustomNumFmtID(ss, style)
  2043. }
  2044. for xfID, xf := range ss.CellXfs.Xf {
  2045. if getXfIDFuncs["numFmt"](numFmtID, xf, style) &&
  2046. getXfIDFuncs["font"](fontID, xf, style) &&
  2047. getXfIDFuncs["fill"](fillID, xf, style) &&
  2048. getXfIDFuncs["border"](borderID, xf, style) &&
  2049. getXfIDFuncs["alignment"](0, xf, style) &&
  2050. getXfIDFuncs["protection"](0, xf, style) {
  2051. styleID = xfID
  2052. return
  2053. }
  2054. }
  2055. return
  2056. }
  2057. // NewConditionalStyle provides a function to create style for conditional
  2058. // format by given style format. The parameters are the same as function
  2059. // NewStyle(). Note that the color field uses RGB color code and only support
  2060. // to set font, fills, alignment and borders currently.
  2061. func (f *File) NewConditionalStyle(style string) (int, error) {
  2062. s := f.stylesReader()
  2063. fs, err := parseFormatStyleSet(style)
  2064. if err != nil {
  2065. return 0, err
  2066. }
  2067. dxf := dxf{
  2068. Fill: newFills(fs, false),
  2069. }
  2070. if fs.Alignment != nil {
  2071. dxf.Alignment = newAlignment(fs)
  2072. }
  2073. if len(fs.Border) > 0 {
  2074. dxf.Border = newBorders(fs)
  2075. }
  2076. if fs.Font != nil {
  2077. dxf.Font = f.newFont(fs)
  2078. }
  2079. dxfStr, _ := xml.Marshal(dxf)
  2080. if s.Dxfs == nil {
  2081. s.Dxfs = &xlsxDxfs{}
  2082. }
  2083. s.Dxfs.Count++
  2084. s.Dxfs.Dxfs = append(s.Dxfs.Dxfs, &xlsxDxf{
  2085. Dxf: string(dxfStr[5 : len(dxfStr)-6]),
  2086. })
  2087. return s.Dxfs.Count - 1, nil
  2088. }
  2089. // GetDefaultFont provides the default font name currently set in the workbook
  2090. // Documents generated by excelize start with Calibri.
  2091. func (f *File) GetDefaultFont() string {
  2092. font := f.readDefaultFont()
  2093. return *font.Name.Val
  2094. }
  2095. // SetDefaultFont changes the default font in the workbook.
  2096. func (f *File) SetDefaultFont(fontName string) {
  2097. font := f.readDefaultFont()
  2098. font.Name.Val = stringPtr(fontName)
  2099. s := f.stylesReader()
  2100. s.Fonts.Font[0] = font
  2101. custom := true
  2102. s.CellStyles.CellStyle[0].CustomBuiltIn = &custom
  2103. }
  2104. // readDefaultFont provides an unmarshalled font value.
  2105. func (f *File) readDefaultFont() *xlsxFont {
  2106. s := f.stylesReader()
  2107. return s.Fonts.Font[0]
  2108. }
  2109. // getFontID provides a function to get font ID.
  2110. // If given font is not exist, will return -1.
  2111. func (f *File) getFontID(styleSheet *xlsxStyleSheet, style *Style) (fontID int) {
  2112. fontID = -1
  2113. if styleSheet.Fonts == nil || style.Font == nil {
  2114. return
  2115. }
  2116. for idx, fnt := range styleSheet.Fonts.Font {
  2117. if reflect.DeepEqual(*fnt, *f.newFont(style)) {
  2118. fontID = idx
  2119. return
  2120. }
  2121. }
  2122. return
  2123. }
  2124. // newFont provides a function to add font style by given cell format
  2125. // settings.
  2126. func (f *File) newFont(style *Style) *xlsxFont {
  2127. fontUnderlineType := map[string]string{"single": "single", "double": "double"}
  2128. if style.Font.Size < 1 {
  2129. style.Font.Size = 11
  2130. }
  2131. if style.Font.Color == "" {
  2132. style.Font.Color = "#000000"
  2133. }
  2134. fnt := xlsxFont{
  2135. Sz: &attrValFloat{Val: float64Ptr(style.Font.Size)},
  2136. Color: &xlsxColor{RGB: getPaletteColor(style.Font.Color)},
  2137. Name: &attrValString{Val: stringPtr(style.Font.Family)},
  2138. Family: &attrValInt{Val: intPtr(2)},
  2139. }
  2140. if style.Font.Bold {
  2141. fnt.B = &style.Font.Bold
  2142. }
  2143. if style.Font.Italic {
  2144. fnt.I = &style.Font.Italic
  2145. }
  2146. if *fnt.Name.Val == "" {
  2147. *fnt.Name.Val = f.GetDefaultFont()
  2148. }
  2149. if style.Font.Strike {
  2150. strike := true
  2151. fnt.Strike = &strike
  2152. }
  2153. val, ok := fontUnderlineType[style.Font.Underline]
  2154. if ok {
  2155. fnt.U = &attrValString{Val: stringPtr(val)}
  2156. }
  2157. return &fnt
  2158. }
  2159. // getNumFmtID provides a function to get number format code ID.
  2160. // If given number format code is not exist, will return -1.
  2161. func getNumFmtID(styleSheet *xlsxStyleSheet, style *Style) (numFmtID int) {
  2162. numFmtID = -1
  2163. if styleSheet.NumFmts == nil {
  2164. return
  2165. }
  2166. if _, ok := builtInNumFmt[style.NumFmt]; ok {
  2167. return style.NumFmt
  2168. }
  2169. if fmtCode, ok := currencyNumFmt[style.NumFmt]; ok {
  2170. for _, numFmt := range styleSheet.NumFmts.NumFmt {
  2171. if numFmt.FormatCode == fmtCode {
  2172. numFmtID = numFmt.NumFmtID
  2173. return
  2174. }
  2175. }
  2176. }
  2177. return
  2178. }
  2179. // newNumFmt provides a function to check if number format code in the range
  2180. // of built-in values.
  2181. func newNumFmt(styleSheet *xlsxStyleSheet, style *Style) int {
  2182. dp := "0."
  2183. numFmtID := 164 // Default custom number format code from 164.
  2184. if style.DecimalPlaces < 0 || style.DecimalPlaces > 30 {
  2185. style.DecimalPlaces = 2
  2186. }
  2187. for i := 0; i < style.DecimalPlaces; i++ {
  2188. dp += "0"
  2189. }
  2190. if style.CustomNumFmt != nil {
  2191. if customNumFmtID := getCustomNumFmtID(styleSheet, style); customNumFmtID != -1 {
  2192. return customNumFmtID
  2193. }
  2194. return setCustomNumFmt(styleSheet, style)
  2195. }
  2196. _, ok := builtInNumFmt[style.NumFmt]
  2197. if !ok {
  2198. fc, currency := currencyNumFmt[style.NumFmt]
  2199. if !currency {
  2200. return setLangNumFmt(styleSheet, style)
  2201. }
  2202. fc = strings.Replace(fc, "0.00", dp, -1)
  2203. if style.NegRed {
  2204. fc = fc + ";[Red]" + fc
  2205. }
  2206. if styleSheet.NumFmts != nil {
  2207. numFmtID = styleSheet.NumFmts.NumFmt[len(styleSheet.NumFmts.NumFmt)-1].NumFmtID + 1
  2208. nf := xlsxNumFmt{
  2209. FormatCode: fc,
  2210. NumFmtID: numFmtID,
  2211. }
  2212. styleSheet.NumFmts.NumFmt = append(styleSheet.NumFmts.NumFmt, &nf)
  2213. styleSheet.NumFmts.Count++
  2214. } else {
  2215. nf := xlsxNumFmt{
  2216. FormatCode: fc,
  2217. NumFmtID: numFmtID,
  2218. }
  2219. numFmts := xlsxNumFmts{
  2220. NumFmt: []*xlsxNumFmt{&nf},
  2221. Count: 1,
  2222. }
  2223. styleSheet.NumFmts = &numFmts
  2224. }
  2225. return numFmtID
  2226. }
  2227. return style.NumFmt
  2228. }
  2229. // setCustomNumFmt provides a function to set custom number format code.
  2230. func setCustomNumFmt(styleSheet *xlsxStyleSheet, style *Style) int {
  2231. nf := xlsxNumFmt{FormatCode: *style.CustomNumFmt}
  2232. if styleSheet.NumFmts != nil {
  2233. nf.NumFmtID = styleSheet.NumFmts.NumFmt[len(styleSheet.NumFmts.NumFmt)-1].NumFmtID + 1
  2234. styleSheet.NumFmts.NumFmt = append(styleSheet.NumFmts.NumFmt, &nf)
  2235. styleSheet.NumFmts.Count++
  2236. } else {
  2237. nf.NumFmtID = 164
  2238. numFmts := xlsxNumFmts{
  2239. NumFmt: []*xlsxNumFmt{&nf},
  2240. Count: 1,
  2241. }
  2242. styleSheet.NumFmts = &numFmts
  2243. }
  2244. return nf.NumFmtID
  2245. }
  2246. // getCustomNumFmtID provides a function to get custom number format code ID.
  2247. // If given custom number format code is not exist, will return -1.
  2248. func getCustomNumFmtID(styleSheet *xlsxStyleSheet, style *Style) (customNumFmtID int) {
  2249. customNumFmtID = -1
  2250. if styleSheet.NumFmts == nil {
  2251. return
  2252. }
  2253. for _, numFmt := range styleSheet.NumFmts.NumFmt {
  2254. if style.CustomNumFmt != nil && numFmt.FormatCode == *style.CustomNumFmt {
  2255. customNumFmtID = numFmt.NumFmtID
  2256. return
  2257. }
  2258. }
  2259. return
  2260. }
  2261. // setLangNumFmt provides a function to set number format code with language.
  2262. func setLangNumFmt(styleSheet *xlsxStyleSheet, style *Style) int {
  2263. numFmts, ok := langNumFmt[style.Lang]
  2264. if !ok {
  2265. return 0
  2266. }
  2267. var fc string
  2268. fc, ok = numFmts[style.NumFmt]
  2269. if !ok {
  2270. return 0
  2271. }
  2272. nf := xlsxNumFmt{FormatCode: fc}
  2273. if styleSheet.NumFmts != nil {
  2274. nf.NumFmtID = styleSheet.NumFmts.NumFmt[len(styleSheet.NumFmts.NumFmt)-1].NumFmtID + 1
  2275. styleSheet.NumFmts.NumFmt = append(styleSheet.NumFmts.NumFmt, &nf)
  2276. styleSheet.NumFmts.Count++
  2277. } else {
  2278. nf.NumFmtID = style.NumFmt
  2279. numFmts := xlsxNumFmts{
  2280. NumFmt: []*xlsxNumFmt{&nf},
  2281. Count: 1,
  2282. }
  2283. styleSheet.NumFmts = &numFmts
  2284. }
  2285. return nf.NumFmtID
  2286. }
  2287. // getFillID provides a function to get fill ID. If given fill is not
  2288. // exist, will return -1.
  2289. func getFillID(styleSheet *xlsxStyleSheet, style *Style) (fillID int) {
  2290. fillID = -1
  2291. if styleSheet.Fills == nil || style.Fill.Type == "" {
  2292. return
  2293. }
  2294. fills := newFills(style, true)
  2295. if fills == nil {
  2296. return
  2297. }
  2298. for idx, fill := range styleSheet.Fills.Fill {
  2299. if reflect.DeepEqual(fill, fills) {
  2300. fillID = idx
  2301. return
  2302. }
  2303. }
  2304. return
  2305. }
  2306. // newFills provides a function to add fill elements in the styles.xml by
  2307. // given cell format settings.
  2308. func newFills(style *Style, fg bool) *xlsxFill {
  2309. var patterns = []string{
  2310. "none",
  2311. "solid",
  2312. "mediumGray",
  2313. "darkGray",
  2314. "lightGray",
  2315. "darkHorizontal",
  2316. "darkVertical",
  2317. "darkDown",
  2318. "darkUp",
  2319. "darkGrid",
  2320. "darkTrellis",
  2321. "lightHorizontal",
  2322. "lightVertical",
  2323. "lightDown",
  2324. "lightUp",
  2325. "lightGrid",
  2326. "lightTrellis",
  2327. "gray125",
  2328. "gray0625",
  2329. }
  2330. var variants = []float64{
  2331. 90,
  2332. 0,
  2333. 45,
  2334. 135,
  2335. }
  2336. var fill xlsxFill
  2337. switch style.Fill.Type {
  2338. case "gradient":
  2339. if len(style.Fill.Color) != 2 {
  2340. break
  2341. }
  2342. var gradient xlsxGradientFill
  2343. switch style.Fill.Shading {
  2344. case 0, 1, 2, 3:
  2345. gradient.Degree = variants[style.Fill.Shading]
  2346. case 4:
  2347. gradient.Type = "path"
  2348. case 5:
  2349. gradient.Type = "path"
  2350. gradient.Bottom = 0.5
  2351. gradient.Left = 0.5
  2352. gradient.Right = 0.5
  2353. gradient.Top = 0.5
  2354. }
  2355. var stops []*xlsxGradientFillStop
  2356. for index, color := range style.Fill.Color {
  2357. var stop xlsxGradientFillStop
  2358. stop.Position = float64(index)
  2359. stop.Color.RGB = getPaletteColor(color)
  2360. stops = append(stops, &stop)
  2361. }
  2362. gradient.Stop = stops
  2363. fill.GradientFill = &gradient
  2364. case "pattern":
  2365. if style.Fill.Pattern > 18 || style.Fill.Pattern < 0 {
  2366. break
  2367. }
  2368. if len(style.Fill.Color) < 1 {
  2369. break
  2370. }
  2371. var pattern xlsxPatternFill
  2372. pattern.PatternType = patterns[style.Fill.Pattern]
  2373. if fg {
  2374. if pattern.FgColor == nil {
  2375. pattern.FgColor = new(xlsxColor)
  2376. }
  2377. pattern.FgColor.RGB = getPaletteColor(style.Fill.Color[0])
  2378. } else {
  2379. if pattern.BgColor == nil {
  2380. pattern.BgColor = new(xlsxColor)
  2381. }
  2382. pattern.BgColor.RGB = getPaletteColor(style.Fill.Color[0])
  2383. }
  2384. fill.PatternFill = &pattern
  2385. default:
  2386. return nil
  2387. }
  2388. return &fill
  2389. }
  2390. // newAlignment provides a function to formatting information pertaining to
  2391. // text alignment in cells. There are a variety of choices for how text is
  2392. // aligned both horizontally and vertically, as well as indentation settings,
  2393. // and so on.
  2394. func newAlignment(style *Style) *xlsxAlignment {
  2395. var alignment xlsxAlignment
  2396. if style.Alignment != nil {
  2397. alignment.Horizontal = style.Alignment.Horizontal
  2398. alignment.Indent = style.Alignment.Indent
  2399. alignment.JustifyLastLine = style.Alignment.JustifyLastLine
  2400. alignment.ReadingOrder = style.Alignment.ReadingOrder
  2401. alignment.RelativeIndent = style.Alignment.RelativeIndent
  2402. alignment.ShrinkToFit = style.Alignment.ShrinkToFit
  2403. alignment.TextRotation = style.Alignment.TextRotation
  2404. alignment.Vertical = style.Alignment.Vertical
  2405. alignment.WrapText = style.Alignment.WrapText
  2406. }
  2407. return &alignment
  2408. }
  2409. // newProtection provides a function to set protection properties associated
  2410. // with the cell.
  2411. func newProtection(style *Style) *xlsxProtection {
  2412. var protection xlsxProtection
  2413. if style.Protection != nil {
  2414. protection.Hidden = &style.Protection.Hidden
  2415. protection.Locked = &style.Protection.Locked
  2416. }
  2417. return &protection
  2418. }
  2419. // getBorderID provides a function to get border ID. If given border is not
  2420. // exist, will return -1.
  2421. func getBorderID(styleSheet *xlsxStyleSheet, style *Style) (borderID int) {
  2422. borderID = -1
  2423. if styleSheet.Borders == nil || len(style.Border) == 0 {
  2424. return
  2425. }
  2426. for idx, border := range styleSheet.Borders.Border {
  2427. if reflect.DeepEqual(*border, *newBorders(style)) {
  2428. borderID = idx
  2429. return
  2430. }
  2431. }
  2432. return
  2433. }
  2434. // newBorders provides a function to add border elements in the styles.xml by
  2435. // given borders format settings.
  2436. func newBorders(style *Style) *xlsxBorder {
  2437. var styles = []string{
  2438. "none",
  2439. "thin",
  2440. "medium",
  2441. "dashed",
  2442. "dotted",
  2443. "thick",
  2444. "double",
  2445. "hair",
  2446. "mediumDashed",
  2447. "dashDot",
  2448. "mediumDashDot",
  2449. "dashDotDot",
  2450. "mediumDashDotDot",
  2451. "slantDashDot",
  2452. }
  2453. var border xlsxBorder
  2454. for _, v := range style.Border {
  2455. if 0 <= v.Style && v.Style < 14 {
  2456. var color xlsxColor
  2457. color.RGB = getPaletteColor(v.Color)
  2458. switch v.Type {
  2459. case "left":
  2460. border.Left.Style = styles[v.Style]
  2461. border.Left.Color = &color
  2462. case "right":
  2463. border.Right.Style = styles[v.Style]
  2464. border.Right.Color = &color
  2465. case "top":
  2466. border.Top.Style = styles[v.Style]
  2467. border.Top.Color = &color
  2468. case "bottom":
  2469. border.Bottom.Style = styles[v.Style]
  2470. border.Bottom.Color = &color
  2471. case "diagonalUp":
  2472. border.Diagonal.Style = styles[v.Style]
  2473. border.Diagonal.Color = &color
  2474. border.DiagonalUp = true
  2475. case "diagonalDown":
  2476. border.Diagonal.Style = styles[v.Style]
  2477. border.Diagonal.Color = &color
  2478. border.DiagonalDown = true
  2479. }
  2480. }
  2481. }
  2482. return &border
  2483. }
  2484. // setCellXfs provides a function to set describes all of the formatting for a
  2485. // cell.
  2486. func setCellXfs(style *xlsxStyleSheet, fontID, numFmtID, fillID, borderID int, applyAlignment, applyProtection bool, alignment *xlsxAlignment, protection *xlsxProtection) int {
  2487. var xf xlsxXf
  2488. xf.FontID = intPtr(fontID)
  2489. if fontID != 0 {
  2490. xf.ApplyFont = boolPtr(true)
  2491. }
  2492. xf.NumFmtID = intPtr(numFmtID)
  2493. if numFmtID != 0 {
  2494. xf.ApplyNumberFormat = boolPtr(true)
  2495. }
  2496. xf.FillID = intPtr(fillID)
  2497. if fillID != 0 {
  2498. xf.ApplyFill = boolPtr(true)
  2499. }
  2500. xf.BorderID = intPtr(borderID)
  2501. if borderID != 0 {
  2502. xf.ApplyBorder = boolPtr(true)
  2503. }
  2504. style.CellXfs.Count++
  2505. xf.Alignment = alignment
  2506. if alignment != nil {
  2507. xf.ApplyAlignment = boolPtr(applyAlignment)
  2508. }
  2509. if applyProtection {
  2510. xf.ApplyProtection = boolPtr(applyProtection)
  2511. xf.Protection = protection
  2512. }
  2513. xfID := 0
  2514. xf.XfID = &xfID
  2515. style.CellXfs.Xf = append(style.CellXfs.Xf, xf)
  2516. return style.CellXfs.Count - 1
  2517. }
  2518. // GetCellStyle provides a function to get cell style index by given worksheet
  2519. // name and cell coordinates.
  2520. func (f *File) GetCellStyle(sheet, axis string) (int, error) {
  2521. ws, err := f.workSheetReader(sheet)
  2522. if err != nil {
  2523. return 0, err
  2524. }
  2525. cellData, col, _, err := f.prepareCell(ws, sheet, axis)
  2526. if err != nil {
  2527. return 0, err
  2528. }
  2529. return f.prepareCellStyle(ws, col, cellData.S), err
  2530. }
  2531. // SetCellStyle provides a function to add style attribute for cells by given
  2532. // worksheet name, coordinate area and style ID. Note that diagonalDown and
  2533. // diagonalUp type border should be use same color in the same coordinate
  2534. // area.
  2535. //
  2536. // For example create a borders of cell H9 on Sheet1:
  2537. //
  2538. // style, err := f.NewStyle(`{"border":[{"type":"left","color":"0000FF","style":3},{"type":"top","color":"00FF00","style":4},{"type":"bottom","color":"FFFF00","style":5},{"type":"right","color":"FF0000","style":6},{"type":"diagonalDown","color":"A020F0","style":7},{"type":"diagonalUp","color":"A020F0","style":8}]}`)
  2539. // if err != nil {
  2540. // fmt.Println(err)
  2541. // }
  2542. // err = f.SetCellStyle("Sheet1", "H9", "H9", style)
  2543. //
  2544. // Set gradient fill with vertical variants shading styles for cell H9 on
  2545. // Sheet1:
  2546. //
  2547. // style, err := f.NewStyle(`{"fill":{"type":"gradient","color":["#FFFFFF","#E0EBF5"],"shading":1}}`)
  2548. // if err != nil {
  2549. // fmt.Println(err)
  2550. // }
  2551. // err = f.SetCellStyle("Sheet1", "H9", "H9", style)
  2552. //
  2553. // Set solid style pattern fill for cell H9 on Sheet1:
  2554. //
  2555. // style, err := f.NewStyle(`{"fill":{"type":"pattern","color":["#E0EBF5"],"pattern":1}}`)
  2556. // if err != nil {
  2557. // fmt.Println(err)
  2558. // }
  2559. // err = f.SetCellStyle("Sheet1", "H9", "H9", style)
  2560. //
  2561. // Set alignment style for cell H9 on Sheet1:
  2562. //
  2563. // style, err := f.NewStyle(`{"alignment":{"horizontal":"center","ident":1,"justify_last_line":true,"reading_order":0,"relative_indent":1,"shrink_to_fit":true,"text_rotation":45,"vertical":"","wrap_text":true}}`)
  2564. // if err != nil {
  2565. // fmt.Println(err)
  2566. // }
  2567. // err = f.SetCellStyle("Sheet1", "H9", "H9", style)
  2568. //
  2569. // Dates and times in Excel are represented by real numbers, for example "Apr 7
  2570. // 2017 12:00 PM" is represented by the number 42920.5. Set date and time format
  2571. // for cell H9 on Sheet1:
  2572. //
  2573. // f.SetCellValue("Sheet1", "H9", 42920.5)
  2574. // style, err := f.NewStyle(`{"number_format": 22}`)
  2575. // if err != nil {
  2576. // fmt.Println(err)
  2577. // }
  2578. // err = f.SetCellStyle("Sheet1", "H9", "H9", style)
  2579. //
  2580. // Set font style for cell H9 on Sheet1:
  2581. //
  2582. // style, err := f.NewStyle(`{"font":{"bold":true,"italic":true,"family":"Times New Roman","size":36,"color":"#777777"}}`)
  2583. // if err != nil {
  2584. // fmt.Println(err)
  2585. // }
  2586. // err = f.SetCellStyle("Sheet1", "H9", "H9", style)
  2587. //
  2588. // Hide and lock for cell H9 on Sheet1:
  2589. //
  2590. // style, err := f.NewStyle(`{"protection":{"hidden":true, "locked":true}}`)
  2591. // if err != nil {
  2592. // fmt.Println(err)
  2593. // }
  2594. // err = f.SetCellStyle("Sheet1", "H9", "H9", style)
  2595. //
  2596. func (f *File) SetCellStyle(sheet, hcell, vcell string, styleID int) error {
  2597. hcol, hrow, err := CellNameToCoordinates(hcell)
  2598. if err != nil {
  2599. return err
  2600. }
  2601. vcol, vrow, err := CellNameToCoordinates(vcell)
  2602. if err != nil {
  2603. return err
  2604. }
  2605. // Normalize the coordinate area, such correct C1:B3 to B1:C3.
  2606. if vcol < hcol {
  2607. vcol, hcol = hcol, vcol
  2608. }
  2609. if vrow < hrow {
  2610. vrow, hrow = hrow, vrow
  2611. }
  2612. hcolIdx := hcol - 1
  2613. hrowIdx := hrow - 1
  2614. vcolIdx := vcol - 1
  2615. vrowIdx := vrow - 1
  2616. ws, err := f.workSheetReader(sheet)
  2617. if err != nil {
  2618. return err
  2619. }
  2620. prepareSheetXML(ws, vcol, vrow)
  2621. makeContiguousColumns(ws, hrow, vrow, vcol)
  2622. for r := hrowIdx; r <= vrowIdx; r++ {
  2623. for k := hcolIdx; k <= vcolIdx; k++ {
  2624. ws.SheetData.Row[r].C[k].S = styleID
  2625. }
  2626. }
  2627. return err
  2628. }
  2629. // SetConditionalFormat provides a function to create conditional formatting
  2630. // rule for cell value. Conditional formatting is a feature of Excel which
  2631. // allows you to apply a format to a cell or a range of cells based on certain
  2632. // criteria.
  2633. //
  2634. // The type option is a required parameter and it has no default value.
  2635. // Allowable type values and their associated parameters are:
  2636. //
  2637. // Type | Parameters
  2638. // ---------------+------------------------------------
  2639. // cell | criteria
  2640. // | value
  2641. // | minimum
  2642. // | maximum
  2643. // date | criteria
  2644. // | value
  2645. // | minimum
  2646. // | maximum
  2647. // time_period | criteria
  2648. // text | criteria
  2649. // | value
  2650. // average | criteria
  2651. // duplicate | (none)
  2652. // unique | (none)
  2653. // top | criteria
  2654. // | value
  2655. // bottom | criteria
  2656. // | value
  2657. // blanks | (none)
  2658. // no_blanks | (none)
  2659. // errors | (none)
  2660. // no_errors | (none)
  2661. // 2_color_scale | min_type
  2662. // | max_type
  2663. // | min_value
  2664. // | max_value
  2665. // | min_color
  2666. // | max_color
  2667. // 3_color_scale | min_type
  2668. // | mid_type
  2669. // | max_type
  2670. // | min_value
  2671. // | mid_value
  2672. // | max_value
  2673. // | min_color
  2674. // | mid_color
  2675. // | max_color
  2676. // data_bar | min_type
  2677. // | max_type
  2678. // | min_value
  2679. // | max_value
  2680. // | bar_color
  2681. // formula | criteria
  2682. //
  2683. // The criteria parameter is used to set the criteria by which the cell data
  2684. // will be evaluated. It has no default value. The most common criteria as
  2685. // applied to {"type":"cell"} are:
  2686. //
  2687. // between |
  2688. // not between |
  2689. // equal to | ==
  2690. // not equal to | !=
  2691. // greater than | >
  2692. // less than | <
  2693. // greater than or equal to | >=
  2694. // less than or equal to | <=
  2695. //
  2696. // You can either use Excel's textual description strings, in the first column
  2697. // above, or the more common symbolic alternatives.
  2698. //
  2699. // Additional criteria which are specific to other conditional format types are
  2700. // shown in the relevant sections below.
  2701. //
  2702. // value: The value is generally used along with the criteria parameter to set
  2703. // the rule by which the cell data will be evaluated:
  2704. //
  2705. // f.SetConditionalFormat("Sheet1", "D1:D10", fmt.Sprintf(`[{"type":"cell","criteria":">","format":%d,"value":"6"}]`, format))
  2706. //
  2707. // The value property can also be an cell reference:
  2708. //
  2709. // f.SetConditionalFormat("Sheet1", "D1:D10", fmt.Sprintf(`[{"type":"cell","criteria":">","format":%d,"value":"$C$1"}]`, format))
  2710. //
  2711. // type: format - The format parameter is used to specify the format that will
  2712. // be applied to the cell when the conditional formatting criterion is met. The
  2713. // format is created using the NewConditionalStyle() method in the same way as
  2714. // cell formats:
  2715. //
  2716. // format, err = f.NewConditionalStyle(`{"font":{"color":"#9A0511"},"fill":{"type":"pattern","color":["#FEC7CE"],"pattern":1}}`)
  2717. // if err != nil {
  2718. // fmt.Println(err)
  2719. // }
  2720. // f.SetConditionalFormat("Sheet1", "A1:A10", fmt.Sprintf(`[{"type":"cell","criteria":">","format":%d,"value":"6"}]`, format))
  2721. //
  2722. // Note: In Excel, a conditional format is superimposed over the existing cell
  2723. // format and not all cell format properties can be modified. Properties that
  2724. // cannot be modified in a conditional format are font name, font size,
  2725. // superscript and subscript, diagonal borders, all alignment properties and all
  2726. // protection properties.
  2727. //
  2728. // Excel specifies some default formats to be used with conditional formatting.
  2729. // These can be replicated using the following excelize formats:
  2730. //
  2731. // // Rose format for bad conditional.
  2732. // format1, err = f.NewConditionalStyle(`{"font":{"color":"#9A0511"},"fill":{"type":"pattern","color":["#FEC7CE"],"pattern":1}}`)
  2733. //
  2734. // // Light yellow format for neutral conditional.
  2735. // format2, err = f.NewConditionalStyle(`{"font":{"color":"#9B5713"},"fill":{"type":"pattern","color":["#FEEAA0"],"pattern":1}}`)
  2736. //
  2737. // // Light green format for good conditional.
  2738. // format3, err = f.NewConditionalStyle(`{"font":{"color":"#09600B"},"fill":{"type":"pattern","color":["#C7EECF"],"pattern":1}}`)
  2739. //
  2740. // type: minimum - The minimum parameter is used to set the lower limiting value
  2741. // when the criteria is either "between" or "not between".
  2742. //
  2743. // // Hightlight cells rules: between...
  2744. // f.SetConditionalFormat("Sheet1", "A1:A10", fmt.Sprintf(`[{"type":"cell","criteria":"between","format":%d,"minimum":"6","maximum":"8"}]`, format))
  2745. //
  2746. // type: maximum - The maximum parameter is used to set the upper limiting value
  2747. // when the criteria is either "between" or "not between". See the previous
  2748. // example.
  2749. //
  2750. // type: average - The average type is used to specify Excel's "Average" style
  2751. // conditional format:
  2752. //
  2753. // // Top/Bottom rules: Above Average...
  2754. // f.SetConditionalFormat("Sheet1", "A1:A10", fmt.Sprintf(`[{"type":"average","criteria":"=","format":%d, "above_average": true}]`, format1))
  2755. //
  2756. // // Top/Bottom rules: Below Average...
  2757. // f.SetConditionalFormat("Sheet1", "B1:B10", fmt.Sprintf(`[{"type":"average","criteria":"=","format":%d, "above_average": false}]`, format2))
  2758. //
  2759. // type: duplicate - The duplicate type is used to highlight duplicate cells in a range:
  2760. //
  2761. // // Hightlight cells rules: Duplicate Values...
  2762. // f.SetConditionalFormat("Sheet1", "A1:A10", fmt.Sprintf(`[{"type":"duplicate","criteria":"=","format":%d}]`, format))
  2763. //
  2764. // type: unique - The unique type is used to highlight unique cells in a range:
  2765. //
  2766. // // Hightlight cells rules: Not Equal To...
  2767. // f.SetConditionalFormat("Sheet1", "A1:A10", fmt.Sprintf(`[{"type":"unique","criteria":"=","format":%d}]`, format))
  2768. //
  2769. // type: top - The top type is used to specify the top n values by number or percentage in a range:
  2770. //
  2771. // // Top/Bottom rules: Top 10.
  2772. // f.SetConditionalFormat("Sheet1", "H1:H10", fmt.Sprintf(`[{"type":"top","criteria":"=","format":%d,"value":"6"}]`, format))
  2773. //
  2774. // The criteria can be used to indicate that a percentage condition is required:
  2775. //
  2776. // f.SetConditionalFormat("Sheet1", "A1:A10", fmt.Sprintf(`[{"type":"top","criteria":"=","format":%d,"value":"6","percent":true}]`, format))
  2777. //
  2778. // type: 2_color_scale - The 2_color_scale type is used to specify Excel's "2
  2779. // Color Scale" style conditional format:
  2780. //
  2781. // // Color scales: 2 color.
  2782. // f.SetConditionalFormat("Sheet1", "A1:A10", `[{"type":"2_color_scale","criteria":"=","min_type":"min","max_type":"max","min_color":"#F8696B","max_color":"#63BE7B"}]`)
  2783. //
  2784. // This conditional type can be modified with min_type, max_type, min_value,
  2785. // max_value, min_color and max_color, see below.
  2786. //
  2787. // type: 3_color_scale - The 3_color_scale type is used to specify Excel's "3
  2788. // Color Scale" style conditional format:
  2789. //
  2790. // // Color scales: 3 color.
  2791. // f.SetConditionalFormat("Sheet1", "A1:A10", `[{"type":"3_color_scale","criteria":"=","min_type":"min","mid_type":"percentile","max_type":"max","min_color":"#F8696B","mid_color":"#FFEB84","max_color":"#63BE7B"}]`)
  2792. //
  2793. // This conditional type can be modified with min_type, mid_type, max_type,
  2794. // min_value, mid_value, max_value, min_color, mid_color and max_color, see
  2795. // below.
  2796. //
  2797. // type: data_bar - The data_bar type is used to specify Excel's "Data Bar"
  2798. // style conditional format.
  2799. //
  2800. // min_type - The min_type and max_type properties are available when the conditional formatting type is 2_color_scale, 3_color_scale or data_bar. The mid_type is available for 3_color_scale. The properties are used as follows:
  2801. //
  2802. // // Data Bars: Gradient Fill.
  2803. // f.SetConditionalFormat("Sheet1", "K1:K10", `[{"type":"data_bar", "criteria":"=", "min_type":"min","max_type":"max","bar_color":"#638EC6"}]`)
  2804. //
  2805. // The available min/mid/max types are:
  2806. //
  2807. // min (for min_type only)
  2808. // num
  2809. // percent
  2810. // percentile
  2811. // formula
  2812. // max (for max_type only)
  2813. //
  2814. // mid_type - Used for 3_color_scale. Same as min_type, see above.
  2815. //
  2816. // max_type - Same as min_type, see above.
  2817. //
  2818. // min_value - The min_value and max_value properties are available when the
  2819. // conditional formatting type is 2_color_scale, 3_color_scale or data_bar. The
  2820. // mid_value is available for 3_color_scale.
  2821. //
  2822. // mid_value - Used for 3_color_scale. Same as min_value, see above.
  2823. //
  2824. // max_value - Same as min_value, see above.
  2825. //
  2826. // min_color - The min_color and max_color properties are available when the
  2827. // conditional formatting type is 2_color_scale, 3_color_scale or data_bar.
  2828. // The mid_color is available for 3_color_scale. The properties are used as
  2829. // follows:
  2830. //
  2831. // // Color scales: 3 color.
  2832. // f.SetConditionalFormat("Sheet1", "B1:B10", `[{"type":"3_color_scale","criteria":"=","min_type":"min","mid_type":"percentile","max_type":"max","min_color":"#F8696B","mid_color":"#FFEB84","max_color":"#63BE7B"}]`)
  2833. //
  2834. // mid_color - Used for 3_color_scale. Same as min_color, see above.
  2835. //
  2836. // max_color - Same as min_color, see above.
  2837. //
  2838. // bar_color - Used for data_bar. Same as min_color, see above.
  2839. //
  2840. func (f *File) SetConditionalFormat(sheet, area, formatSet string) error {
  2841. var format []*formatConditional
  2842. err := json.Unmarshal([]byte(formatSet), &format)
  2843. if err != nil {
  2844. return err
  2845. }
  2846. drawContFmtFunc := map[string]func(p int, ct string, fmtCond *formatConditional) *xlsxCfRule{
  2847. "cellIs": drawCondFmtCellIs,
  2848. "top10": drawCondFmtTop10,
  2849. "aboveAverage": drawCondFmtAboveAverage,
  2850. "duplicateValues": drawCondFmtDuplicateUniqueValues,
  2851. "uniqueValues": drawCondFmtDuplicateUniqueValues,
  2852. "2_color_scale": drawCondFmtColorScale,
  2853. "3_color_scale": drawCondFmtColorScale,
  2854. "dataBar": drawCondFmtDataBar,
  2855. "expression": drawConfFmtExp,
  2856. }
  2857. ws, err := f.workSheetReader(sheet)
  2858. if err != nil {
  2859. return err
  2860. }
  2861. cfRule := []*xlsxCfRule{}
  2862. for p, v := range format {
  2863. var vt, ct string
  2864. var ok bool
  2865. // "type" is a required parameter, check for valid validation types.
  2866. vt, ok = validType[v.Type]
  2867. if ok {
  2868. // Check for valid criteria types.
  2869. ct, ok = criteriaType[v.Criteria]
  2870. if ok || vt == "expression" {
  2871. drawfunc, ok := drawContFmtFunc[vt]
  2872. if ok {
  2873. cfRule = append(cfRule, drawfunc(p, ct, v))
  2874. }
  2875. }
  2876. }
  2877. }
  2878. ws.ConditionalFormatting = append(ws.ConditionalFormatting, &xlsxConditionalFormatting{
  2879. SQRef: area,
  2880. CfRule: cfRule,
  2881. })
  2882. return err
  2883. }
  2884. // UnsetConditionalFormat provides a function to unset the conditional format
  2885. // by given worksheet name and range.
  2886. func (f *File) UnsetConditionalFormat(sheet, area string) error {
  2887. ws, err := f.workSheetReader(sheet)
  2888. if err != nil {
  2889. return err
  2890. }
  2891. for i, cf := range ws.ConditionalFormatting {
  2892. if cf.SQRef == area {
  2893. ws.ConditionalFormatting = append(ws.ConditionalFormatting[:i], ws.ConditionalFormatting[i+1:]...)
  2894. return nil
  2895. }
  2896. }
  2897. return nil
  2898. }
  2899. // drawCondFmtCellIs provides a function to create conditional formatting rule
  2900. // for cell value (include between, not between, equal, not equal, greater
  2901. // than and less than) by given priority, criteria type and format settings.
  2902. func drawCondFmtCellIs(p int, ct string, format *formatConditional) *xlsxCfRule {
  2903. c := &xlsxCfRule{
  2904. Priority: p + 1,
  2905. Type: validType[format.Type],
  2906. Operator: ct,
  2907. DxfID: &format.Format,
  2908. }
  2909. // "between" and "not between" criteria require 2 values.
  2910. _, ok := map[string]bool{"between": true, "notBetween": true}[ct]
  2911. if ok {
  2912. c.Formula = append(c.Formula, format.Minimum)
  2913. c.Formula = append(c.Formula, format.Maximum)
  2914. }
  2915. _, ok = map[string]bool{"equal": true, "notEqual": true, "greaterThan": true, "lessThan": true, "greaterThanOrEqual": true, "lessThanOrEqual": true, "containsText": true, "notContains": true, "beginsWith": true, "endsWith": true}[ct]
  2916. if ok {
  2917. c.Formula = append(c.Formula, format.Value)
  2918. }
  2919. return c
  2920. }
  2921. // drawCondFmtTop10 provides a function to create conditional formatting rule
  2922. // for top N (default is top 10) by given priority, criteria type and format
  2923. // settings.
  2924. func drawCondFmtTop10(p int, ct string, format *formatConditional) *xlsxCfRule {
  2925. c := &xlsxCfRule{
  2926. Priority: p + 1,
  2927. Type: validType[format.Type],
  2928. Rank: 10,
  2929. DxfID: &format.Format,
  2930. Percent: format.Percent,
  2931. }
  2932. rank, err := strconv.Atoi(format.Value)
  2933. if err == nil {
  2934. c.Rank = rank
  2935. }
  2936. return c
  2937. }
  2938. // drawCondFmtAboveAverage provides a function to create conditional
  2939. // formatting rule for above average and below average by given priority,
  2940. // criteria type and format settings.
  2941. func drawCondFmtAboveAverage(p int, ct string, format *formatConditional) *xlsxCfRule {
  2942. return &xlsxCfRule{
  2943. Priority: p + 1,
  2944. Type: validType[format.Type],
  2945. AboveAverage: &format.AboveAverage,
  2946. DxfID: &format.Format,
  2947. }
  2948. }
  2949. // drawCondFmtDuplicateUniqueValues provides a function to create conditional
  2950. // formatting rule for duplicate and unique values by given priority, criteria
  2951. // type and format settings.
  2952. func drawCondFmtDuplicateUniqueValues(p int, ct string, format *formatConditional) *xlsxCfRule {
  2953. return &xlsxCfRule{
  2954. Priority: p + 1,
  2955. Type: validType[format.Type],
  2956. DxfID: &format.Format,
  2957. }
  2958. }
  2959. // drawCondFmtColorScale provides a function to create conditional formatting
  2960. // rule for color scale (include 2 color scale and 3 color scale) by given
  2961. // priority, criteria type and format settings.
  2962. func drawCondFmtColorScale(p int, ct string, format *formatConditional) *xlsxCfRule {
  2963. minValue := format.MinValue
  2964. if minValue == "" {
  2965. minValue = "0"
  2966. }
  2967. maxValue := format.MaxValue
  2968. if maxValue == "" {
  2969. maxValue = "0"
  2970. }
  2971. midValue := format.MidValue
  2972. if midValue == "" {
  2973. midValue = "50"
  2974. }
  2975. c := &xlsxCfRule{
  2976. Priority: p + 1,
  2977. Type: "colorScale",
  2978. ColorScale: &xlsxColorScale{
  2979. Cfvo: []*xlsxCfvo{
  2980. {Type: format.MinType, Val: minValue},
  2981. },
  2982. Color: []*xlsxColor{
  2983. {RGB: getPaletteColor(format.MinColor)},
  2984. },
  2985. },
  2986. }
  2987. if validType[format.Type] == "3_color_scale" {
  2988. c.ColorScale.Cfvo = append(c.ColorScale.Cfvo, &xlsxCfvo{Type: format.MidType, Val: midValue})
  2989. c.ColorScale.Color = append(c.ColorScale.Color, &xlsxColor{RGB: getPaletteColor(format.MidColor)})
  2990. }
  2991. c.ColorScale.Cfvo = append(c.ColorScale.Cfvo, &xlsxCfvo{Type: format.MaxType, Val: maxValue})
  2992. c.ColorScale.Color = append(c.ColorScale.Color, &xlsxColor{RGB: getPaletteColor(format.MaxColor)})
  2993. return c
  2994. }
  2995. // drawCondFmtDataBar provides a function to create conditional formatting
  2996. // rule for data bar by given priority, criteria type and format settings.
  2997. func drawCondFmtDataBar(p int, ct string, format *formatConditional) *xlsxCfRule {
  2998. return &xlsxCfRule{
  2999. Priority: p + 1,
  3000. Type: validType[format.Type],
  3001. DataBar: &xlsxDataBar{
  3002. Cfvo: []*xlsxCfvo{{Type: format.MinType}, {Type: format.MaxType}},
  3003. Color: []*xlsxColor{{RGB: getPaletteColor(format.BarColor)}},
  3004. },
  3005. }
  3006. }
  3007. // drawConfFmtExp provides a function to create conditional formatting rule
  3008. // for expression by given priority, criteria type and format settings.
  3009. func drawConfFmtExp(p int, ct string, format *formatConditional) *xlsxCfRule {
  3010. return &xlsxCfRule{
  3011. Priority: p + 1,
  3012. Type: validType[format.Type],
  3013. Formula: []string{format.Criteria},
  3014. DxfID: &format.Format,
  3015. }
  3016. }
  3017. // getPaletteColor provides a function to convert the RBG color by given
  3018. // string.
  3019. func getPaletteColor(color string) string {
  3020. return "FF" + strings.Replace(strings.ToUpper(color), "#", "", -1)
  3021. }
  3022. // themeReader provides a function to get the pointer to the xl/theme/theme1.xml
  3023. // structure after deserialization.
  3024. func (f *File) themeReader() *xlsxTheme {
  3025. var (
  3026. err error
  3027. theme xlsxTheme
  3028. )
  3029. if err = f.xmlNewDecoder(bytes.NewReader(namespaceStrictToTransitional(f.readXML("xl/theme/theme1.xml")))).
  3030. Decode(&theme); err != nil && err != io.EOF {
  3031. log.Printf("xml decoder error: %s", err)
  3032. }
  3033. return &theme
  3034. }
  3035. // ThemeColor applied the color with tint value.
  3036. func ThemeColor(baseColor string, tint float64) string {
  3037. if tint == 0 {
  3038. return "FF" + baseColor
  3039. }
  3040. r, _ := strconv.ParseInt(baseColor[0:2], 16, 64)
  3041. g, _ := strconv.ParseInt(baseColor[2:4], 16, 64)
  3042. b, _ := strconv.ParseInt(baseColor[4:6], 16, 64)
  3043. var h, s, l float64
  3044. if r >= 0 && r <= math.MaxUint8 && g >= 0 && g <= math.MaxUint8 && b >= 0 && b <= math.MaxUint8 {
  3045. h, s, l = RGBToHSL(uint8(r), uint8(g), uint8(b))
  3046. }
  3047. if tint < 0 {
  3048. l *= (1 + tint)
  3049. } else {
  3050. l = l*(1-tint) + (1 - (1 - tint))
  3051. }
  3052. br, bg, bb := HSLToRGB(h, s, l)
  3053. return fmt.Sprintf("FF%02X%02X%02X", br, bg, bb)
  3054. }