AhmadFais1611 / php-excel-reader

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

While reading xls column leading zeros stipped off #174

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Hi,
In my excel file i have a column leading '0', while reading from 
php-excel-reader zeros will stripped off. 

Is anyone earlier overcome this issue?
My Code is 
--------------------------------------------------
require_once 'excel_reader2.php';
$data = new Spreadsheet_Excel_Reader("stock.xls",false);
$data = $data->sheets[0][cells]; 
print_r($data);
--------------------------------------------------

output is 
---------------------------------------------------
Array
(
    [1] => Array
        (
            [1] => Style #
            [2] => Weight
            [3] => Available Stock
            [4] => Inspection
            [5] => On Order Quantity
            [6] => Estimated Arrival Date
        )

    [2] => Array
        (
            [1] => 54025
            [2] => 99
            [3] => -10
            [4] => 0
            [5] => 0
            [6] => 0
        )

    [3] => Array
        (
            [1] => 313070
            [2] => 58
            [3] => -1
            [4] => 0
            [5] => 0
            [6] => 0
        )
--------------------------------------------------------------

Original issue reported on code.google.com by stephenp...@gmail.com on 6 Jun 2013 at 1:31

Attachments:

GoogleCodeExporter commented 8 years ago
Your issue does not have so much to with the library, instead you can get your 
correct result by using the str_pad function when you're reading that very 
column:

$val = str_pad($val, 7, 0, STR_PAD_LEFT);

Original comment by endar...@gmail.com on 16 Jun 2013 at 12:55