0

I want to write a .xls. My data is stored in an array like this:

   Array
   (
        [1] => Array
        (
               [0] => CAGL0B04213g
               [1] => Strain CBS138 chromosome B complete sequence
               [2] => 11.02.03.04
               [3] => transcriptional control
               [4] => Transcription
               [5] => 0.15831099018927
               [6] => 1
               [7] => 0.31746031746032
        )

        [2] => Array
        (
               [0] => CAGL0B04213g
               [1] => Strain CBS138 chromosome B complete sequence
               [2] => 32.01.01
               [3] => oxidative stress response
               [4] => Cell rescue, defense and virulence
               [5] => 0.09289860600029
               [6] => 1
               [7] => 1.2048192771084
        )
   )

I used the method fromArray() and it works fine but when I open the .xls with, for example LibreOffice, entries like 32.01.01 were shown as '32.01.01 or entries like 40.01 were shown as 42,01. I tried this (Reading numbers as text format with PHPExcel) approach but I can't see any change. How can I write all values as STRING/TEXT and prevent that LibreOffice or Excel display them with data-format or number?

Thank you!

Community
  • 1
  • 1
user3017615
  • 549
  • 1
  • 5
  • 9
  • Quoting from accepted answer of the question you linked: `You'll have to store the numbers explicitly as strings, so you can't use fromArray(). Use setCellValueExplicit() or setCellValueExplicitByColumnAndRow() instead, passing a $pDataType argument of PHPExcel_Cell_DataType::TYPE_STRING.` – Matteo Tassinari Nov 25 '13 at 13:25
  • possible duplicate of [Reading numbers as text format with PHPExcel](http://stackoverflow.com/questions/12457610/reading-numbers-as-text-format-with-phpexcel) – Matteo Tassinari Nov 25 '13 at 13:26
  • okay, thank you. Now I just managed it! – user3017615 Nov 25 '13 at 14:48

1 Answers1

0

Since it applies here to, here is the important part of the accepted answer of another almost identical question:

You'll have to store the numbers explicitly as strings, so you can't use fromArray(). Use setCellValueExplicit() or setCellValueExplicitByColumnAndRow() instead, passing a $pDataType argument of PHPExcel_Cell_DataType::TYPE_STRING.

Community
  • 1
  • 1
Matteo Tassinari
  • 18,121
  • 8
  • 60
  • 81