ImportExcel icon indicating copy to clipboard operation
ImportExcel copied to clipboard

Error when imported data starts with equals sign ("=")

Open An-dir opened this issue 1 year ago • 8 comments

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 "=|0" and maybe some other errors, like counter in this and maybe other files.

Maybe you can fix it so that when you import, it will not crash, but handle it like the xlsx via csv did

An-dir avatar Jun 01 '23 07:06 An-dir