Create workbookExport.php

This commit is contained in:
MatMasIt 2022-02-06 18:03:19 +01:00 committed by GitHub
parent d3a49e1b27
commit 1123dc6947
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

24
server/workbookExport.php Normal file
View File

@ -0,0 +1,24 @@
<?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);