小编Hel*_*vio的帖子

Apache-POI在excel中排序行

我想用一个字符串列对表中的行进行排序.我尝试使用Sheet.shiftRows方法实现这一点,但我无法管理.它不会在我的方法中切换行的位置.我的代码有什么问题?或者也许有更好的方法来排序excel中任何String列的行?

/**
 * Sorts (A-Z) rows by String column
 * @param sheet - sheet to sort
 * @param column - String column to sort by
 * @param rowStart - sorting from this row down
 */
private void sortSheet(Sheet sheet, int column, int rowStart) {
    boolean sorting = true;
    int lastRow = sheet.getLastRowNum();
    while (sorting == true) {
        sorting = false;
        for (Row row : sheet) {
            // skip if this row is before first to sort
            if (row.getRowNum()<rowStart) continue;
            // …
Run Code Online (Sandbox Code Playgroud)

java sorting excel row apache-poi

12
推荐指数
2
解决办法
2万
查看次数

标签 统计

apache-poi ×1

excel ×1

java ×1

row ×1

sorting ×1