It is working successfully when I manually running it. In script the storage cmd will run and generate a CSV data and I tried to put it as source for this script. Hi, I tried to using this csv to Excel convert in one of storage Capacity reporting script. ![]() $xlsx = "c:/path/to/save/files/$filename.xlsx" # Names Excel file same name as CSV #$xlsx = "$Path/$filename.xlsx" # Names & saves Excel file same name/location as CSV ![]() $csv = $_.FullName #Location of the source file Thanks for this, while my files are converting here’s an addition to the above script (for converting all CSV files in a folder) $query.TextFileOtherDelimiter = $delimiter $Connector = $($TxtConnector,$worksheet.Range("A1")) # Build the QueryTables.Add command and reformat the data $excel = New-Object -ComObject excel.application # Create a new Excel workbook with one empty sheet $delimiter = " " #Specify the delimiter used in the file $xlsx = "c:/path/to/file/whatever.xlsx" #Desired location of output $csv = "c:/path/to/file/whatever.csv" #Location of the source file The following script will open the specified CSV, save it as an XLSX file to a specified location and perform a text-to-columns based on the delimiter being a semicolon ( ). The original code was unable to determine the delimiting character within the CSV and so whilst I was successful in obtaining a XLSX file, it was still semi-colon separated. The following code is substantially based on the work of Nixta but I have made several changes including the manual specification of the delimiting character. ![]() Online tools exist too ( Example 1, Example 2). There are several pieces of code online that purport to do this but don’t work well ( Example 1, Example 2, Example 3). Screenshot of a XLSX file in Microsoft Excel with data arranged in cells.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |