Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ikkez/f3-sheet
Some Excel and CSV utilities for PHP Fat-Free Framework
https://github.com/ikkez/f3-sheet
csv csv-utilities excel fat-free-framework
Last synced: 20 days ago
JSON representation
Some Excel and CSV utilities for PHP Fat-Free Framework
- Host: GitHub
- URL: https://github.com/ikkez/f3-sheet
- Owner: ikkez
- License: gpl-3.0
- Created: 2017-08-11T09:39:17.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-03-06T16:19:50.000Z (10 months ago)
- Last Synced: 2024-11-09T22:33:18.576Z (about 1 month ago)
- Topics: csv, csv-utilities, excel, fat-free-framework
- Language: PHP
- Size: 26.4 KB
- Stars: 11
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
### Sheet
Some Excel and CSV utilities for PHP Fat-Free Framework.
#### Example from Array of Data
```php
$excel = \Sheet::instance();// data array
$rows = [
[
"name" => "rose",
"color" => "red",
"num" => 15
],
[
"name" => "daisy",
"color" => "yellow",
"num" => 25,
],
[
"name" => "orchid",
"color" => "purple",
"num" => 7
]
];
// header array to rename the field labels and sort/reorder the data array
$headers = ['name'=>'Name', 'num'=>'Number', 'color'=>'Flower Color'];$excel->renderXLS($rows,$headers,"flowers.xls");
```In case your data array is not keyed, you can use the `applyHeader` method to transform the array:
```php
$rows = [
[
"rose",
"red",
15
],
[
"daisy",
"yellow",
25,
],
[
"orchid",
"purple",
7
]
];
$rows = \Sheet::instance()->applyHeader($rows,['name','color','num']);```
#### Example from Fat Free Mapper Object
```
//Setup mapper
$items = new \DB\SQL\Mapper($db,'mytable');//Load all items and map to associative array
$all = array_map(array($items,'cast'),$items->find());$csv = \Sheet::instance();
$csv->renderCSV($all, $items->fields(), "items.csv");
```#### Notice
The generated XLS can have problems in older versions of MS Office (Excel) with number-formatted fields not being recognized as such (displayed as text instead) and text fields, that contain line breaks can also leads to problems there (missing text).Nevertheless, these problems do not appear when opened with LibreOffice or OpenOffice or rendered as csv with `renderCSV` instead and then imported to excel.
## LicenseYou are allowed to use this plugin under the terms of the GNU General Public License version 3 or later.
Copyright (C) 2017 Christian Knuth [ikkez]