以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 对导出的excel表某列排序,代码如何实现 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=94438) |
|
-- 作者:bahamute -- 发布时间:2016/12/23 15:07:00 -- 对导出的excel表某列排序,代码如何实现 Dim Book As New XLS.Book \'定义一个Excel工作簿
Dim Sheet As XLS.Sheet = Book.Sheets(0) \'引用工作簿的第一个工作表 For c As Integer = 0 To nms.length -1 Sheet(0, c).Value = caps(c) \'指定列标题 Sheet.Cols(c).Width = szs(c) \'指定列宽 Next For r As Integer = 0 To dt.Rows.Count - 1 \'填入数据 For c As Integer = 0 To nms.length -1 Sheet(r +1, c).Value = dt.rows(r)(nms(c)) Next Next ................(此处需要对Sheet表第一列按升序排序,如何实现) |
|
-- 作者:狐狸爸爸 -- 发布时间:2016/12/23 15:11:00 -- Dim drs As List(of DataRow) = DataTables("表名").Select("","第一列") Dim Book As New XLS.Book \'定义一个Excel工作簿 Dim Sheet As XLS.Sheet = Book.Sheets(0) \'引用工作簿的第一个工作表 For c As Integer = 0 To nms.length -1 Sheet(0, c).Value = caps(c) \'指定列标题 Sheet.Cols(c).Width = szs(c) \'指定列宽 Next For r As Integer = 0 To dt.Rows.Count - 1 \'填入数据 For c As Integer = 0 To nms.length -1 Sheet(r +1, c).Value = drs(r)(nms(c)) Next Next |