Manuel Pear

Format::setBorderColor

Format::setBorderColor -- Définit toutes les bordures de la cellule à une même couleur

Synopsis

  1. <?php
  2. require_once "Spreadsheet/Excel/Writer.php
  3. ?> 

void Format::setBorderColor (mixed $color)

Description

Définit toutes les bordures de la cellule à une même couleur.

Paramètres

  • mixed $color - La couleur définie. Soit une chaîne (comme 'blue'), soit un entier (l'intervalle est [8...63]).

    Reportez-vous à la section sur << utilisation des couleurs >> du manuel pour plus d'informations.

Note

Cette fonction ne peut pas être appelée de façon statique.

Exemple

Exemple 43-1. Exemple avec setBorderColor()

  1. <?php
  2. require_once 'Spreadsheet/Excel/Writer.php';  
  3.  
  4. $workbook = new Spreadsheet_Excel_Writer();  
  5. $worksheet =& $workbook->addWorksheet();  
  6. // nous pouvons définir toutes les propriétés lors de l'instanciation
  7. $upper_right_side_brick =& $workbook->addFormat(array('right' => 5, 'top' => 5, 'size' => 15, 
  8.                                        'pattern' => 1, 'bordercolor' => 'blue', 
  9.                                        'fgcolor' => 'red'));  
  10. // ou définir toutes les propriétés une par une
  11. $upper_left_side_brick =& $workbook->addFormat();  
  12. $upper_left_side_brick->setLeft(5);  
  13. $upper_left_side_brick->setTop(5);  
  14. $upper_left_side_brick->setSize(15);  
  15. $upper_left_side_brick->setPattern(1);  
  16. $upper_left_side_brick->setBorderColor('blue');  
  17. $upper_left_side_brick->setFgColor('red');  
  18.  
  19. $lower_right_side_brick =& $workbook->addFormat(array('right' => 5, 'bottom' => 5, 'size' => 15, 
  20.                                        'pattern' => 1, 'bordercolor' => 'blue', 
  21.                                        'fgcolor' => 'red'));  
  22. $lower_left_side_brick =& $workbook->addFormat(array('left' => 5, 'bottom' => 5, 'size' => 15, 
  23.                                        'pattern' => 1, 'bordercolor' => 'blue', 
  24.                                        'fgcolor' => 'red'));  
  25.  
  26. $worksheet->setColumn(0, 20, 6);  
  27.  
  28. // Ciel
  29. $sky =& $workbook->addFormat(array('fgcolor' => 'cyan', 'pattern' => 1, 'size' => 15));  
  30. for ($i = 0; $i <= 10; $i++)  
  31. { 
  32.    for ($j = 0; $j < 20; $j++) { 
  33.       $worksheet->writeBlank($i, $j, $sky); 
  34.    }  
  35. }  
  36.  
  37. // Nuageux
  38. $cloud =& $workbook->addFormat(array('fgcolor' => 'white', 'pattern' => 1, 'size' => 15));  
  39. $worksheet->writeBlank(5, 7, $cloud);  
  40. $worksheet->writeBlank(4, 8, $cloud);  
  41. $worksheet->writeBlank(5, 8, $cloud);  
  42. $worksheet->writeBlank(6, 8, $cloud);  
  43. $worksheet->writeBlank(4, 9, $cloud);  
  44. $worksheet->writeBlank(5, 9, $cloud);  
  45. $worksheet->writeBlank(5, 10, $cloud);  
  46.  
  47. // Briques
  48. for ($j = 0; $j < 20; $j++)  
  49. { 
  50.    for ($i = 5; $i <= 11; $i++) 
  51.    { 
  52.       if (($i + $j)%2 == 1) // côté droit de la brique
  53.       { 
  54.          $worksheet->writeBlank(2*$i, $j, $upper_right_side_brick); 
  55.          $worksheet->writeBlank(2*$i + 1, $j, $lower_right_side_brick); 
  56.       } 
  57.       else // côté gauche de la brique
  58.       { 
  59.          $worksheet->writeBlank(2*$i, $j, $upper_left_side_brick); 
  60.          $worksheet->writeBlank(2*$i + 1, $j, $lower_left_side_brick); 
  61.       } 
  62.    }  
  63. }  
  64.  
  65. // On cache la grille pour qu'elle ne gâche pas notre art Excel ;)
  66. $worksheet->hideGridLines();  
  67.  
  68. $workbook->send('bricks.xls');  
  69. $workbook->close(  
  70. ?> 

Remonter Remonter
L'éditeur javascript - CSS - Gentoo - Tutoriaux PHP - Tutoriels PHP - Bretagne - php - Moto - Kit graphique