Search code examples
excelxmljsreport

jsreport excel xml attribute Format ISO-8601 date to custom `d-mmm-yy`


Any idea how to format ISO-8601 date to custom d-mmm-yy ?

I'm struggling to format date from ISO-8601 to custom numFmtId=15 cell. From my searching I found:

I was able to detect whether or not the column header that contains date keyword and whatever column value inside, but I was unable to format it properly.

The best I was able to found on jsreport related thread was: https://jsreport.net/learn/html-to-xlsx which wasn't helping me that much since I was using xlsx recipe.

You can see playground here which contains my progress so far.


Solution

  • To format cell you can add on style.xml:

      `<xf numFmtId="15" fontId="0" fillId="0" borderId="1" xfId="0" applyNumberFormat="1" applyFill="1" applyBorder="1" applyAlignment="1">
         <alignment horizontal="center" />
      </xf>`
    

    And update which part which using that format. example: <c t="d" s="4">

    You can see result on Playground here.

    The most helpful resources from which I've linked in the question: