I want to export my data to excel using phpspreadsheet but my data is number in 12 character. So I need to display all the character (121212121212) instead of (1.21212E+11).
I have try the format using
PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_TEXT
and
PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_NUMBER
It doesn't work.
This is my cell formatting code:
$spreadsheet->getActiveSheet()->getStyle('B')->getNumberFormat()
->setFormatCode(PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_TEXT);
This is my value insert code:
$sheet->setCellValue('A'.$i, $i-1);
$sheet->setCellValue('B'.$i, $useric);
If I use the FORMAT_TEXT the result is this:

when using PHPSpreadsheet, this is what I do.
$spreadsheet->getActiveSheet()
->getCell('A1')
->setValueExplicit(
$someNumber,
\PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING2
);
If by any chance you using PHPExcel, maybe you can do something like this
$spreadsheet->getActiveSheet()
->setCellValueExplicit('A1', $someNumber, PHPExcel_Cell_DataType::TYPE_STRING);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With