Format The Cells For Entire Column In PHP Excel

2019-09-17 10:25发布

问题:

I have used the solution found within this Answer.

The code I used looks like this:

  $objWorksheet->getColumnDimension("AM")->setWidth(20);
  $objWorksheet->SetCellValue("AM1", "Date1");
  $objWorksheet->getStyle("AM")
                 ->getNumberFormat()
                   ->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_TEXT);

The one problem I had is when I select the entire column as such:

It still says "general".

But when I select a range of columns from 0 to 4500 lets say:

It shows up as "text".

If set to "General" the dates are auto-formmated by Excel and read wrong into PHPExcel.

Will these cells be read as "General" or as "Text"?

Can I rely that they will always be read as "Text" using this method?