XSSFRow.copyFromRow is failed when try to copy Row having the same row-index from another Sheet. It calls FormulaShifter.createForRowCopy passing rowDifference=0, which in turns raises IllegalArgumentException("amountToMove must not be zero"). I suppose, for cross-sheet row copy FormulaShifter should be adapted, or at least skipped.
Can you provide some sample code and sample file to make it possible to reproduce this more easily?
Here is a simple test case that attempts to copy data across sheets at the same row index: try (XSSFWorkbook wb = new XSSFWorkbook()) { XSSFSheet first = wb.createSheet(); XSSFRow row = first.createRow(0); row.createCell(0).setCellValue("Value"); XSSFSheet second = wb.createSheet(); second.copyRows(Collections.singletonList(row), 0, new CellCopyPolicy()); } catch (Exception e) { /* poi-ooxml-4.1.0.jar java.lang.IllegalArgumentException: amountToMove must not be zero at org.apache.poi.ss.formula.FormulaShifter.<init>(FormulaShifter.java:80) at org.apache.poi.ss.formula.FormulaShifter.createForRowCopy(FormulaShifter.java:118) at org.apache.poi.xssf.usermodel.XSSFRow.copyRowFrom(XSSFRow.java:623) at org.apache.poi.xssf.usermodel.XSSFSheet.copyRows(XSSFSheet.java:2938) */ throw new IllegalStateException(e); }
*** Bug 63352 has been marked as a duplicate of this bug. ***
There is some more information and a workaround discussed at https://stackoverflow.com/questions/54430518/why-am-i-getting-illegalargumentexception-while-using-copyrowfrom-in-xssfro
when can we expect this bug to be fixed.
Apache POI is a volunteer-only project, nobody is paid to work on it. So nobody is tasked with working on a specific bug and there is no ETA. If you would like to speed up things, you can try to help by doing some more analysis yourself and if possible provide a possible patch.
Thank you for replying. Any work arounds that can be used for now?
I added a fix for this - will appear in v5.1.0 release