DataDownload

This commit is contained in:
schrom01 2023-02-15 17:12:23 +01:00
parent 8e2e2ecb61
commit 9501370fae
5 changed files with 29 additions and 2 deletions

3
SQL/Queries.sql Normal file
View File

@ -0,0 +1,3 @@
CREATE TABLE `u517357132_genderwatchpro`.`topics` ( `id` VARCHAR(8) CHARACTER SET ascii COLLATE ascii_bin NOT NULL , `lastSave` INT NULL DEFAULT CURRENT_TIMESTAMP , `fullJSON` JSON NOT NULL , `timeWatchM` INT NOT NULL , `timeWatchW` INT NOT NULL , `timeWatchD` INT NOT NULL , `countWatchM` INT NOT NULL , `countWatchW` INT NOT NULL , `countWatchD` INT NOT NULL , PRIMARY KEY (`id`)) ENGINE = InnoDB;
INSERT INTO `topics` (`id`, `lastSave`, `fullJSON`, `timeWatchM`,`timeWatchW`, `timeWatchD`, `countWatchM`, `countWatchW`, `countWatchD`) values ('test', 2014, '{}', 10, 10, 10, 10, 40, 10) ON DUPLICATE KEY UPDATE `id` = 'test'

Binary file not shown.

View File

@ -0,0 +1,4 @@
<?php
require $_SERVER['DOCUMENT_ROOT'] . '/spreadSheetReader/read_write_xlsx.php';
download_xlsxFile([]);

View File

@ -10,7 +10,7 @@
<section>
<div class="container">
<h1>Genderwatch-protocol</h1>
<a href="data/data.xlsx">Anonyme Daten herunterladen (aktuell in Entwicklung)</a>
<a href="dataCollector/download.php">Anonyme Daten herunterladen (aktuell in Entwicklung)</a>
<h2 style="margin-left: 10px;">Aktuelles Thema</h2>
<table class="table-bordered">
<tr>

View File

@ -2,8 +2,28 @@
require $_SERVER['DOCUMENT_ROOT'] . '/spreadSheetReader/SimpleXLSX.php';
require $_SERVER['DOCUMENT_ROOT'] . '/spreadSheetReader/SimpleXLSXGen.php';
function read_xls_file($filename){
$fileContent = [];
if ($xlsx = SimpleXLSX::parse($filename)) {
$fileContent = ($xlsx->rows());
} else {
echo SimpleXLSX::parseError();
}
return $fileContent;
}
function write_xlsxFile($filename, $data) {
$xlsx = SimpleXLSXGen::fromArray($data);
$xlsx->saveAs($filename);
}
function download_xlsxFile($data) {
$xlsx = SimpleXLSXGen::fromArray($data);
$xlsxArray = read_xls_file($_SERVER['DOCUMENT_ROOT'] ."/data/data.xlsx");
foreach ($data as $row) {
array_push($xlsxArray, $row);
}
$xlsx = SimpleXLSXGen::fromArray($xlsxArray);
$xlsx->downloadAs("data.xlsx");
}