This repository has been archived on 2024-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
BiblioMxWeb/server/workbookExport.php
2022-02-06 18:03:19 +01:00

25 lines
624 B
PHP

<?php
require("vendor/autoload.php");
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
use PhpOffice\PhpSpreadsheet\Writer\Ods;
$spreadsheet = new Spreadsheet();
$reader = new \PhpOffice\PhpSpreadsheet\Reader\Csv();
$reader->setInputEncoding('CP1252');
$reader->setDelimiter(',');
$reader->setEnclosure('"');
$reader->setSheetIndex(0);
$spreadsheet = $reader->load("data/current.csv");
$writer = new Xlsx($spreadsheet);
$writer->save("data/current.xlsx");
$writer = new Ods($spreadsheet);
$writer->save("data/current.ods");
$spreadsheet->disconnectWorksheets();
unset($spreadsheet);