9 Mo of invalid tag error

Topics: Developer Forum, User Forum
Feb 10, 2015 at 3:09 AM
Ok I have 2 files that seems the same...

1 file works really well and i get what i want.

the other file, not so much i get so many php errors but to me they seem like the same type of documents with the same sheets and everything...

i get those errors

Warning: DOMDocument::loadHTMLFile(): Tag cell invalid in Facebook-Insights-Data-Export-86WORX-2015-01-22.xls, line: 11313 in C:\wamp\www\Facebook\Classes\PHPExcel\Reader\HTML.php on line 427

for like 1000 times

can you guys help me to get what is wrong ?

<?php 
set_include_path(dirname(__FILE__) . PATH_SEPARATOR . get_include_path());

require 'Classes/PHPExcel.php';
require 'Classes/PHPExcel/IOFactory.php';
// libxml_use_internal_errors(true);
?> 


<?php

if(isset($_FILES['file_upload']))
{
    
    
    Upload();
    
    $sheetname = 'Daily Liked and online';
    $name = $_FILES["file_upload"]["name"]; 
    $thefile = $name;
    
    $inputFileType = PHPExcel_IOFactory::identify($thefile);
    $objReader = PHPExcel_IOFactory::createReader($inputFileType);
    $objReader->setReadDataOnly(true);
    $objReader->setLoadSheetsOnly($sheetname);
    $objPHPExcel = $objReader->load($thefile);
    $objWorksheet = $objPHPExcel->getActiveSheet();
    
    $total_sheets=$objPHPExcel->getSheetCount(); 
    //$allSheetName=$objPHPExcel->getSheetNames(); 
    $objWorksheet = $objPHPExcel->setActiveSheetIndex($total_sheets-1); 
    
    
    $highestRow = $objWorksheet->getHighestRow(); 
    $highestColumn = $objWorksheet->getHighestColumn();  
    $highestColumnIndex = PHPExcel_Cell::columnIndexFromString($highestColumn);  
                for ($row = 6; $row <= $highestRow;++$row) 
                {  
                    $first = 0;
                    $colfirst = 0;
                    $second = 0;
                    $colsecond = 0;
                    $third = 0;
                    $colthird = 0;
                    $highertempo = 0;
                    
                    for ($bouclecol = 1; $bouclecol < 4; ++$bouclecol)
                    {
                    
                        for ($col = 1; $col <$highestColumnIndex;++$col)
                        {  

                            $value=$objWorksheet->getCellByColumnAndRow($col, $row)->getFormattedValue();  
                            if ($col >= 2)
                            {
                                if ($value > $first )
                                {
                                    if ($first > $second)
                                    {
                                        if ($second > $third)
                                        {
                                            $third = $second;
                                            $colthird = $colsecond;
                                        }
                                        $second = $first;
                                        $colsecond = $colfirst;
                                    }
                                    $first = $value;
                                    $colfirst = $col;
                                }
                                else
                                {
                                    if ($value > $second and $col <> $colfirst)
                                    {
                                        if ($second > $third)
                                        {
                                            $third = $second;
                                            $colthird = $colsecond;
                                        }
                                        $second = $value;
                                        $colsecond = $col;
                                    }
                                    else
                                    {
                                        if ($value > $third and $col <> $colfirst and $col <> $colsecond)
                                        {
                                            $third = $value;
                                            $colthird = $col;
                                        }
                                    }
                                }
                                $tempo = $objWorksheet->getCellByColumnAndRow(2,$row)->getFormattedValue();
                                if ($tempo <> null )
                                {
                                $tempodate = $objWorksheet->getCellByColumnAndRow(1,$row)->getFormattedValue();
                                $tempodate = strtotime($tempodate);
                                $arraydata[$row-1][3]=date("l",$tempodate); ;
                                
                                if ($colfirst >=10)
                                {
                                $arraydata[$row-1][4]="{$colfirst} : 00 | {$first}" ; 
                                }
                                else
                                {
                                $arraydata[$row-1][4]="0{$colfirst} : 00 | {$first}" ; 
                                }
                                
                                if ($colsecond >=10)
                                {
                                $arraydata[$row-1][5]="{$colsecond} : 00 | {$second}" ; 
                                }
                                else
                                {
                                $arraydata[$row-1][5]="0{$colsecond} : 00 | {$second}" ; 
                                }
                                
                                if ($colthird >=10)
                                {
                                $arraydata[$row-1][6]="{$colthird} : 00 | {$third}" ; 
                                }
                                else
                                {
                                $arraydata[$row-1][6]="0{$colthird} : 00 | {$third}" ; 
                                }
                                
                                }
                            }
                            else
                            {
                                $tempo =$objWorksheet->getCellByColumnAndRow(2,$row)->getFormattedValue();
                                if ($tempo <> null )
                                {
                                $arraydata[$row-1][$col] = $value;
                                }   
                            }
                

                        }  
                    }

                }
    //unlink($_FILES["file_upload"]["name"]);
    
    //print_r($arraydata);
} 
function Upload() 
{
// Check for errors
    if($_FILES['file_upload']['error'] > 0)
    {
        die('An error ocurred when uploading.');
    }

    $ext = substr(strrchr($_FILES['file_upload']['name'], "."), 1);
    //Check filetype
    if($ext != 'xls')
    {
        die('Unsupported filetype uploaded.');
    }

    // Check filesize
    //if($_FILES['file_upload']['size'] > 5000000)
    //{
    //  die('File uploaded exceeds maximum upload size.');
    //}
    
    $path = getcwd();
    
    
    $uploads_dir = $path;
    $tmp_name = $_FILES["file_upload"]["tmp_name"];
    $name = $_FILES["file_upload"]["name"];

    if (!move_uploaded_file($tmp_name, $name)) 
    {
        die('Error uploading file - check destination is writeable.');
    }
  
}
?>

<!DOCTYPE html>
<html>
<head>
  <title>Import Facebook Data</title>
</head>

<body>


<table border="1" width="75%">
    <?php
    $NbrCol     = 5;
    $NbrLigne   = 8;
    ?>
    <thead>
        <td width="10%">Date</td>
        <td>Weekday</td>
        <td>1</td>
        <td>2</td>
        <td>3</td>
    </thead>

    <tbody>

    <?php if (count(@$arraydata) > 0): ?>
        
        <?php foreach (@$arraydata as $row): array_map('htmlentities', $row); ?>
        <tr>
        <td><?php echo implode('</td><td>', $row); ?></td>
        </tr>
        <?php endforeach; ?>
    
    
        <?php endif; ?>
    </tbody>
    
    


</table>
    <table>
            <form method='post' enctype='multipart/form-data' action='Excel Importer.php'>
            File: <input type='file' name='file_upload'>
            <input type='submit'>
            </form>
    
    

    <table>
<?php


?>

</body>

</html>