Using PHP to export data to Excel files, no Phpexcel class, wrote a simple program
Generate an Excel file, and then enter the data one line at a
But the ID number output into a scientific count, there is a solution on the Internet, one is the front quotation marks, can solve the problem,
Another http://www.cnblogs.com/jcz120 ...
But feel good trouble, ask you, besides these two solutions, there is no other way?
Thank you, everyone.
Reply content:
Using PHP to export data to Excel files, no Phpexcel class, wrote a simple program
Generate an Excel file, and then enter the data one line at a
But the ID number output into a scientific count, there is a solution on the Internet, one is the front quotation marks, can solve the problem,
Another http://www.cnblogs.com/jcz120 ...
But feel good trouble, ask you, besides these two solutions, there is no other way?
Thank you, everyone.
Adding a space to the ID number is actually converting the number to a string.
Precede the ID number with a single quotation mark (single quote in the English input state), such as ' 4400202 ....
Either add a single quotation mark, or pre-format the cell to text format, these two are the simplest solution, but also trouble ...
Front Plus Single quote:$objPHPExcel->getActiveSheet()->setCellValue('A1', "'". 123456789033);
Specify the data type:$objPHPExcel->getActiveSheet()->setCellValueExplicit('A1',123456789033, PHPExcel_Cell_DataType::TYPE_STRING);
Very simple, once encountered, add a "431226198910135411" in the back. \ t ", fully resolved. If you solve your problem, please remember powder a oh, public number: Phpgod.
+ + + Update Split line, time: 2016-10-9 11:18:09+++
Segmentfault editor really disgusting to me, above the T unexpectedly gave me escaped, 艹!
What format Excel file do you generate, csv
xls
or xlsx
, 1,3 words, generate relatively good processing, csv
by delimiter, but not bad processing string, xlsx
is XML (feel you should be wrapped up to handle this bar), xlsx
The format has a special string of XML, you need to put the string into the XML, and then according to the string ordinal to fetch (so the design estimate can reduce the repetition of string occupation resources). But use it PHPExcel
, just use it, Composer require
I have written a library to read and generate Excel, the later compatibility what is more troublesome, directly used PHPExcel
. After all, others filled a lot of pits.
Another way of phpexcel handling strings is mentioned upstairs.
Copy upstairs:
$objPHPExcel->getActiveSheet()->setCellValueExplicit('A1',123456789033, PHPExcel_Cell_DataType::TYPE_STRING);