0

Here is the code within a method of a class:

        $this->p($result);//die();
        $this->spreadSheet($result);  //die();
        $this->p($result);die();

Result of first print call(this->p)

Array
        (
            [0] => Array
                (
                    [BLOCK_ID] => 537-14547
                    [SawnOn] => Gang saw
                    [ORIG_VOLUME_BRUT] => 179.67
                    [ORIG_VOLUME_NET] => 103.38
                    [COUTS_TOTAUX] => 2413.92
                    [COUTS_TRANSPORT] => 0
                    [SLABCOUNT] => 20
                    [totalSlabVolume] => 117.48
                    [totalSurfaceArea] => 1127.78
                    [totalValue] => 9563.56
                    [RECEPTION_DATE] => 03/22/2013
                    [1st Quality] => 100
                    [Second Quality] => 0
                    [Standard Slab] => 0
                )

            [1] => Array
                (
                    [BLOCK_ID] => 618-11523
                    [SawnOn] => Gang saw
                    [ORIG_VOLUME_BRUT] => 241.46
                    [ORIG_VOLUME_NET] => 171
                    [COUTS_TOTAUX] => 11858.85
                    [COUTS_TRANSPORT] => 0
                    [SLABCOUNT] => 56
                    [totalSlabVolume] => 143.44
                    [totalSurfaceArea] => 2295.03
                    [totalValue] => 21687.43
                    [RECEPTION_DATE] => 03/29/2013
                    [1st Quality] => 91.07
                    [Second Quality] => 7.14
                    [Standard Slab] => 1.79
                )

            [2] => Array
                (
                    [BLOCK_ID] => 237-14593
                    [SawnOn] => Gang saw
                    [ORIG_VOLUME_BRUT] => 312.5
                    [ORIG_VOLUME_NET] => 260.23
                    [COUTS_TOTAUX] => 12061.66
                    [COUTS_TRANSPORT] => 0
                    [SLABCOUNT] => 40
                    [totalSlabVolume] => 160.27
                    [totalSurfaceArea] => 1538.55
                    [totalValue] => 14016.18
                    [RECEPTION_DATE] => 03/22/2013
                    [1st Quality] => 0
                    [Second Quality] => 17.5
                    [Standard Slab] => 82.5
                )

        )

Result of second print out:

Array
(
[0] => Array
    (
        [BLOCK_ID] => 537-14547
        [SawnOn] => Gang saw
        [ORIG_VOLUME_BRUT] => 179.67
        [ORIG_VOLUME_NET] => 103.38
        [COUTS_TOTAUX] => 2413.92
        [COUTS_TRANSPORT] => 0
        [SLABCOUNT] => 20
        [totalSlabVolume] => 117.48
        [totalSurfaceArea] => 1127.78
        [totalValue] => 9563.56
        [RECEPTION_DATE] => 03/22/2013
        [1st Quality] => 100
        [Second Quality] => 0
        [Standard Slab] => 0
    )

[1] => Array
    (
        [BLOCK_ID] => 618-11523
        [SawnOn] => Gang saw
        [ORIG_VOLUME_BRUT] => 241.46
        [ORIG_VOLUME_NET] => 171
        [COUTS_TOTAUX] => 11858.85
        [COUTS_TRANSPORT] => 0
        [SLABCOUNT] => 56
        [totalSlabVolume] => 143.44
        [totalSurfaceArea] => 2295.03
        [totalValue] => 21687.43
        [RECEPTION_DATE] => 03/29/2013
        [1st Quality] => 91.06999999999999
        [Second Quality] => 7.14
        [Standard Slab] => 1.79
    )

[2] => Array
    (
        [BLOCK_ID] => 237-14593
        [SawnOn] => Gang saw
        [ORIG_VOLUME_BRUT] => 312.5
        [ORIG_VOLUME_NET] => 260.23
        [COUTS_TOTAUX] => 12061.66
        [COUTS_TRANSPORT] => 0
        [SLABCOUNT] => 40
        [totalSlabVolume] => 160.27
        [totalSurfaceArea] => 1538.55
        [totalValue] => 14016.18
        [RECEPTION_DATE] => 03/22/2013
        [1st Quality] => 0
        [Second Quality] => 17.5
        [Standard Slab] => 82.5
    )

)

Now see the value for 1st quality in Array[1] of second output. It has changed from 91.07 to 91.0699999999. What could have possibly caused this?

Here is the code for the 2 methods called in the code above:

    function spreadSheet($blocks)
{
    $this->excel->getProperties()->setCreator("Maper")
        ->setLastModifiedBy("Maper")
        ->setTitle("Maper")
        ->setSubject("Maper")
        ->setDescription("Maper")
        ->setKeywords("Maper")
        ->setCategory("Maper");
     $i=1;
    $col='A';
    $columns = $this->tableHeadings;
    foreach ($columns as $column) {
        $this->excel->getActiveSheet()->setCellValue($col++ . $i, $column);
    }


    foreach($blocks as $columns)
    {
        $i++;
        $col = 'A';
        foreach($columns as $column)
        {
            if($col=='A')$sheetName=$column;
            $this->excel->getActiveSheet()->setCellValue($col++ . $i, $column);

        }
       $this->_addSheet($sheetName);
        $this->excel->getActiveSheet()->getCell('A'.$i)->getHyperlink()->setUrl("sheet://'".$sheetName."'!A1");

    }
    $this->excel->getActiveSheet()->setTitle('Blocks');
    $this->setStyles();
    //$this->_forceSpreadsheetDownload();
    $this->_saveSpreadsheet();


}

the p method:

    function p($arr)
{
    echo"<pre>";
    print_r($arr);
    echo"</pre>";
}
4

0 回答 0