Files
faveo/vendor/maatwebsite/excel/docs/export/cells.md
Manish Verma 76e85db070 update 1.0.8.0
Commits for version update
2016-10-17 12:02:27 +05:30

1.2 KiB

Cell manipulation

$sheet->cell('A1', function($cell) {

    // manipulate the cell

});

$sheet->cells('A1:A5', function($cells) {

    // manipulate the range of cells

});

Set background

To change the background of a range of cells we can use ->setBackground($color, $type, $colorType)

// Set black background
$cells->setBackground('#000000');

Change fonts

// Set with font color
$cells->setFontColor('#ffffff');

// Set font family
$cells->setFontFamily('Calibri');

// Set font size
$cells->setFontSize(16);

// Set font weight to bold
$cells->setFontWeight('bold');

// Set font
$cells->setFont(array(
    'family'     => 'Calibri',
    'size'       => '16',
    'bold'       =>  true
));

Set borders

// Set all borders (top, right, bottom, left)
$cells->setBorder('solid', 'none', 'none', 'solid');

// Set borders with array
$cells->setBorder(array(
    'top'   => array(
        'style' => 'solid'
    ),
));

Set horizontal alignment

// Set alignment to center
$cells->setAlignment('center');

Set vertical alignment

// Set vertical alignment to middle
 $cells->setValignment('center');