use setValueCell() and AdvancedValueBinder

This commit is contained in:
Uwe Steinmann 2025-02-10 16:17:03 +01:00
parent 35ad154ab4
commit a5999caca3

View File

@ -129,7 +129,7 @@ class SeedDMS_Download_Mgr {
public function createToc($file) { /* {{{ */ public function createToc($file) { /* {{{ */
$objPHPExcel = new PhpOffice\PhpSpreadsheet\Spreadsheet(); $objPHPExcel = new PhpOffice\PhpSpreadsheet\Spreadsheet();
//$objPHPExcel->setValueBinder(new \PhpOffice\PhpSpreadsheet\Cell\AdvancedValueBinder()); $objPHPExcel->setValueBinder(new \PhpOffice\PhpSpreadsheet\Cell\AdvancedValueBinder());
$objPHPExcel->getProperties()->setCreator("SeedDMS")->setTitle("Metadata"); $objPHPExcel->getProperties()->setCreator("SeedDMS")->setTitle("Metadata");
if($items = $this->items) { if($items = $this->items) {
$sheet = $objPHPExcel->setActiveSheetIndex(0); $sheet = $objPHPExcel->setActiveSheetIndex(0);
@ -138,9 +138,9 @@ class SeedDMS_Download_Mgr {
$i = 1; $i = 1;
$col = 1; $col = 1;
foreach($this->header as $h) foreach($this->header as $h)
$sheet->setCellValueByColumnAndRow($col++, $i, $h); $sheet->setCellValue([$col++, $i], $h);
foreach($this->extraheader as $h) foreach($this->extraheader as $h)
$sheet->setCellValueByColumnAndRow($col++, $i, $h); $sheet->setCellValue([$col++, $i], $h);
$i++; $i++;
foreach($items as $item) { foreach($items as $item) {
if($item->isType('documentcontent')) { if($item->isType('documentcontent')) {
@ -151,11 +151,11 @@ class SeedDMS_Download_Mgr {
$approvalStatus = $item->getApprovalStatus(); $approvalStatus = $item->getApprovalStatus();
$col = 1; $col = 1;
$sheet->setCellValueByColumnAndRow($col++, $i, $document->getID()); $sheet->setCellValue([$col++, $i], $document->getID());
$sheet->setCellValueByColumnAndRow($col++, $i, $document->getName()); $sheet->setCellValue([$col++, $i], $document->getName());
$sheet->setCellValueByColumnAndRow($col++, $i, $document->getID()."-".$item->getOriginalFileName()); $sheet->setCellValue([$col++, $i], $document->getID()."-".$item->getOriginalFileName());
$sheet->setCellValueByColumnAndRow($col++, $i, getOverallStatusText($status['status'])); $sheet->setCellValue([$col++, $i], getOverallStatusText($status['status']));
$sheet->setCellValueByColumnAndRow($col++, $i, $item->getVersion()); $sheet->setCellValue([$col++, $i], $item->getVersion());
$l = $i; $l = $i;
$k = $i; $k = $i;
if($reviewStatus) { if($reviewStatus) {
@ -179,11 +179,11 @@ class SeedDMS_Download_Mgr {
break; break;
} }
$tcol = $col; $tcol = $col;
$sheet->setCellValueByColumnAndRow($tcol++, $l, $reqName); $sheet->setCellValue([$tcol++, $l], $reqName);
$sheet->setCellValueByColumnAndRow($tcol, $l, ($r['status']==1 || $r['status']==-1) ? \PhpOffice\PhpSpreadsheet\Shared\Date::PHPToExcel(new DateTime($r['date'])) : null); $sheet->setCellValue([$tcol, $l], ($r['status']==1 || $r['status']==-1) ? \PhpOffice\PhpSpreadsheet\Shared\Date::PHPToExcel(new DateTime($r['date'])) : null);
$sheet->getStyleByColumnAndRow($tcol++, $l)->getNumberFormat()->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_DATE_DATETIME); $sheet->getStyleByColumnAndRow($tcol++, $l)->getNumberFormat()->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_DATE_DATETIME);
$sheet->setCellValueByColumnAndRow($tcol++, $l, $r['comment']); $sheet->setCellValue([$tcol++, $l], $r['comment']);
$sheet->setCellValueByColumnAndRow($tcol++, $l, getReviewStatusText($r["status"])); $sheet->setCellValue([$tcol++, $l], getReviewStatusText($r["status"]));
$l++; $l++;
} }
$l--; $l--;
@ -210,11 +210,11 @@ class SeedDMS_Download_Mgr {
break; break;
} }
$tcol = $col; $tcol = $col;
$sheet->setCellValueByColumnAndRow($tcol++, $k, $reqName); $sheet->setCellValue([$tcol++, $k], $reqName);
$sheet->setCellValueByColumnAndRow($tcol, $k, ($r['status']==1 || $r['status']==-1) ? \PhpOffice\PhpSpreadsheet\Shared\Date::PHPToExcel(new DateTime($r['date'])) : null); $sheet->setCellValue([$tcol, $k], ($r['status']==1 || $r['status']==-1) ? \PhpOffice\PhpSpreadsheet\Shared\Date::PHPToExcel(new DateTime($r['date'])) : null);
$sheet->getStyleByColumnAndRow($tcol++, $k)->getNumberFormat()->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_DATE_DATETIME); $sheet->getStyleByColumnAndRow($tcol++, $k)->getNumberFormat()->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_DATE_DATETIME);
$sheet->setCellValueByColumnAndRow($tcol++, $k, $r['comment']); $sheet->setCellValue([$tcol++, $k], $r['comment']);
$sheet->setCellValueByColumnAndRow($tcol++, $k, getApprovalStatusText($r["status"])); $sheet->setCellValue([$tcol++, $k], getApprovalStatusText($r["status"]));
$k++; $k++;
} }
$k--; $k--;
@ -222,7 +222,7 @@ class SeedDMS_Download_Mgr {
$col += 4; $col += 4;
if(isset($this->extracols[$item->getID()]) && $this->extracols[$item->getID()]) { if(isset($this->extracols[$item->getID()]) && $this->extracols[$item->getID()]) {
foreach($this->extracols[$item->getID()] as $column) foreach($this->extracols[$item->getID()] as $column)
$sheet->setCellValueByColumnAndRow($col++, $i, is_array($column) ? implode("\n", $column) : $column ); $sheet->setCellValue([$col++, $i], is_array($column) ? implode("\n", $column) : $column );
} }
$i = max($l, $k); $i = max($l, $k);
$i++; $i++;
@ -240,9 +240,9 @@ class SeedDMS_Download_Mgr {
$i = 1; $i = 1;
$col = 1; $col = 1;
foreach($this->folder_header as $h) foreach($this->folder_header as $h)
$sheet->setCellValueByColumnAndRow($col++, $i, $h); $sheet->setCellValue([$col++, $i], $h);
foreach($this->folder_extraheader as $h) foreach($this->folder_extraheader as $h)
$sheet->setCellValueByColumnAndRow($col++, $i, $h); $sheet->setCellValue([$col++, $i], $h);
$i++; $i++;
$items = $this->folder_items; $items = $this->folder_items;
foreach($items as $item) { foreach($items as $item) {
@ -251,11 +251,11 @@ class SeedDMS_Download_Mgr {
$dms = $folder->_dms; $dms = $folder->_dms;
$col = 1; $col = 1;
$sheet->setCellValueByColumnAndRow($col++, $i, $folder->getID()); $sheet->setCellValue([$col++, $i], $folder->getID());
$sheet->setCellValueByColumnAndRow($col++, $i, $folder->getName()); $sheet->setCellValue([$col++, $i], $folder->getName());
if(isset($this->folder_extracols[$item->getID()]) && $this->folder_extracols[$item->getID()]) { if(isset($this->folder_extracols[$item->getID()]) && $this->folder_extracols[$item->getID()]) {
foreach($this->folder_extracols[$item->getID()] as $column) foreach($this->folder_extracols[$item->getID()] as $column)
$sheet->setCellValueByColumnAndRow($col++, $i, is_array($column) ? implode("\n", $column) : $column ); $sheet->setCellValue([$col++, $i], is_array($column) ? implode("\n", $column) : $column );
} }
$i++; $i++;
} }