styles.go 95 KB

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