Problem with Duplicating Style to More than 6 rows

Topics: Developer Forum, User Forum
Jun 11, 2009 at 3:21 PM

Hi All,

I am having a strange problem while duplicating the style using following method:

My Cell Style Defination:

$objPHPExcel->getActiveSheet()->getStyle('A5')->applyFromArray(
        array(
            'alignment' => array(
                'horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER,
                'vertical' => PHPExcel_Style_Alignment::VERTICAL_CENTER,
        ),
            'borders' => array(
                'top'     => array(
                     'style' => PHPExcel_Style_Border::BORDER_THIN
                 ),
                'bottom'     => array(
                     'style' => PHPExcel_Style_Border::BORDER_THIN
                 ),
                'right'     => array(
                     'style' => PHPExcel_Style_Border::BORDER_THIN
                 ),
                'left'     => array(
                     'style' => PHPExcel_Style_Border::BORDER_THIN
                 )
            )
        )
    );

following works fine:
    $objPHPExcel->getActiveSheet()->duplicateStyle( $objPHPExcel->getActiveSheet()->getStyle('A5'), 'B5:BT5' );

for ($rm=6;$rm<=11;$rm++){
         $range1="A".$rm.":BT".$rm;
         $objPHPExcel->getActiveSheet()->duplicateStyle( $objPHPExcel->getActiveSheet()->getStyle('A5'), $range1);
     }  // I get style duplicated upto row number 11

Following do not work:

$rownum=54;

  for ($rm=6;$rm<=$rownum;$rm++){
         $range1="A".$rm.":BT".$rm;
         $objPHPExcel->getActiveSheet()->duplicateStyle( $objPHPExcel->getActiveSheet()->getStyle('A5'), $range1);
     }

 

The problem starts when I do not get any error reported but written excel file is not recognized by Excel. Normally output file size is ~15kb but when i try to duplicate style using above output file is only some bytes normally abt 100 to 160bytes.  

Please I am writing excel in xlsx forma i.e Excel 2007.

Looking forward for a response:

 

Thanks and best Regards,

Developer
Jun 11, 2009 at 3:49 PM

Not sure what is causing this. Perhaps memory has been exhausted.

After PHPExcel 1.6.7 several changes have been made related to styling. I recommend that you try to download latest source code from here. It should be stable.
http://phpexcel.codeplex.com/SourceControl/ListDownloadableCommits.aspx

Using that, your script will probably run faster and use less memory. Also, duplicateStyleArray() is going to be deprecated. You may instead try the simpler syntax:

$objPHPExcel->getActiveSheet()->getStyle('B5:BT5')->applyFromArray($styleArray);

Notice that getStyle() accepts a cell range using latest source code.

Jun 11, 2009 at 3:59 PM
Hi Koyama,

Thank you for the reply, can you post me an example how to define $styleArray.

thanks and b
est Regards,


--
Rehan Azher


On Thu, Jun 11, 2009 at 10:49 PM, koyama <notifications@codeplex.com> wrote:

From: koyama

Not sure what is causing this. Perhaps memory has been exhausted.

After PHPExcel 1.6.7 several changes have been made related to styling. I recommend that you try to download latest source code from here. It should be stable.
http://phpexcel.codeplex.com/SourceControl/ListDownloadableCommits.aspx

Using that, your script will probably run faster and use less memory. Also, duplicateStyleArray() is going to be deprecated. You may instead try the simpler syntax:

$objPHPExcel->getActiveSheet()->getStyle('B5:BT5')->applyFromArray($styleArray);

Notice that getStyle() accepts a cell range using latest source code.

Read the full discussion online.

To add a post to this discussion, reply to this email (PHPExcel@discussions.codeplex.com)

To start a new discussion for this project, email PHPExcel@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


Developer
Jun 11, 2009 at 4:08 PM

$styleArray would be the array in your first example.

$styleArray = array(
    'alignment' => array(
        'horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER,
        'vertical' => PHPExcel_Style_Alignment::VERTICAL_CENTER,
    ),
    'borders' => array(
        'top' => array(
            'style' => PHPExcel_Style_Border::BORDER_THIN
         ),
        'bottom' => array(
            'style' => PHPExcel_Style_Border::BORDER_THIN
         ),
        'right' => array(
            'style' => PHPExcel_Style_Border::BORDER_THIN
         ),
        'left' => array(
            'style' => PHPExcel_Style_Border::BORDER_THIN
         ),
    ),
);

Jun 11, 2009 at 4:09 PM
Hi Koyama,

I tried the same with the following code:

$styleArray = array(
    'borders' => array(
        'allborders' => array(
            'style' => PHPExcel_Style_Border::BORDER_THICK,
            'color' => array('argb' => 'FFFF0000'),
            ),
        ),
    );
    $range="A5:BT".$rownum;  //$rownum here is 54
    $objPHPExcel->getActiveSheet()->getStyle($range)->applyFromArray($styleArray);


My output file is only 146 bytes and excel can not recognize it.  I am attaching both files , one with all data populated but formatting applied to first row only and 2nd with the unrecognized format.

 
Thanks and Best Regards,

--
Rehan Azher
Now in Sigapore
Cell: +65 92967887 Off: +6568988888


On Thu, Jun 11, 2009 at 11:00 PM, rehanazher <notifications@codeplex.com> wrote:

From: rehanazher

Hi Koyama,

Thank you for the reply, can you post me an example how to define $styleArray.

thanks and b
est Regards,


--
Rehan Azher


On Thu, Jun 11, 2009 at 10:49 PM, koyama <notifications@codeplex.com> wrote:

