Load Excel from HTML Table with all cell values loaded explicitly?

Topics: User Forum
Feb 2, 2016 at 11:29 PM
Edited Feb 2, 2016 at 11:29 PM
I currently have some code which will take an HTML table stored in a temporary file and parse it into a PHPExcel object:
        // insert $table into $objPHPExcel's Active Sheet through $excelHTMLReader
        PHPExcel_Cell::setValueBinder( new PHPExcel_Cell_AdvancedValueBinder() );
        $objPHPExcel     = new PHPExcel();
        $excelHTMLReader = PHPExcel_IOFactory::createReader('HTML');
        $excelHTMLReader->loadIntoExisting($tmpfile, $objPHPExcel);
        $objPHPExcel->getActiveSheet()->setTitle('Excel Export'); 
The HTML table is valid, and it works pretty well.

However, I do not want the cells to automatically detect formatting. I would like all cell content to be entered explicitly such that long strings like "1111111111111" aren't treated as an int, or "000002" doesn't have the leading zeroes deleted.

I've checked, and it seems that when doing this that the values are automatically pre-formatted. Thus <td>00001</td> is stored as "1", etc.

I could perhaps extend the PHPExcel_Reader_HTML class and re-write some functions, but I'd rather not do this.

Is there an easier way to store all values from an HTML table as explicit non-formatted values?

Feb 4, 2016 at 12:15 PM
Personally, I'd use a custom Value Binder to set everything explicitly to string if you want this