ImportExcel
ImportExcel copied to clipboard
Error when imported data starts with equals sign ("=")
I have noticed that there are problems importing data if the imported text starts with a "=". There may be a better solution than the current one.
#How I did my tests with unsatisfactory results
# Testresult: Errors
"Col1;Col2`r`ntext;=|0" | ConvertFrom-Csv -Delimiter ";" | Export-Excel test1.xlsx -AutoFilter -AutoSize
# Testresult: Displays the '-character
"Col1;Col2`r`ntext;'=|0" | ConvertFrom-Csv -Delimiter ";" | Export-Excel -AutoFilter -AutoSize
# works but with ugly interpretation as text in a formula
"Col1;Col2`r`ntext;=`"=|0`"" | ConvertFrom-Csv -Delimiter ";" | Export-Excel -AutoFilter -AutoSize
In an old issue you wrote ( https://github.com/dfinke/ImportExcel/issues/1007#issuecomment-798961673 ) that Excel interprets this as a formula, but the following test looks promising that there may be a better solution:
# Here is how I expect it to be handled (delimiter is language dependend in your test):
"Col1;Col2`r`ntext;=|0" | ConvertFrom-Csv -Delimiter ";" | Export-Csv test.csv -Delimiter ";" -NoTypeInformation
start excel test.csv
Then save as xlsx has no problem with displaying it as string and reopen the xlsx without errors. The recognition as a formula starts when you try to make changes - then you can decide what you want to do with the data.
There can be more characters than the "=" character or "'" at the beginning, wich can cause problems when importing.
It looks like in the "sharedStrings.xml" is missing "
Maybe you can fix it so that when you import, it will not crash, but handle it like the xlsx via csv did