How to copy a row from existing excel sheet to a new excel sheet using Apache POI?

半腔热情 提交于 2019-12-06 14:02:44

Just modify the copyRow method, add parameter HSSFSheet resultSheet then modify newRow variable in the method to get that from resultSheet like this

private static void copyRow(HSSFWorkbook workbook, HSSFSheet worksheet, HSSFSheet resultSheet, int sourceRowNum, int destinationRowNum) {
    // Get the source / new row
    HSSFRow newRow = resultSheet.getRow(destinationRowNum);
    HSSFRow sourceRow = worksheet.getRow(sourceRowNum);

take that resultSheet from your destination "output.xls"

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!