在asp.net中停止对excel中的sheetname进行sorting

我从excel中获取工作表名称,并创build其文本是工作表名称的button。

但每次创buildbutton时,都按字母顺序sorting。 我不想把它们分类。

这是我的代码:

Dim objConn As OleDbConnection = Nothing Dim dt As System.Data.DataTable = Nothing Try Dim connString As String = "" If Extension = "xls" Or Extension = ".xls" Then connString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & FileUploadPath & sender.text & ";Extended Properties=" + Convert.ToChar(34).ToString() + "Excel 8.0;HDR=No;IMEX=1" + Convert.ToChar(34).ToString() + "" ElseIf Extension = "xlsx" Or Extension = ".xlsx" Then connString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & FileUploadPath & sender.text & ";Extended Properties=" + Convert.ToChar(34).ToString() + "Excel 12.0;HDR=No;IMEX=2" + Convert.ToChar(34).ToString() + "" End If objConn = New OleDbConnection(connString) objConn.Open() dt = objConn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, Nothing) If Not dt Is Nothing Then Dim i As Integer = 1 For Each row As DataRow In dt.Rows Dim btn As Button = New Button btn.ID = "btnSheet" & i btn.Text = row("TABLE_NAME").ToString().Substring(0, row("TABLE_NAME").ToString.Length - 1) excelSheetButtonsList.Add(btn) tdInfo.Controls.Add(btn) tdInfo.Controls.Add(New LiteralControl(" ")) AddHandler btn.Click, AddressOf ExcelSheetNameButtons_Click i += 1 Next End If Catch ex As Exception Finally If objConn IsNot Nothing Then objConn.Close() objConn.Dispose() End If If dt IsNot Nothing Then dt.Dispose() End If End Try 

图像1是以上代码的输出:

在这里输入图像说明

现在图2描述了excel表单:

在这里输入图像说明

我想我的输出顺序,因为它是在图像2。

一种(尽pipe不是很可靠)的方法是对结果DataTable进行sorting(通过创build基于它的DataView)将它sorting在DateCreated或DateModified列上。