From: koyama

Not sure what is causing this. Perhaps memory has been exhausted.

After PHPExcel 1.6.7 several changes have been made related to styling. I recommend that you try to download latest source code from here. It should be stable.
http://phpexcel.codeplex.com/SourceControl/ListDownloadableCommits.aspx

Using that, your script will probably run faster and use less memory. Also, duplicateStyleArray() is going to be deprecated. You may instead try the simpler syntax:

$objPHPExcel->getActiveSheet()->getStyle('B5:BT5')->applyFromArray($styleArray);

Notice that getStyle() accepts a cell range using latest source code.

Read the full discussion online.

To add a post to this discussion, reply to this email (PHPExcel@discussions.codeplex.com)

To start a new discussion for this project, email PHPExcel@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


Read the full discussion online.

To add a post to this discussion, reply to this email (PHPExcel@discussions.codeplex.com)

To start a new discussion for this project, email PHPExcel@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


Jun 11, 2009 at 4:17 PM
One more thing, this do not relate to this issue but since I have caught you online , this is regarding Autosize i noticed that AutoSize do not work properly , its width calculation is not ok, can you tell me the source file name where it calculates the width so i can add some extra width myself but with this i would not be able to update my phpExcel class with the latest later on.

 
Best Regards,


--
Rehan Azher


On Thu, Jun 11, 2009 at 11:09 PM, rehanazher <notifications@codeplex.com> wrote:

From: rehanazher

Hi Koyama,

I tried the same with the following code:

$styleArray = array(
    'borders' => array(
        'allborders' => array(
            'style' => PHPExcel_Style_Border::BORDER_THICK,
            'color' => array('argb' => 'FFFF0000'),
            ),
        ),
    );
    $range="A5:BT".$rownum;  //$rownum here is 54
    $objPHPExcel->getActiveSheet()->getStyle($range)->applyFromArray($styleArray);


My output file is only 146 bytes and excel can not recognize it.  I am attaching both files , one with all data populated but formatting applied to first row only and 2nd with the unrecognized format.

 
Thanks and Best Regards,

--
Rehan Azher
Now in Sigapore
Cell: +65 92967887 Off: +6568988888


On Thu, Jun 11, 2009 at 11:00 PM, rehanazher <notifications@codeplex.com> wrote:

From: rehanazher

Hi Koyama,

Thank you for the reply, can you post me an example how to define $styleArray.

thanks and b
est Regards,


--
Rehan Azher


On Thu, Jun 11, 2009 at 10:49 PM, koyama <notifications@codeplex.com> wrote:

From: koyama

Not sure what is causing this. Perhaps memory has been exhausted.

After PHPExcel 1.6.7 several changes have been made related to styling. I recommend that you try to download latest source code from here. It should be stable.
http://phpexcel.codeplex.com/SourceControl/ListDownloadableCommits.aspx

Using that, your script will probably run faster and use less memory. Also, duplicateStyleArray() is going to be deprecated. You may instead try the simpler syntax:

$objPHPExcel->getActiveSheet()->getStyle('B5:BT5')->applyFromArray($styleArray);

Notice that getStyle() accepts a cell range using latest source code.

Read the full discussion online.

To add a post to this discussion, reply to this email (PHPExcel@discussions.codeplex.com)

To start a new discussion for this project, email PHPExcel@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


Read the full discussion online.

To add a post to this discussion, reply to this email (PHPExcel@discussions.codeplex.com)

To start a new discussion for this project, email PHPExcel@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


Read the full discussion online.

To add a post to this discussion, reply to this email (PHPExcel@discussions.codeplex.com)

To start a new discussion for this project, email PHPExcel@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


Developer
Jun 11, 2009 at 4:27 PM

Thanks, I received the files. If you open the defect file in a text editor, you will see the problem:

<br />
<b>Fatal error</b>:  Maximum execution time of 30 seconds exceeded in <b>C:\wamp\www\matrix\PHPExcel\Cell.php</b> on line <b>447</b><br />

Did you try the latest source code? Some changes have been made with autosize in latest source code, can you check whether is got better?

Jun 11, 2009 at 4:39 PM
Hi ,

Thanks for the guidance, I updated my php.ini for execution time, I need one more clue dont want to post on another new Discussion. If you have seen my file <working version> my columns are upto BT and setting all columns AutoSize True is a night mare, is there any method that can do this job in Batch manner. Sorry I haven't read all the documentation. oooooops.

Regarding the AutoSize (just now I downloaded the latest code but it still ) seems to be similar. I am attaching the recent output file
If you see S.No. Column and many others they are not fully expanded.

Thanks and Best Regards,


--
Rehan Azher


On Thu, Jun 11, 2009 at 11:28 PM, koyama <notifications@codeplex.com> wrote:

From: koyama

Thanks, I received the files. If you open the defect file in a text editor, you will see the problem:



Fatal error:  Maximum execution time of 30 seconds exceeded in C:\wamp\www\matrix\PHPExcel\Cell.php on line 447


Did you try the latest source code? Some changes have been made with autosize in latest source code, can you check whether is got better?

Read the full discussion online.

To add a post to this discussion, reply to this email (PHPExcel@discussions.codeplex.com)

To start a new discussion for this project, email PHPExcel@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


Jun 15, 2009 at 4:25 PM

I have the same issue using v1.6.7, I'll try the latest version and report back. Thanks for the suggestion.

Jun 16, 2009 at 5:17 PM

Just wanted to let you guys know that there is a huge improvement in the latest version from the SVN (I was actually using 1.6.6 earlier).

Thanks for the work that's going into this!