phpexcelphpexcelreader

PHPExcel: how to get hidden cell values / Scientific Number in Number?


In PHPExcel is there any format available to get proper reading of the order item value as shown in picture.

Excel Sheet Snapshot

I read whole the document but not find any solution for this problem.

For the date filled also if the data is shown ###### like way then how to get that as well?


Solution

  • In MS Excel, numbers that are larger than a certain size will be shown in scientific format (e.g. 1.40E+15) unless you set a format mask for that cell which says otherwise. The solution is to set an appropriate format mask, or to set the value as a string value.

    In MS Excel, if a string value is wider than the column size, then it will be shown as ######. The solution is to increase the column size.

    EDIT

    I can't tell you what the best column size is? That all depends on your data.... but you can either set columns to a fixed size using:

    $objPHPExcel->getActiveSheet()
        ->getColumnDimension('D')
        ->setWidth(32);
    

    or set a column to autocalculate the width

    $objPHPExcel->getActiveSheet()
        ->getColumnDimension('D')
        ->setAutoSize(true);
    

    Exactly as described in the PHPExcel docs

    Note that we do spend time and effort writing this documentation to try and answer your questions: it is worth reading.