I have a simple spreadsheet with a number formatted as text:
I want to use PhpSpreadsheet to determine that the number is indeed formatted as text instead of the default "General". So I do this:
<?php
use PhpOffice\PhpSpreadsheet\IOFactory;
require 'vendor/autoload.php';
$reader = IOFactory::createReader('Xlsx');
$reader->setReadDataOnly(TRUE);
$cell = $reader->load('index.xlsx')->getActiveSheet()->getCell('A1');
var_dump($cell->getValue(), $cell->getStyle()->getNumberFormat()->getFormatCode());
But the result is always this:
float(12345)
string(7) "General"
How to determine if the number is formatted as "Text"?
12345
to12346
, save the file, and test again. When I do that, I get the correct result.PHPOffice/PhpSpreadsheet
repository that took me down that path.