Skip to content

Commit

Permalink
Merge pull request #156 from dbarzin/dev
Browse files Browse the repository at this point in the history
fix import bug
  • Loading branch information
dbarzin authored Oct 4, 2024
2 parents 64173d9 + 2ecebc1 commit fcd16d7
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions app/Http/Controllers/MeasureImportController.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,23 +99,23 @@ function ($e) use ($model) {
);
// Get full path
$fileName = Storage::disk('local')->path($file);

// XLSX
$reader = new \PhpOffice\PhpSpreadsheet\Reader\Xlsx();
$reader->setReadDataOnly(true);
$spreadsheet = $reader->load($fileName);

$sheet = $spreadsheet->getSheet($spreadsheet->getFirstSheetIndex());
$data = $sheet->toArray();

if ($this->canImportFromFile($data, $request->has('clean'), $errors)) {
// Clear database
if ($request->has('clean')) {
$this->clean();
$errors->push('Database cleared');
}
$this->importFromFile($data, $errors);
}

// XLSX
$reader = new \PhpOffice\PhpSpreadsheet\Reader\Xlsx();
$reader->setReadDataOnly(true);
$spreadsheet = $reader->load($fileName);

$sheet = $spreadsheet->getSheet($spreadsheet->getFirstSheetIndex());
$data = $sheet->toArray();

if ($this->canImportFromFile($data, $request->has('clean'), $errors)) {
// Clear database
if ($request->has('clean')) {
$this->clean();
$errors->push('Database cleared');
}
$this->importFromFile($data, $errors);
}
} finally {
if ($request->file()) {
Expand Down

0 comments on commit fcd16d7

Please sign in to comment.