php - PHPExcel for loop timeout
Get the solution ↓↓↓I have this code where I want to set from 3 to 333 to have a certain row height at every 30 interval, meaning at row 3, 33, 63, 93 up till 333:
for ($i=3; $i<340; $i+30){
$objPHPExcel->getActiveSheet()->getRowDimension($i)->setRowHeight(57);
}
But when I click on controller actionGenerate(), it doesn't generate and timeouts me after 30 seconds. Can I know why isn't it generating?
If I were to use the manual way, as in doing line by line, PLUS having so many different kinds of settings, I'd be exhausted.
Answer
Solution:
PHP
limits the execution time of any script. The default time is 30 seconds.
Your script probably takes longer than 30 seconds to execute.
Set yourset_time_limit
to0
.
This will set it to unlimited.
like this:
set_time_limit(0);
for ($i=3; $i<340; $i+=30){ // <--- here was your problem
$objPHPExcel->getActiveSheet()->getRowDimension($i)->setRowHeight(57);
}
And try again.
Info aboutset_time_limit
in the docs
-- edit--
The problem was in thefor
loop.
$i + 30
adds30
to$i
but it does not assign it.
It should be$i +=30
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: too few arguments to function laravel
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.