Bug 57844 - SXSSFSheet.shiftRows() throws java.lang.RuntimeException: NotImplemented
Summary: SXSSFSheet.shiftRows() throws java.lang.RuntimeException: NotImplemented
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: SXSSF (show other bugs)
Version: unspecified
Hardware: PC All
: P2 enhancement (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-04-21 17:11 UTC by Michael
Modified: 2016-04-10 09:41 UTC (History)
0 users



Attachments
Small java program to test SXSSFSheet.shiftRows() functionality (1.45 KB, text/x-java)
2015-04-21 17:11 UTC, Michael
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Michael 2015-04-21 17:11:34 UTC
Created attachment 32675 [details]
Small java program to test SXSSFSheet.shiftRows() functionality

SXSSFSheet.shiftRows() throws java.lang.RuntimeException: NotImplemented
Comment 1 Nick Burch 2015-04-21 23:56:33 UTC
I'm not sure we're going to be able to add support for this in SXSSF - shifting rows generally requires updating all sorts of back-and-forth references, which SXSSF wouldn't be able to do as it won't have the required objects available

It's possible that someone could do a minimal implementation that just did a few updates on rows which were in the buffer in memory, but care would need to be taken to ensure it cleanly throws an exception if it's asked to touch anything outside of the buffer
Comment 2 Michael 2015-04-22 13:39:10 UTC
I understand the complexity, but in this case Apache POI API better not to offer and not to allow this method at all, rather then making impression that user (developer) is able to insert row(s) and not allowing to do it.
Comment 3 Javen O'Neal 2015-11-23 06:03:57 UTC
Proposed resolution:
Update the Java docs (https://poi.apache.org/apidocs/org/apache/poi/xssf/streaming/SXSSFSheet.html) and clearly state which functions are not implemented. (I'm guessing shiftRows isn't the only SXSSF* function that throws RuntimeException/UnsupportedOperationException("NotImplemented").

As Nick said, shiftRows could only work if the rows to be shifted are within current window, rows that haven't yet been written probably wouldn't be able to be shifted, and any reference (formula, named range, merged region, hyperlink, chart data, tables, pivot tables, conditional formatting rules) that refers to a shifted row would probably be broken.

If someone can find a workable solution that addresses these issues, we'd be happy to implement it. Until then, the best we can do is advertise "Not Implemented" in the java docs. I think it'd be a step backwards to move shiftRows out of the Sheet interface so that SXSSFSheet isn't required to implement it.
Comment 4 Javen O'Neal 2015-11-29 15:35:54 UTC
Added in r1717079.

I added an annotation org.apache.poi.util.NotImplemented which should be used on any method, especially a public method, that is not implemented (either because no one has gotten around to the work or the class inherently can't support it but we want the method to be available in the interface so users can write generic code.

I added these annotations on to the two shiftRows calls in SXSSFSheet.
Before this bug is closed, someone needs to search through the code for
RuntimeException, UnsupportedOperationException, NotImplemented, Not Implemented and annotate those methods as well.
Comment 5 Dominik Stadler 2016-04-10 09:41:39 UTC
I reviewed the SXSSF classes and added some more notes in r1738413, so this should be mostly done now, any missing entries will be fixed as we go along.