styles.go 93 KB

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