About laravel_excel

Before taking

$sheet->getStyle('A1:A5')->getNumberFormat()
        ->setFormatCode( \PHPExcel_Style_NumberFormat::FORMAT_TEXT ); //格式为文本

The way the cells into the text, but there's ID number or information in the form of scientific notation (here I still do not understand why there will be a text format to scientific notation, I saw a cell really is a text format) Although you can add spaces or single quotes in front of the data or the data behind the increase in "\ t", you can achieve good results on this show, but he did not escape detection Excel macros (which are written in the macro demand-side testing, whether single t backslash quotes space will always be a problem is detected), so asked to avoid detection of this macro is a headache for a long time, and then see another solution:

$sheet->setCellValueExplicit("A1",'这里填写数据',\PHPExcel_Cell_DataType::TYPE_STRING); //只能一个单元格一个单元格赋值

I find it to be perfect dodge Excel macro detection, suspect that is not getNumberFormat () function to my pit

而且 setCellValueExplicit 这个函数同时还可以起到修改表中值的作用!!!所以如果有修改表中单元格的值的需求,也可以用这个函数

Published 20 original articles · won praise 8 · views 50000 +

Guess you like

Origin blog.csdn.net/a26637896/article/details/82380577