none
Open csv with semi column separator and save as excel format

    Domanda

  • I Open csv with semi column separator and want save as excel format
    Excel can be open and format as proper excel column separate by semi column but when save, it give error
    $workbook.SaveAs("c:\temp\merged.xlsx")  -> give You cannot call a method on a null-valued expression

    $excel = New-Object -ComObject excel.application
    $excel.visible = $False
    $excel.displayalerts=$False
    $workbook = $excel.Workbooks.OpenText("c:\temp\merged.csv",$xlWindows,1,1,1,$True,$True,$False,$True,$False,$False)
    #$workbook = $excel.Workbooks.Open("$workdir\merged.csv")
    $workbook.SaveAs("c:\temp\merged.xlsx")
    $workbook.Close()
    $excel.quit()
    $excel = $null

    why

    when $excel.Workbooks.Open -> write-host $workbook give System.__ComObject
    when $excel.Workbooks.Opentext -> write-host $workbook give blank/nothing

    Can someone please help?

    mercoledì 27 giugno 2012 12:29

Risposte

Tutte le risposte