Quantcast
Channel: Active questions tagged excel - Stack Overflow
Viewing all articles
Browse latest Browse all 88854

Imported .csv file with formulas

$
0
0

I have imported a comma seperated csv file using powershell. I gets imported and looks as it should. The problem is, the cells contain formulas. Like =20+50+70. It doesn't get calculated unless i click enter i the top field. Another problem is, that some of the cells contains numbers like =50,2+70,5. These cells excel doesn't understand at all. It can't caltulate them, unless i remove the , or replace it with a dot (.). But this is not a possibility. How to i fix this? The csv file is imported with powershell using this:

[threading.thread]::CurrentThread.CurrentCulture = 'en-US'
$wbpath=Join-Path "$psscriptroot"'file.xlsx'
$importcsv=Join-Path "$psscriptroot"'file.csv'
$xl = New-Object -ComObject Excel.Application
$xl.Visible = $false
$xl.Workbooks.OpenText($importcsv)
$xl.DisplayAlerts = $false
[threading.thread]::CurrentThread.CurrentCulture = 'en-US'
$xl.ActiveWorkbook.SaveAs($wbpath,51)
$xl.Quit()
while([System.Runtime.Interopservices.Marshal]::ReleaseComObject($xl)){'released'}

The

[threading.thread]::CurrentThread.CurrentCulture = 'en-US'

is necessary or i will get errors because my system locale is not us.

Thank you.

CSV Sample:

name1.name1.name1,"=20","=7,65","=20,01"
name2.name2.name2,"=20+10","=4,96+0,65","=20,01+10"
name3.name3.name3,"=20","=4,96+0,88","=21,01+11"

Viewing all articles
Browse latest Browse all 88854

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>