0

is there any way to get placeholders in my excel file using phpspreadsheet? all I see I can do is using a specific cell to put my data into it eg. setCellValue('A1','John') I want to insert data into my excel where I have a placeholder not into a specific cell, looking for something similar to phpword eg. setValue($placeholder,'John')

I've been looking for a solution for quite a while now but I can't find any function to help me out.

CTD
  • 1

1 Answers1

1

You can try it.

    $spreadSheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet;
    $placeholder = 'D'
    $i = 5;
    $spreadSheet->getActiveSheet()->setCellValue($placeholder . $i, 'John');
poppies
  • 142
  • 6
  • thanks for answering figured it out on my own after i saw ur reply lol `foreach ($sheet->getRowIterator() as $row) { $cellIterator = $row->getCellIterator(); $cellIterator->setIterateOnlyExistingCells(TRUE); if($cellName == ""){ foreach ($cellIterator as $cell) { $value = $cell->getValue(); if($value == "John"){ $cellName = $cell->getCoordinate(); } }else { break; } }` – CTD May 21 '22 at 13:07