Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Formula cells have their contents changed #38

Open
claudioimai opened this issue Mar 22, 2023 · 0 comments
Open

Formula cells have their contents changed #38

claudioimai opened this issue Mar 22, 2023 · 0 comments

Comments

@claudioimai
Copy link

claudioimai commented Mar 22, 2023

Not sure if this bug has appeared/fixed somewhere, but I couldn't find any help, and I've been trying it all day:

I have this loop in my code:
foreach($report as $prod){ $sheetParams['{id_produto}'][$idx] = $prod['codigo']; $sheetParams['{product_name}'][$idx] = $prod['titulo']; $sheetParams['preco_compra'][$idx] = $prod['preco_compra']; $sheetParams['preco_venda'][$idx] = $prod['precoVenda']; $sheetParams['qde'][$idx] = (int)$prod['qde']; $sheetParams['[subtotalcompra]'][$idx] = '=E'. ($idx+6) . '*C'.($idx+6); $sheetParams['[subtotalvenda]'][$idx] = '=E'. ($idx+6) . '*D'.($idx+6); $sheetParams['[lucro_bruto]'][$idx] = '=G'. ($idx+6) . '-F'.($idx+6); $idx++; }

After filling the arrays, I send it using

PhpExcelTemplator::saveToFile($templateFile, $fileName, $sheetParams);

one of the arrays ([subtotalcompra]) gets the values:
[[subtotalcompra]] => Array ( [0] => '=E6*C6' [1] => '=E7*C7' )

whereas the other ([subtotalvenda]) is

[[subtotalvenda]] => Array ( [0] => '=E6*D6' [1] => '=E7*D7' )

The template file uses them in 2 columns, which should be the multiplication formulas for each row, but only the first row gets the correct values, '=E6*C6' and '=E6*D6'

The other cells get their values as '=E9*D9' and the cell to the right has '=E10*D10'

The indexes for each cell are changed as if the cell count somehow interferes in the string used for the formulas.
Even weirder is that the values are changed as if some regex acts on the string, changing every cell in the resulting spreadsheet.

I could even trace some data change into phpoffice/phpspreadsheet but was unable to find what could be happening before the data changed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant