Wednesday, 12 June 2019

PhpSpreadsheet - Get raw string value for d/m/Y dates instead of being converted to floats

I am trying to read an excel file that has 03/05/2008 kind of format, but when I read using PhpSpreadsheet, it returns me 2008.0.

Is there a way to get the raw string format of columns instead of converting to float?

try {
    $inputFileType = IOFactory::identify($path);

    try {
        $reader = IOFactory::createReader($inputFileType);
        $reader->setReadDataOnly(true);
        $valuesSpreadsheet = $reader->load($path);

        try {
           $spreadsheetArr = $valuesSpreadsheet->getActiveSheet()->toArray();
           dd($spreadsheetArr);
        }
     }
}

Edit: I don't want to get a specific cell and convert it to timestamp like the comments below. I want to get as array ->toArray() but getting all raw string formats.



from PhpSpreadsheet - Get raw string value for d/m/Y dates instead of being converted to floats

No comments:

Post a Comment