-
Hello All, Thank you for this wonderful set of features for importing and exporting, I love to use your features. I have a working environment with many exports and imports. In an export I would like to achieve the following. I have multiple sheets and would like to have a sheet where i would use a Vlookup formula that searches values from another sheet. The expected result would be the following: But in my export I have #N/A in all cells that contains the formula, not even have the formula in the field only #N/A as text. In my config file the 'pre_calculate_formulas' => false is set. where #NAMEOFSHEET# is the proper name of the other sheet and $thisRowId represents the currentRow. if I put and simpler formula to a cell, such as SUM it creates the export with the proper formula in the cell and not with the calculated value. Is there any idea what am I doing wrong? thank you for your kind help! regs Tomi |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 7 replies
-
What is the PhpSpreadsheet expects a |
Beta Was this translation helpful? Give feedback.
-
I don't know what the Laravel wrapper might be doing, but this works as expected in PhpSpreadsheet: $spreadSheet = new Spreadsheet();
$workSheet = $spreadSheet->getActiveSheet();
$dataSheet = new \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet($spreadSheet, 'Data');
$spreadSheet->addSheet($dataSheet);
$data = [['XYZ', 'ABC'], ['WXY', 'DEF'], ['VWX', 'GHI'], ['UVW', 'JKL']];
$formula = '=VLOOKUP(A1,Data!B:C,2,false)';
$workSheet->getCell('A1')->setValue('VWX');
$workSheet->getCell('A2')->setValue($formula);
$dataSheet->fromArray($data, null, 'B1');
$writer = new \PhpOffice\PhpSpreadsheet\Writer\Xlsx($spreadSheet);
$writer->save("{$fileName}.xlsx"); |
Beta Was this translation helpful? Give feedback.
I don't know what the Laravel wrapper might be doing, but this works as expected in PhpSpreadsheet: