PHP code example of rich-id / excel-generator-bundle

1. Go to this page and download the library: Download rich-id/excel-generator-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

rich-id / excel-generator-bundle example snippets


use RichId\ExcelGeneratorBundle\Annotation as Excel;
use RichId\ExcelGeneratorBundle\Model\ExcelContent;

/**
 * @Excel\HeaderStyle(color="#FFFFFF", backgroundColor="#C1D9E1", fontSize=18, position=Excel\Style::POSITION_CENTER)
 */
class PersonContent extends ExcelContent
{
    /**
     * @var string
     *            
     * @Excel\ContentStyle(color="#000000", fontSize=12, wrapText=true)
     * @Excel\HeaderTitle(title="app.person.firstname")
     */
   public $firstname;
   
    /**
     * @var string
     *            
     * @Excel\ContentStyle(color="#000000", fontSize=12, bold=true, wrapText=true)
     * @Excel\HeaderTitle(title="app.person.lastname")
     */
   public $lastname;
   
    /**
     * @var string
     *            
     * @Excel\ContentStyle(color="#000000", fontSize=10)
     * @Excel\HeaderTitle(title="app.person.age")
     */
   public $age;
   
   public function __construct(User $user)
   {
        $this->firstname = $user->getFirstname();
        $this->lastname = $user->getLastname();
        $this->age = $user->getAge();
        
        foreach ($user->getAddresses() as $address) {
            $addressContent = new AddressContent($address);
            $this->addChild($addressContent);
        }
   }
}