0

I'm using Import-Excel function from ImportExcel module https://github.com/dfinke/ImportExcel to Get data from Excel to PowerShell.

When I print out imported table - columns do come out in the order as they were in Excel file. However I'm doing some modifications like renaming some of the columns (removing white signs from names) etc. Object I create in this process has columns sorted alphabetically. Question is: where is the information about column order in source file stored so I can use it afterwards when creating SQL table that stores the data ? I expect that there is some object that stores the information about printout order, something like format.ps1xml maybe ?

Tomek
  • 641
  • 1
  • 6
  • 16
  • Check this: https://stackoverflow.com/questions/42090900/column-ordering-when-exporting-to-csv-in-powershell-controlling-the-property-e Hashtable key/value pairs are stored "randomly" internally, so if you want to order them a particular way when creating your SQL table, you can just use a PSCustomObject to order them how you like before passing to some function or script that creates it – trebleCode Mar 02 '18 at 22:00
  • Thanks, I'm able to output in correct order by doing $obj|select - property $props where props Is correctly sorted list. Question is how do I find out the correct order :) – Tomek Mar 04 '18 at 07:13

0 Answers0