Xls
Handle Xls file
Handle Xls file
Create $Xls. Then iterate through the set of pages and add selected values to file data. Lastly, return data as XLS file:
$Xls = $this->get('xls')->setFilename('testname.xls');
foreach ( $Orders as $Order ){
$Xls->addRow(
$Order->product,
$Order->price
);
}
$Xls->outputFile();
Setting the data one cell at a time:
foreach ( $Orders as $Order ){
$Xls->newRow();
$Xls->addCol($Order->product);
$Xls->addCol($Order->price);
}
Setting colums:
$Xls->addCol('Määrä','number'); // value is formatted as number
$Xls->addCol('Päivä','date'); // value is formatted as date
$Xls->addCol(Array(
'title' => 'Määrä',
'type' => 'number',
'hidden' => false // If TRUE, col is not shown
));
Method | Return type | Description |
---|---|---|
setFilename(string) | this | Set output filename. |
getFilename() | string | Return the set output filename. |
addCol(title,type) | this | Set column definition |
addCol(array) | this | Set column definition |
Method | Return type | Description |
---|---|---|
newRow() | this | Add new empty line. |
addRow(array) | this | Add new row from array. |
addRow(col1,col2,..) | this | Add new row from arguments. |
addCell(data) | this | Add new cell to last line. |
Method | Return type | Description |
---|---|---|
getData() | array | Return the data as two dimensional array. |
getRowIndex() | int | Return the index of last row. |
isRows() | int | Return TRUE if there are any data. |
countRows() | int | Return number of lines. |
countCols() | int | Return max number of cols. |
getWriter([format]) | Writer | Return spreadsheet Writer object. |
getContent([format]) | string | File content |
saveToFile(file,[format]) | bool | Save to file. Return true if sucess. |
outputFile() | void | Send XLS file to browser. |