按照DESCENDING顺序对excel列进行sorting
这里是我的代码,正确地sorting整个工作表基于列2升序。
$table = $worksheet.ListObjects | where DisplayName -EQ "User_Table" $table.Sort.SortFields.clear() $table.Sort.SortFields.add($table.Range.Columns.Item(2)) $table.Sort.apply()
我已经尝试在各个地方添加xlDescending,但不断收到语法错误。
据此… https://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.sortfields.add.aspx …
SortField Add( Range Key, Object SortOn, Object Order, Object CustomOrder, Object DataOption )
订单是第三个参数。 结合下面的答案… https://stackoverflow.com/a/11770103/5040941你应该能够做一些沿线
$table.Sort.SortFields.add($table.Range.Columns.Item(2),0,2)
其中0和2是XlSortOnValues
和XlDescending
的值