Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $CustomLogInfos #my phat item
- $fileName = "my-file_2022.01.31_04.10.34"
- $delimiter = ","
- $directoryPath = "C:\Users\path\"
- $csv = $directoryPath + $fileName + ".csv"
- $CustomLogInfos | Export-CSV -Path $csv -Force -NoTypeInformation
- $xlsx = $directoryPath + $fileName + ".xlsx"
- $excel = New-Object -ComObject excel.application
- $workbook = $excel.Workbooks.Add(1)
- $worksheet = $workbook.worksheets.Item(1)
- $TxtConnector = ("TEXT;" + $csv)
- $Connector = $worksheet.QueryTables.add($TxtConnector,$worksheet.Range("A1"))
- $query = $worksheet.QueryTables.item($Connector.name)
- $query.TextFileOtherDelimiter = $delimiter
- $query.TextFileParseType = 1
- $query.TextFileColumnDataTypes = ,1 * $worksheet.Cells.Columns.Count
- $query.AdjustColumnWidth = 1
- $query.Refresh()
- $query.Delete()
- $Workbook.SaveAs($xlsx,51)
- $excel.Quit()
- start excel.exe $xlsx
Add Comment
Please, Sign In to add comment