styles.go 93 KB

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