setAutoSize(true); $Acolumnsize = $objPHPEx...">

Get width of Auto Size column in PHPExcel

$objPHPExcel->getActiveSheet()->getColumnDimension("A")->setAutoSize(true);

$Acolumnsize = $objPHPExcel->getActiveSheet()->getColumnDimension("A")->getWidth();

echo "<h1>" . $Acolumnsize . "</h1>";

I want to set the column to auto size. In this case, column A.

Once it was auto-sized, I want to use the value when determining the width of another column, so I need to know how much space A takes.

Every time I used the code above, the width of column A is -1, so the column width is not set. Therefore, it seems that automatic calibration does not set the column width for any reason.

I am wondering how do I get the width of a column with auto size?

+4
source share
1 answer

Worksheet calculateColumnWidths. , , . :

$objPHPExcel->getActiveSheet()->calculateColumnWidths();

.

+4

Source: https://habr.com/ru/post/1538726/


All Articles