XSSFWorkbook.cloneSheet throws POIXMLException if the sheet contains a threaded comment

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

XSSFWorkbook.cloneSheet throws POIXMLException if the sheet contains a threaded comment

yeguenic
Hi,I am stuck on an error that XSSFWorkbook throws when cloning an Excel
sheet that contains a threaded comment. Apparently this is a new type of
comment that Microsoft added to Excel around September 2018. What they were
calling 'Comments' in the UI, is now called 'Notes'. Threaded comments allow
users to reply to each other.I have downloaded the latest version of POI,
which is version 4.0.1. It has been released in December 2018._Here is the
stack trace:_org.apache.poi.ooxml.POIXMLException: Can't clone sheet -
unknown relation type found:
http://schemas.microsoft.com/office/2017/10/relationships/threadedComment        at
org.apache.poi.xssf.usermodel.XSSFWorkbook.addRelation(XSSFWorkbook.java:700)
at
org.apache.poi.xssf.usermodel.XSSFWorkbook.cloneSheet(XSSFWorkbook.java:631)
at
org.apache.poi.xssf.usermodel.XSSFWorkbook.cloneSheet(XSSFWorkbook.java:585)
at testprojects.poi401.poitester.testcloneSheet(poitester.java:26) at
testprojects.poi401.poitester.main(poitester.java:35)_Here is the code for
this use-case:_import java.io.File;import
org.apache.poi.xssf.usermodel.XSSFSheet;import
org.apache.poi.xssf.usermodel.XSSFWorkbook;public class poitester {      
public static void testcloneSheet(File inFile) {        try {                  
XSSFWorkbook workbook = new XSSFWorkbook(inFile);            XSSFSheet sheet
= workbook.getSheetAt(0);            if( sheet == null )              
System.out.println("Sheet cannot be found");                      
XSSFSheet clonedSheet = workbook.cloneSheet(0);                    } catch(
Throwable t) {            t.printStackTrace();        }    }        public
static void main(String[] args) {        File f = new File
("/Users/yleguenic/Desktop/WorkbookWithThreadedComment.xlsx");      
testcloneSheet(f);    }    } WorkbookWithThreadedComment.xlsx
<http://apache-poi.1045710.n5.nabble.com/file/t340656/WorkbookWithThreadedComment.xlsx>
The WorkbookWithThreadedComment.xlsx workbook contains one sheet that has a
'Note' on cell A1 and a 'Threaded Comment' on cell B1.If anyone knows a way
to prevent the cloning of the sheet from crashing, even if it implies to
loose the  threaded comments, this would make my day !Regards,Yann.



--
Sent from: http://apache-poi.1045710.n5.nabble.com/POI-User-f2280730.html
Reply | Threaded
Open this post in threaded view
|

Re: XSSFWorkbook.cloneSheet throws POIXMLException if the sheet contains a threaded comment

Dominik Stadler
Hi,

this sounds like an enhancement request for Apache POI. Keep in mind that
not every thing is supported already with such a huge set of specs/formats
like the Office documents. Having a later release-date of Apache POI surely
will not mean each and every feature of Office will be available in Apache
POI.

Can you create a feature request in the bug database at
https://bz.apache.org/bugzilla/ where you provide a sample document and
your sample code to reproduce this?

Thanks... Dominik.



On Mon, Jan 14, 2019 at 10:22 AM yeguenic <[hidden email]> wrote:

> Hi,I am stuck on an error that XSSFWorkbook throws when cloning an Excel
> sheet that contains a threaded comment. Apparently this is a new type of
> comment that Microsoft added to Excel around September 2018. What they were
> calling 'Comments' in the UI, is now called 'Notes'. Threaded comments
> allow
> users to reply to each other.I have downloaded the latest version of POI,
> which is version 4.0.1. It has been released in December 2018._Here is the
> stack trace:_org.apache.poi.ooxml.POIXMLException: Can't clone sheet -
> unknown relation type found:
> http://schemas.microsoft.com/office/2017/10/relationships/threadedComment
>      at
>
> org.apache.poi.xssf.usermodel.XSSFWorkbook.addRelation(XSSFWorkbook.java:700)
> at
>
> org.apache.poi.xssf.usermodel.XSSFWorkbook.cloneSheet(XSSFWorkbook.java:631)
> at
>
> org.apache.poi.xssf.usermodel.XSSFWorkbook.cloneSheet(XSSFWorkbook.java:585)
> at testprojects.poi401.poitester.testcloneSheet(poitester.java:26)      at
> testprojects.poi401.poitester.main(poitester.java:35)_Here is the code for
> this use-case:_import java.io.File;import
> org.apache.poi.xssf.usermodel.XSSFSheet;import
> org.apache.poi.xssf.usermodel.XSSFWorkbook;public class poitester {
> public static void testcloneSheet(File inFile) {        try {
>
> XSSFWorkbook workbook = new XSSFWorkbook(inFile);            XSSFSheet
> sheet
> = workbook.getSheetAt(0);            if( sheet == null )
> System.out.println("Sheet cannot be found");
> XSSFSheet clonedSheet = workbook.cloneSheet(0);                    } catch(
> Throwable t) {            t.printStackTrace();        }    }        public
> static void main(String[] args) {        File f = new File
> ("/Users/yleguenic/Desktop/WorkbookWithThreadedComment.xlsx");
> testcloneSheet(f);    }    } WorkbookWithThreadedComment.xlsx
> <
> http://apache-poi.1045710.n5.nabble.com/file/t340656/WorkbookWithThreadedComment.xlsx>
>
> The WorkbookWithThreadedComment.xlsx workbook contains one sheet that has a
> 'Note' on cell A1 and a 'Threaded Comment' on cell B1.If anyone knows a way
> to prevent the cloning of the sheet from crashing, even if it implies to
> loose the  threaded comments, this would make my day !Regards,Yann.
>
>
>
> --
> Sent from: http://apache-poi.1045710.n5.nabble.com/POI-User-f2280730.html