From dca07e06f5a75c9b336b110c6fc81158b9e7d01d Mon Sep 17 00:00:00 2001 From: Ryan Prather Date: Thu, 27 Sep 2018 14:27:57 -0400 Subject: [PATCH] Bug #18 fix --- inc/excelConditionalStyles.inc | 8 +++++++- ste/export.php | 6 +++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/inc/excelConditionalStyles.inc b/inc/excelConditionalStyles.inc index cd4fd04..3068162 100644 --- a/inc/excelConditionalStyles.inc +++ b/inc/excelConditionalStyles.inc @@ -353,10 +353,16 @@ $conditions['not_reviewed_count']->getStyle() ->setEndColor($yellow); $validation['host_status']->setType(\PhpOffice\PhpSpreadsheet\Cell\DataValidation::TYPE_LIST); -$validation['host_status']->setFormula1("=ValidStatus"); +$validation['host_status']->setAllowBlank(false); +$validation['host_status']->setFormula1('"Not Reviewed,Not a Finding,Open,Not Applicable,No Data,Exception,False Positive"'); $validation['host_status']->setShowDropDown(true); +$validation['host_status']->setShowErrorMessage(true); +$validation['host_status']->setError("Selected value not valid"); +$validation['host_status']->setErrorTitle("Invalid selection"); +$validation['host_status']->setErrorStyle(\PhpOffice\PhpSpreadsheet\Cell\DataValidation::STYLE_STOP); $validation['true_false']->setType(\PhpOffice\PhpSpreadsheet\Cell\DataValidation::TYPE_LIST); +$validation['true_false']->setAllowBlank(false); $validation['true_false']->setFormula1("=TRUE,FALSE"); $validation['true_false']->setShowDropDown(true); diff --git a/ste/export.php b/ste/export.php index 4ad2f9b..d6f0abe 100644 --- a/ste/export.php +++ b/ste/export.php @@ -239,8 +239,6 @@ foreach ($findings as $worksheet_name => $data) { $col = Coordinate::stringFromColumnIndex($col_id); $sheet->setCellValue("{$col}{$row}", $status); - $sheet->getCell("{$col}{$row}")->setDataValidation(clone $validation['host_status']); - $log->debug("Set data validation for target $host_name"); } $overall_str = "=IF(" . @@ -252,7 +250,6 @@ foreach ($findings as $worksheet_name => $data) { "COLUMNS(F{$row}:{$last_tgt_col}{$row}), TRUE, FALSE)"; $sheet->setCellValue($overall_col . $row, $overall_str); - $sheet->getCell("{$col}{$row}")->setDataValidation(clone $validation['host_status']); $sheet->setCellValue($same_col . $row, $same_str, true) ->getStyle("{$same_col}11:{$same_col}{$sheet->getHighestDataRow()}") @@ -266,6 +263,9 @@ foreach ($findings as $worksheet_name => $data) { $row++; } + $sheet->setDataValidation("{$col}11:{$col}{$row}", clone $validation['host_status']); + $log->debug("Set data validation for target $host_name"); + $log->debug("Completed STIG parsing"); $sheet->getStyle("F11:" . Coordinate::stringFromColumnIndex(count($data['target_list']) + 6) . $row) ->setConditionalStyles($host_status);