PHP Excel Question - Opencart
  • I'm attempting to add a new sheet using the PHP Excel library on some
    fairly popular open-source code. I know some basic programming, but this
    nested line confuses me.

    $j=0

    $worksheet->getColumnDimensionByColumn($j++)->setWidth(max(strlen('price_prefix'),5)+1,$text_format);
    ...

    I'm most concerned with what looks like the 2nd parameter of the strlen
    function, '5' in the above line. But it might be more useful to get a
    break-down of the whole line to show what's going on here.
    Thanks in advance!
  • 2 Comments sorted by
  • i think in above code here you just writing column name to worksheet that's why its getting length of column where you writing line there also put same code for strlen.
  • Thanks for the response ithacker.  I'm looking for a more specific answer if possible. Like, this is actually a statement that calls out to the getWidth function in the PHPExcel library. My assumption is that it's trying to create a column width for database item it's importing.
    What I'm trying to understand in this case is what the parameters mean to that function? For instance, is 'max' looking for the highest count of the strlen of 'price_prefix' and 5? Is the +1 just to change how the count is indexed, or is it a parameter of setWidth? What is the purpose? The third parameter looks like it's the value of a variable that formats the column, but I'm not sure.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, or you want to Ask a new Question, Please Login or Create a new Account by Clicking below

Login with Facebook

Tagged

Popular Posts of the Week

Top Posters Weekly

Optimum Creative