[ Index ]
 

Code source de Dolibarr 2.0.1

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/htdocs/includes/php_writeexcel/ -> example-demo.php (source)

   1  <?php
   2  
   3  set_time_limit(10);
   4  
   5  require_once  "class.writeexcel_workbook.inc.php";
   6  require_once  "class.writeexcel_worksheet.inc.php";
   7  
   8  $fname = tempnam("/tmp", "demo.xls");
   9  $workbook =& new writeexcel_workbook($fname);
  10  $worksheet =& $workbook->addworksheet('Demo');
  11  $worksheet2 =& $workbook->addworksheet('Another sheet');
  12  $worksheet3 =& $workbook->addworksheet('And another');
  13  
  14  #######################################################################
  15  #
  16  # Write a general heading
  17  #
  18  $worksheet->set_column('A:B', 32);
  19  $heading  =& $workbook->addformat(array(
  20                                          bold    => 1,
  21                                          color   => 'blue',
  22                                          size    => 18,
  23                                          merge   => 1,
  24                                          ));
  25  
  26  $headings = array('Features of php_writeexcel', '');
  27  $worksheet->write_row('A1', $headings, $heading);
  28  
  29  #######################################################################
  30  #
  31  # Some text examples
  32  #
  33  $text_format =& $workbook->addformat(array(
  34                                              bold    => 1,
  35                                              italic  => 1,
  36                                              color   => 'red',
  37                                              size    => 18,
  38                                              font    => 'Comic Sans MS'
  39                                          ));
  40  
  41  $worksheet->write('A2', "Text");
  42  $worksheet->write('B2', "Hello Excel");
  43  $worksheet->write('A3', "Formatted text");
  44  $worksheet->write('B3', "Hello Excel", $text_format);
  45  
  46  #######################################################################
  47  #
  48  # Some numeric examples
  49  #
  50  $num1_format =& $workbook->addformat(array(num_format => '$#,##0.00'));
  51  $num2_format =& $workbook->addformat(array(num_format => ' d mmmm yyy'));
  52  
  53  $worksheet->write('A4', "Numbers");
  54  $worksheet->write('B4', 1234.56);
  55  $worksheet->write('A5', "Formatted numbers");
  56  $worksheet->write('B5', 1234.56, $num1_format);
  57  $worksheet->write('A6', "Formatted numbers");
  58  $worksheet->write('B6', 37257, $num2_format);
  59  
  60  #######################################################################
  61  #
  62  # Formulae
  63  #
  64  /*
  65  $worksheet->set_selection('B7');
  66  $worksheet->write('A7', 'Formulas and functions, "=SIN(PI()/4)"');
  67  $worksheet->write('B7', '=SIN(PI()/4)');
  68  */
  69  
  70  #######################################################################
  71  #
  72  # Hyperlinks
  73  #
  74  $worksheet->write('A8', "Hyperlinks");
  75  $worksheet->write('B8',  'http://www.php.net/');
  76  
  77  #######################################################################
  78  #
  79  # Images
  80  #
  81  $worksheet->write('A9', "Images");
  82  $worksheet->insert_bitmap('B9', 'php.bmp', 16, 8);
  83  
  84  #######################################################################
  85  #
  86  # Misc
  87  #
  88  $worksheet->write('A17', "Page/printer setup");
  89  $worksheet->write('A18', "Multiple worksheets");
  90  
  91  $workbook->close();
  92  
  93  header("Content-Type: application/x-msexcel");
  94  $fh=fopen($fname, "rb");
  95  fpassthru($fh);
  96  unlink($fname);
  97  
  98  ?>


Généré le : Mon Nov 26 12:29:37 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics