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
Export-Excel not correctly evaluating formulas containing table references #1360
Comments
Please post an xlsx with the data and tables |
@dfinke The excel file was originally created with:
It then gets populated with:
|
replace Col3 = '=[@Col2]*2' |
Wow, that works! Interesting, |
TIPS from me: Try to pass object only with data(no formulas,no formatting,only data) into export-excel and then format file. It works better |
@dfinke When adding data to an existing file populated with data where some formulas don't contain table references. For instance, see Excel Test 2.xlsx Data in
When adding data to
You get this output, see Excel Test 2_Code 1.xlsx Output from
However, when adding data to
You get this output, see Excel Test 2_Code 2.xlsx Output from
If you then add data to
You get this output, see Excel Test 2_Code 2_Append.xlsx Output from
Note the formula in Row 6 Col4: it changed from |
As @oliwex stated, a better way to do this is to generate the file, then adjust. $data = ConvertFrom-Csv @"
COL1,COL2
20,200
30,300
40,400
50,500
"@
$path = 'C:\TEMP\example1.xlsx'
Remove-Item -Path $path -ErrorAction SilentlyContinue
$excel = $data | Export-Excel -Path $path -PassThru
$sheet = $excel.Workbook.Worksheets["Sheet1"]
Set-ExcelColumn -Worksheet $sheet -Heading "COL3" -Value {"=B$row*2"}
Close-ExcelPackage -ExcelPackage $excel -Show |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
When exporting data that contains formulas with table references with Export-Excel, the cells containing formulas with table references don't evaluate correctly.
For example,
Output with the above code
The example code saves the data to the end of the existing Table but the value in Column C shows #REF! (the formula for the cell is =#REF!*2)
The value in Column C should be 200.
The text was updated successfully, but these errors were encountered: