styles.go 94 KB

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