java怎么删除excel列 java删除excel行_删除行

 

删除掉这一行  

/**
     * excel删除行
     * @param sheet
     * @param rowIndex 要删除的行数  从0开始
     */
    public void removeRow(HSSFSheet sheet, int rowIndex)
    {
        //        这行是删除合并单元格
        sheet.removeMergedRegion(rowIndex);
        int lastRowNum = sheet.getLastRowNum();
        if (rowIndex >= 0 && rowIndex < lastRowNum)
            sheet.shiftRows(rowIndex + 1, lastRowNum, -1);//将行号为rowIndex+1一直到行号为lastRowNum的单元格全部上移一行,以便删除rowIndex行
        if (rowIndex == lastRowNum)
        {
            HSSFRow removingRow = sheet.getRow(rowIndex);
            if (removingRow != null)
                sheet.removeRow(removingRow);
        }
    }