HTML to Excel Formatting Array Data

In my application I have a procedure which export data in an xls file.

To do so It use this kind of formatting:

   Plain Text: mso-number-format:@
   Format a number to 2 decimal places: mso-number-format:"0.00"
   Comma separators with 2 decimal places: mso-number-format:#,##0.00
   Date  Time Formating:
   American date: mso-number-format:mm/dd/yy
   Month name: mso-number-format:d-mmm-yyyy
   Date and Time: mso-number-format:d/m/yyyy h:mm AM/PM
   Short Date: mso-number-format:"Short Date" (05/06/2011)
   Medium Date: mso-number-format:"Medium Date" (10-jan-2011)
   Short Time: mso-number-format:"Short Time" (8:67)
   Medium Time: mso-number-format:"Medium Time" (8:67 AM)
   Long Time: mso-number-format:"Long Time"  (8:67:25:00)
   Percentage: mso-number-format:Percent (To two decimal places)
   Scientific Notation: mso-number-format:"0.E+00"
   Fractions - up to 3 digits: mso-number-format:"# ???/???"
   Currency (£12.76): mso-number-format:"{$content}22£{$content}22#,##0.00"
   2 decimals, negative numbers in red and signed: mso-number-format:"#,##0.00_ ;[Red]-#,##0.00 " (1.86-1.66)
   Accounting Format –5,(5): mso-number-format:”#,##0.00_);[Black]\(#,##0.00\)”
*/
   define("PLAINTEXT",     'mso-number-format:@');
   define("TWODECIMALS",   'mso-number-format:#,##0.00');
   define("SIXDECIMALS",   'mso-number-format:"0.000000"');
   define("DATE",          'mso-number-format:dd/mm/yy');
   define("CURRENCY",      'mso-number-format:"{$content}22€{$content}22#,##0.00"');

And then in a associative array procede with this annotation

private $baseStructure = array(
        'Category'       => array('label' => 'Category',         'format' => PLAINTEXT),
        'BaseCategory'   => array('label' => 'Base Category',    'format' => PLAINTEXT),

....

Basically (for what I’m understanding) it picks data from the db and create an xls file with it.

The problem occurs when I need to format a Json array, I can’t find a way to properly formatting it as a comma separated string and then in my excel it result like:

["Company1","Company2"]

I’ve tried by using this:

'Company'      => array('label' => 'Company',     'format' => ARRAY_FILTER_USE_KEY)

But with no result.

I think a missing the proper formatter but by Googling I only found the table that I’ve posted at the beginning of the post.

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *