:::

2-2 套用樣板

  1. 好處是不用全部都用程式來寫,可以自己設定好各種花俏的格式,程式只負責把值填上
    <?php
    
    require 'vendor/autoload.php';
    
    $spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load('test.xlsx');
    
    $worksheet = $spreadsheet->getActiveSheet();
    
    $worksheet->getCell('A1')->setValue('套用樣板測試');
    
    header('Content-Type: application/vnd.ms-excel');
    header('Content-Disposition: attachment;filename="套用樣板測試.xls"');
    header('Cache-Control: max-age=0');
    
    $writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Xls');
    $writer->save('php://output');
    

     

  2. 簡單的樣板:text.xlsx

:::

書籍目錄

展開 | 闔起

https%3A%2F%2Fcampus-xoops.tn.edu.tw%2Fmodules%2Ftad_book3%2Fpage.php%3Ftbdsn%3D1337%26tbsn%3D36

計數器

今天: 617617617
昨天: 2027202720272027
總計: 7971658797165879716587971658797165879716587971658