mysql-php export Excel data, ID output problem

Source: Internet
Author: User
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 ...

    1. Front Plus Single quote:$objPHPExcel->getActiveSheet()->setCellValue('A1', "'". 123456789033);

    2. 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);
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.