Excel file creation error with Phpexcel

Asked

Viewed 234 times

0

I would like to know the correct way to align the text in all columns; adjust the width of all columns; and also apply bold in ranges of cells.

The way my code is, it does correctly, however, generates the error below:

PHP Notice: Undefined index: in /home/menqcom1/public_html/php-excel/Phpexcel/Cell.php on line 820

//Mescla as celulas do titulo
$objPHPExcel->getActiveSheet()->mergeCells('A1:D1');

//Alinha o texto a Esquerda
$objPHPExcel->getActiveSheet()->getStyle('A1:E999')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);

// Definir a largura de todas as colunas    
$objPHPExcel->getActiveSheet()->getColumnDimension('A:Z')->setWidth(10);

// Formatar o intervalo A2:E3 a itálico
$objPHPExcel->getActiveSheet()->getStyle('A3:E3')->getFont()->setItalic(true);

// Formatar a cor do texto da célula A2 a azul
$objPHPExcel->getActiveSheet()->getStyle('A3:E3')->getFont()->getColor()->setARGB(PHPExcel_Style_Color::COLOR_BLUE);

// Indicação da criação do ficheiro
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');

// Formatar o intervalo A1:F1 a negrito
$objPHPExcel->getActiveSheet()->getStyle('A1:F1')->getFont()->setBold(true);
  • Your Lack of punctuation is disturbing! Is it not because you are formatting the merged cells along with the others not?

  • 1

    Try to change the single quotes for double quotes

  • @Wéllingthonm.Souza managed to solve. the error was because I created the file and then left a cell in bold, that is, I should first apply styles, etc to create the file. thank you

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.