PHPOffice / PHPExcel

ARCHIVED
Other
11.46k stars 4.19k forks source link

PHPExcel removes Data Validation Option of Excel sheet after editing existing Excel Sheet #330

Open logindian opened 10 years ago

logindian commented 10 years ago

I am using PHPExcel for editing existing excel sheets.

I had already set up a Data Validation method in my excel sheet untitled

When i edit this excel using PHPExcel, this Excel Specific Data Validation vanishes.

I am using MSoffice 2007; For snapshots: please refer to this question : http://stackoverflow.com/questions/22119876/phpexcel-removes-data-validation-option-of-excel-sheet-after-editing-existing-ex

My PHP code:

//load existing template.. $objPHPExcel = PHPExcel_IOFactory::load('www/PHPExcelReader/Excel_Uploads/sample.xls');

// Set document properties $objPHPExcel->getProperties()->setCreator("Logic Item") ->setLastModifiedBy("Logic") ->setTitle("List"); $objPHPExcel->setActiveSheetIndex(0)->setCellValue('AZ1', $combination);

// Set active sheet index to the first sheet, so Excel opens this as the first sheet $objPHPExcel->setActiveSheetIndex(0); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); $file_name='sample.xls'; $objWriter->save($file_name); echo "Excel is ready to download now...";

MarkBaker commented 10 years ago

Unable to replicate this problem, can you please provide a spreadsheet file that demonstrates the issue

logindian commented 10 years ago

I am unable to attach the xls file here. Please provide email id. How did i create the issue is, I had set up an validation on A1 cell from G1:G4 cells. Intially G1:G4 is empty so A1 will show one blank dropdown list. Then i am writing G1:G4 using PHPExcel , values are written but A1 cell does not have the validation.

GuillaumeRossolini commented 7 years ago

Hi,

I ran into this problem.

To reproduce:

  1. Create an empty workbook from Excel;
  2. The first and second sheets will be filled by end-users, while the third will be their datasource;
  3. Rename all three sheets;
  4. Fill some data in sheet 3;
  5. Set some cells or columns in sheets 1 and 2 as validated by validation lists from columns in sheet 3;
  6. Save the file;
  7. Update the data in Sheet 3 with a PHP script and save as a new file.

Now open the new workbook with Excel: the cells that were list-validated are now just plain cells. All data validation parameters seem to be gone: title, error message, datasource.