| type | cell type |
| name | cell name (A1, B11) |
| value | cell value (1233, 1233.34, 2022-02-21 00:00:00, String) |
| href | internal and external links |
| f | formula |
| s | style index, use $xlsx->cellFormats[ $index ] to get style |
| css | generated cell CSS |
| r | row index |
| hidden | hidden row or column |
| width | width in custom units |
| height | height in points (pt, 1/72 in) |
| comment | Cell comment as plain text |
### Select Sheet
```php
$xlsx = SimpleXLSX::parse('book.xlsx');
// Sheet numeration started 0, we select second worksheet
foreach( $xlsx->rows(1) as $r ) {
// ...
}
```
### Get sheet by index
```php
$xlsx = SimpleXLSX::parse('book.xlsx');
echo 'Sheet Name 2 = '.$xlsx->sheetName(1);
```
### XLSX::parse remote data
```php
if ( $xlsx = SimpleXLSX::parse('https://www.example.com/example.xlsx' ) ) {
$dim = $xlsx->dimension(1); // don't trust dimension extracted from xml
$num_cols = $dim[0];
$num_rows = $dim[1];
echo $xlsx->sheetName(1).':'.$num_cols.'x'.$num_rows;
} else {
echo SimpleXLSX::parseError();
}
```
### XLSX::parse memory data
```php
// For instance $data is a data from database or cache
if ( $xlsx = SimpleXLSX::parseData( $data ) ) {
print_r( $xlsx->rows() );
} else {
echo SimpleXLSX::parseError();
}
```
### Get Cell (slow)
```php
echo $xlsx->getCell(0, 'B2'); // The Hobbit
```
### DateTime helpers
```php
// default SimpleXLSX datetime format is YYYY-MM-DD HH:MM:SS (ISO, MySQL)
echo $xlsx->getCell(0,'C2'); // 2016-04-12 13:41:00
// custom datetime format
$xlsx->setDateTimeFormat('d.m.Y H:i');
echo $xlsx->getCell(0,'C2'); // 12.04.2016 13:41
// unixstamp
$xlsx->setDateTimeFormat('U');
$ts = $xlsx->getCell(0,'C2'); // 1460468460
echo gmdate('Y-m-d', $ts); // 2016-04-12
echo gmdate('H:i:s', $ts); // 13:41:00
// raw excel value
$xlsx->setDateTimeFormat( NULL ); // returns as excel datetime
$xd = $xlsx->getCell(0,'C2'); // 42472.570138889
echo gmdate('m/d/Y', $xlsx->unixstamp( $xd )); // 04/12/2016
echo gmdate('H:i:s', $xlsx->unixstamp( $xd )); // 13:41:00
```
### Rows with header values as keys
```php
if ( $xlsx = SimpleXLSX::parse('books.xlsx')) {
// Produce array keys from the array values of 1st array element
$header_values = $rows = [];
foreach ( $xlsx->rows() as $k => $r ) {
if ( $k === 0 ) {
$header_values = $r;
continue;
}
$rows[] = array_combine( $header_values, $r );
}
print_r( $rows );
}
```
```
Array
(
[0] => Array
(
[ISBN] => 618260307
[title] => The Hobbit
[author] => J. R. R. Tolkien
[publisher] => Houghton Mifflin
[ctry] => USA
)
[1] => Array
(
[ISBN] => 908606664
[title] => Slinky Malinki
[author] => Lynley Dodd
[publisher] => Mallinson Rendel
[ctry] => NZ
)
)
```
### Debug
```php
use Shuchkin\SimpleXLSX;
ini_set('error_reporting', E_ALL );
ini_set('display_errors', 1 );
if ( $xlsx = SimpleXLSX::parseFile('books.xlsx', true ) ) {
echo $xlsx->toHTML();
} else {
echo SimpleXLSX::parseError();
}
```
### Classic OOP style
```php
use SimpleXLSX;
$xlsx = new SimpleXLSX('books.xlsx'); // try...catch
if ( $xlsx->success() ) {
foreach( $xlsx->rows() as $r ) {
// ...
}
} else {
echo 'xlsx error: '.$xlsx->error();
}
```
More examples [here](https://github.com/shuchkin/simplexlsx/tree/master/examples)
### Error Codes
SimpleXLSX::ParseErrno(), $xlsx->errno()