styles.go 93 KB

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