epocnova / php-excel

Automatically exported from code.google.com/p/php-excel
MIT License
0 stars 0 forks source link

fix Number Stored as Text error #8

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. add some rows that have numbers in them
2. download
3. Excel gives Number Stored as text error.

What is the expected output? What do you see instead?
Excel gives Number Stored as text error.

What version of the product are you using? On what operating system?
1.0 on Mac OSX.

Please provide any additional information below.
Here is my fix:

        foreach ($array as $k => $v):
            $ssType = "String";
            if(is_numeric($v)) {
                $ssType = "Number";
            }
            $cells .= "<Cell><Data ss:Type=\"".$ssType."\">" .
utf8_encode($v) . "</Data></Cell>\n"; 

        endforeach;

Original issue reported on code.google.com by selfprop...@gmail.com on 1 Oct 2007 at 4:19

GoogleCodeExporter commented 9 years ago
If the above doesn't work try this

foreach($line_arr as $col)
{
     $dtype = (is_numeric($col)) ? 'x:num':'';
     $line.="<td class=xl24 width=64 ".$dtype.">".$col."</td>";
}

Original comment by ilayaraj...@gmail.com on 7 Jul 2009 at 10:50

GoogleCodeExporter commented 9 years ago
Thanks for your input. There is a new branch available:

http://code.google.com/p/php-excel/source/browse/#svn/branches/version02

This version addresses your issue. In Germany we have the problem that the 
automagic
type identification may lead to the corruption of article numbers starting with 
a 0
(zero) or postcodes. This is why I set the types to String by default.

However, the new version will support the automatic identification of types, 
when you
set a certain parameter in the constructor:

$xls = new Excel_XML('UTF-8', true);

Using 'true' will activate the automatic conversion, so that numeric strings get
defined as Number in the XML.

Original comment by oliver.s...@gmail.com on 10 Sep 2009 at 9:55

GoogleCodeExporter commented 9 years ago
I will address this issue with a new version and/or a patch for version 1.

Original comment by oliver.s...@gmail.com on 10 Sep 2009 at 12:27

GoogleCodeExporter commented 9 years ago
Thanks again for posting your fix. I've addressed this issue in the new version 
1.1,
which is available in the [http://code.google.com/p/php-excel/downloads/list 
download
section] of the project.

However, activating the auto-type identification remains optional since there 
are
cases where you do not want the library to autoconvert values (for example: 
german
postcodes starting with 0).

Original comment by oliver.s...@gmail.com on 10 Sep 2009 at 2:20

GoogleCodeExporter commented 9 years ago
i had the same issue,
just removing the white space(s) before or after the strings - Solved. :D

Original comment by bhavinra...@gmail.com on 10 Nov 2012 at 7:25