Dim Xls As Excel.Application = New Excel.Application '定义excel应用程序 Dim Xlsbook As Excel.Workbook '定义工作簿 Dim Xlssheet As Excel.Worksheet '定义工作表 Xlsbook = Xls.Application.Workbooks.Open("c:\sort.xls") Xlssheet = Xlsbook.Sheets(1) CType(Xlssheet.Columns(1), Excel.Range).ColumnWidth = 30 CType(Xlssheet.Columns(2), Excel.Range).ColumnWidth = 60 CType(Xlssheet.Columns(3), Excel.Range).ColumnWidth = 10 Xlssheet.UsedRange.Sort(Key1:=Xlssheet.Range(Xlssheet.Cells(1, 3).Address), _ Order1:=Excel.XlSortOrder.xlAscending, _ Header:=Excel.XlYesNoGuess.xlNo, _ Orientation:=Excel.XlSortOrientation.xlSortColumns)
Xlssheet.UsedRange.Sort(Key1:=Xlssheet.Range(Xlssheet.Cells(1, 3).Address), _ Order1:=Excel.XlSortOrder.xlAscending, _ Header:=Excel.XlYesNoGuess.xlNo, _ Orientation:=Excel.XlSortOrientation.xlSortColumns)
原文地址:http://blog.csdn.net/qzmrock/article/details/41644799