在Jackcess中对表格进行排序 [英] Sort a table in Jackcess

查看:134
本文介绍了在Jackcess中对表格进行排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Jackcess在Java中使用MS-Access表:

I work with an MS-Access table in Java using Jackcess:

Database mdb = Database.open(new File(myPath));
Table myTable = mdb.getTable("TableName"); 

是否有一种方法可以使表按一个或多个列进行排序/排序?在文档中找不到任何内容.

Is there a way to get the table sorted/ordered by one or more column(s)? Couldn't find anything in the docs.

感谢任何提示.

推荐答案

如果您使用由索引支持的游标遍历表行,则将获得按相关索引排序的行.

If you iterate through the Table rows using a Cursor which is backed by an Index, you will get the rows ordered by the relevant Index.

这是一个示例(使用1.x API),该示例根据主键的顺序对表进行迭代:

This is an example (using the 1.x API) which iterates the table based on the order of the primary key:

for(Map<String,Object> row : Cursor.createIndexCursor(table, table.getPrimaryKeyIndex())) {
  // do something with row here...
}

这篇关于在Jackcess中对表格进行排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