創(chuàng)建一個(gè)文件,使用第一個(gè)參數(shù)作為文件名。
Excel::create('Filename');
可以使用回調(diào)函數(shù)操作創(chuàng)建的文件。
Excel::create('Filename', function($excel) {
// Call writer methods here
});
更改屬性
有幾個(gè)屬性可以改變 大多數(shù)設(shè)置了默認(rèn)。
Excel::create('Filename', function($excel) {
// Set the title 設(shè)置標(biāo)題
$excel->setTitle('Our new awesome title');
// Chain the setters 設(shè)置創(chuàng)作人
$excel->setCreator('Maatwebsite') ->setCompany('Maatwebsite');
// Call them separately 設(shè)置 介紹說明
$excel->setDescription('A demonstration to change the file properties');
});
Exporting導(dǎo)出
To download the created file, use->export($ext) or ->download($ext).
下載創(chuàng)建的excel
Export to Excel5 (xls)格式
Excel::create('Filename', function($excel) {
})->export('xls');
// or
->download('xls');
Export to Excel2007 (xlsx)格式
->export('xlsx');
// or
->download('xlsx');
Export to CSV格式
->export('csv');
// or
->download('csv');
(未完待續(xù)...)