1. Go to this page and download the library: Download baptouuuu/spreadsheet library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
baptouuuu / spreadsheet example snippets
use Spreadsheet\{
Spreadsheet,
Sheet,
Cell,
Position
};
$sheet = new Sheet('sheet 1');
$sheet = $sheet
->add(
new Cell(
new Position('A', 1),
'A1 value'
)
)
->add(
new Cell(
new Position('B', 2),
'B2 value'
)
);
$spreadsheet = new Spreadsheet('My Spreadsheet');
$spreadsheet = $spreadsheet->add($sheet);
use Spreadsheet\{
Writer\CsvWriter,
Formatter\FormatterInterface,
File\Csv
};
use Innmind\Immutable\Map;
$writer = new CsvWriter(';', true, new Map('string', FormatterInterface::class));
$file = $writer->write($spreadsheet);
$file instanceof Csv; //true
(string) $file->name(); //sheet 1.csv
(string) $file->content();
/*
A;B
A1;
;B2
*/
use Spreadsheet\{
Reader\CsvReader,
File\Csv,
Position
};
use Innmind\Filesystem\Stream\StringStream;
$reader = new CsvReader(';', true);
$spreadsheet = $reader->read(
new Csv(
'sheet.csv',
new StringStream(<<<CSV
A;B
A1;B1
CSV
)
)
);
$spreadsheet->name(); //sheet
$spreadsheet->get('sheet')->name(); //sheet
$spreadsheet->get('sheet')->get(new Position('A', 1))->value(); //A1
$spreadsheet->get('sheet')->get(new Position('B', 1))->value(); //B1
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.