You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Sam' <ma...@gmail.com> on 2015/10/22 10:18:12 UTC
POI XSSF and ClipBoard issue
Hi guys,
I initially opened this bug (
https://bz.apache.org/bugzilla/show_bug.cgi?id=58510) but apparently the
user list suits better.
What I want is to be able to read the content of the system clipboard
(after someone copied something from Excel). I was doing that with POI
(HSSF). I was finding the "Biff8" format inside the clipboard (among
others) and giving it to POI and everything was fine.
Apparently the Biff8 format is for Excel 97-2007. So my question is, is it
still possible to use POI for reading clipboard out of newer version of
Excel? Has anyone attempted that?
I know you people are used to open files directly with POI so my needs are
a bit different. Here is a list Formats available when copying (XML
Spreadsheet, text/rtf, cf5, cf4,cf129, Biff5 , Biff12, text/plain,
Link,text/html, Biff8, Object Descriptor, Csv, Link Source Descriptor).
Thank you,
Sam'
Re: POI XSSF and ClipBoard issue
Posted by Sam' <ma...@gmail.com>.
Yes I think you are right.
In the end, I posted my question there :
https://stackoverflow.com/questions/33387511/decode-xml-spreadsheet-content-of-a-clipboard-generated-by-excel?noredirect=1#comment54574714_33387511
But I ended up doing a parser myself within 300 lines. I'll post that on my
github or somewhere so that people can re-use it if someone ever have the
same problem as I am.
Thank you
2015-10-29 8:56 GMT+01:00 Mark Beardsley <ma...@tiscali.co.uk>:
> Thinking about this suggestion again - BIFF8 - and it is a pretty poor idea
> really. I am going to guess that the Clipboard class is able to determine
> the type of data copied onto it and is not able to convert. Therefore, if
> you are copying from an xml based Excel file, you cannot get the data back
> in the older binary file format - BIFF8.
>
>
>
> --
> View this message in context:
> http://apache-poi.1045710.n5.nabble.com/POI-XSSF-and-ClipBoard-issue-tp5720595p5720694.html
> Sent from the POI - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
>
>
Re: POI XSSF and ClipBoard issue
Posted by Mark Beardsley <ma...@tiscali.co.uk>.
Thinking about this suggestion again - BIFF8 - and it is a pretty poor idea
really. I am going to guess that the Clipboard class is able to determine
the type of data copied onto it and is not able to convert. Therefore, if
you are copying from an xml based Excel file, you cannot get the data back
in the older binary file format - BIFF8.
--
View this message in context: http://apache-poi.1045710.n5.nabble.com/POI-XSSF-and-ClipBoard-issue-tp5720595p5720694.html
Sent from the POI - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org
Re: POI XSSF and ClipBoard issue
Posted by Mark Beardsley <ma...@tiscali.co.uk>.
I looked back at your first post and found that you could xpecify BIFF8 when
you recover the contents of the Clipboard. Well, the older binary file
format for Excel was BIFF8 and POI can work with that. Try creating an
HSSFWorkbook from the contents of the clipboard rather than an XSSFWorkbook.
No promises but that might work. Alternatively, take a look at what you
recover from the Clipboard using the various options open to you. To be able
to create an XSSFWorkbook you will be looking for a zipped archive that
contains various files and folders. My first step would be to try with the
BIFF8 option and an HSSFWorkbook though - no promises but that might work
for you.
PS. I did check further and that fragment of XML does relate to an earlier
file format - Office 2003 xml - an example of which can be found here -
https://en.wikipedia.org/wiki/Microsoft_Office_XML_formats#Excel_XML_Spreadsheet_example
--
View this message in context: http://apache-poi.1045710.n5.nabble.com/POI-XSSF-and-ClipBoard-issue-tp5720595p5720682.html
Sent from the POI - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org
Re: POI XSSF and ClipBoard issue
Posted by Sam' <ma...@gmail.com>.
Allright. Currently I was able to parse it by following this documentation
:
https://msdn.microsoft.com/en-us/library/aa140066%28v=office.10%29.aspx#odc_xmlss_ss
I tested it with Excel 2007, 2010, 2013 and 2016 and that format is in the
clipboard everytime in the same manner.
So whether this is OOXML, SpreadsheetML or XML Spreadsheet I don't know.. I
do not understand at all the whole thing..
Thanks
2015-10-28 17:42 GMT+01:00 Mark Beardsley <ma...@tiscali.co.uk>:
> To be certain, I would need more time to look around but I believe that is
> SpreadsheetML and not OOXML that POI supports. Microsoft have had more than
> one attempt at creating an xml markup for Excel workbooks and I believe
> that
> this fragment relates to the earlier format - take a look here to see what
> I
> am referring to -
> https://en.wikipedia.org/wiki/Microsoft_Office_XML_formats
>
> I do not know for certain but I do believe that POI cannot work with
> SpreadsheetML. Before accepting what I say as definitive however, I would
> advise waiting to see if any one of the devlopers of the api - I am merely
> a
> user - can provide further details.
>
>
>
> --
> View this message in context:
> http://apache-poi.1045710.n5.nabble.com/POI-XSSF-and-ClipBoard-issue-tp5720595p5720680.html
> Sent from the POI - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
>
>
Re: POI XSSF and ClipBoard issue
Posted by Mark Beardsley <ma...@tiscali.co.uk>.
To be certain, I would need more time to look around but I believe that is
SpreadsheetML and not OOXML that POI supports. Microsoft have had more than
one attempt at creating an xml markup for Excel workbooks and I believe that
this fragment relates to the earlier format - take a look here to see what I
am referring to - https://en.wikipedia.org/wiki/Microsoft_Office_XML_formats
I do not know for certain but I do believe that POI cannot work with
SpreadsheetML. Before accepting what I say as definitive however, I would
advise waiting to see if any one of the devlopers of the api - I am merely a
user - can provide further details.
--
View this message in context: http://apache-poi.1045710.n5.nabble.com/POI-XSSF-and-ClipBoard-issue-tp5720595p5720680.html
Sent from the POI - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org
Re: POI XSSF and ClipBoard issue
Posted by Sam' <ma...@gmail.com>.
For example, here is what I have when I make a copy of a selection in Excel
:
<?xml version="1.0"?>
<?mso-application progid="Excel.Sheet"?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:html="http://www.w3.org/TR/REC-html40">
<Styles>
<Style ss:ID="Default" ss:Name="Normal">
<Alignment ss:Vertical="Bottom"/>
<Borders/>
<Font ss:FontName="Calibri" x:Family="Swiss" ss:Size="11"
ss:Color="#000000"/>
<Interior/>
<NumberFormat/>
<Protection/>
</Style>
</Styles>
<Worksheet ss:Name="Feuil1">
<Table ss:ExpandedColumnCount="1" ss:ExpandedRowCount="3"
ss:DefaultColumnWidth="60" ss:DefaultRowHeight="15">
<Row>
<Cell><Data ss:Type="Number">8</Data></Cell>
</Row>
<Row>
<Cell><Data ss:Type="Number">9</Data></Cell>
</Row>
<Row>
<Cell ss:Formula="=SUM(R[-2]C:R[-1]C)"><Data
ss:Type="Number">17</Data></Cell>
</Row>
</Table>
</Worksheet>
</Workbook>
Seems to me like a well formed XML.
2015-10-28 8:24 GMT+01:00 Mark Beardsley <ma...@tiscali.co.uk>:
> To my mind, the problem still remains - what exactly is the '"XML
> Spreadsheet" format' that you refer to? Before being able to answer your
> question, we need some more information. What data is copied to the
> clipboard? Is it just a fragment of the complete xml markup for a Excel
> workbook? If so, what fragment is copied to the clipboard? That was why I
> suggested testing the type and calling the appropriate getXXX() method to
> dump the copied data to screen - if that is at all possible. Sorry to say
> that I cannot help as all I have access to is the standard Oracle Java SDK
> which does not include the Clipboard class you are referring to.
>
>
>
> --
> View this message in context:
> http://apache-poi.1045710.n5.nabble.com/POI-XSSF-and-ClipBoard-issue-tp5720595p5720673.html
> Sent from the POI - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
>
>
Re: POI XSSF and ClipBoard issue
Posted by Mark Beardsley <ma...@tiscali.co.uk>.
To my mind, the problem still remains - what exactly is the '"XML
Spreadsheet" format' that you refer to? Before being able to answer your
question, we need some more information. What data is copied to the
clipboard? Is it just a fragment of the complete xml markup for a Excel
workbook? If so, what fragment is copied to the clipboard? That was why I
suggested testing the type and calling the appropriate getXXX() method to
dump the copied data to screen - if that is at all possible. Sorry to say
that I cannot help as all I have access to is the standard Oracle Java SDK
which does not include the Clipboard class you are referring to.
--
View this message in context: http://apache-poi.1045710.n5.nabble.com/POI-XSSF-and-ClipBoard-issue-tp5720595p5720673.html
Sent from the POI - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org
Re: POI XSSF and ClipBoard issue
Posted by Sam' <ma...@gmail.com>.
Can POI read "XML Spreadsheet" format? Because I have it but I don't know
if POI can read it. If yes, I assume it is with XSSF right?
I've seen that I need quite a lot of JAR for XSSF but my only concern is to
parse the XML and extract the data, is it possible to that with POI without
having all the jars ?
2015-10-23 16:35 GMT+02:00 Mark Beardsley <ma...@tiscali.co.uk>:
> Looking at the Clipboard class, it has methods that would allow you to
> discover the type of the data pasted onto the clipboard. It would be quite
> possible to use if...else clauses to test and see if the Clipboard
> hasString() or hasRtf() etc and then call the appropriate method to simply
> dump the raw contents of the clipboards to a file or maybe to System.out
> initially. That should allow you to look at what you have copied and maybe
> give a clue as to how POI could work with the data.
>
>
>
> --
> View this message in context:
> http://apache-poi.1045710.n5.nabble.com/POI-XSSF-and-ClipBoard-issue-tp5720595p5720626.html
> Sent from the POI - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
>
>
Re: POI XSSF and ClipBoard issue
Posted by Mark Beardsley <ma...@tiscali.co.uk>.
Looking at the Clipboard class, it has methods that would allow you to
discover the type of the data pasted onto the clipboard. It would be quite
possible to use if...else clauses to test and see if the Clipboard
hasString() or hasRtf() etc and then call the appropriate method to simply
dump the raw contents of the clipboards to a file or maybe to System.out
initially. That should allow you to look at what you have copied and maybe
give a clue as to how POI could work with the data.
--
View this message in context: http://apache-poi.1045710.n5.nabble.com/POI-XSSF-and-ClipBoard-issue-tp5720595p5720626.html
Sent from the POI - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org
Re: POI XSSF and ClipBoard issue
Posted by Sam' <ma...@gmail.com>.
Hi,
What do you mean by "copy a cell, paste it into your app, save that to
disk"?
What do I save? The content of the "XML Spreadsheet" format given by Excel?
Because I cannot print the whole clipBoard like that. I'm using the JavaFX
ClipBoard object (
https://docs.oracle.com/javase/8/javafx/api/javafx/scene/input/Clipboard.html
) and all I can do is to print the content for each different format that
Excel gives me (XML Spreadsheet, text/rtf, cf5, cf4,cf129, Biff5 , Biff12,
text/plain, Link,text/html, Biff8, Object Descriptor, Csv, Link Source
Descriptor).
Regards,
2015-10-22 15:50 GMT+02:00 Nick Burch <ap...@gagravarr.org>:
> On Thu, 22 Oct 2015, Sam' wrote:
>
>> Yes the attachment is in XSSF format. I produced the file without POI.
>> That
>> means I opened Excel on my computer, then fill the cell and add a comment
>> and saved it.
>>
>> Then I opened it again, clicked on the first cell and did a copy of it.
>> Then after, I do a "paste" in my Java application and I'm trying to decode
>> what's in it, and give it to POI.
>>
>
> Ah, that explains why things might be being a bit odd. (It might be like
> password protected files, which get wrapped up in odd ways, or might be
> something else...)
>
> So technically, I am not providing a full spreadsheet file. Simply
>> extracting what Excel has put into the clipboard. And apparently something
>> was put in it into a Biff8 format. And that "something" was ok for POI.
>> Now
>> that if I'm extracting from the clipboard the "XML Spreadsheet" content
>> and
>> I give it to POI, it's not working.
>>
>> But maybe the cause is that : what is inside the clipboard is not a fully
>> constructed content and POI doesn't recognize that as an Excel file.
>>
>
> It probably isn't a full file. Quite what it is, and how close, I'm not
> sure. It'll be interesting to find out!
>
> I'd suggest you open an enhancement ticket in bugzilla. Then, create a
> simple spreadsheet in XLS and XLSX format, and attach those. Next, copy a
> cell, paste it into your app, save that to disk, then repeat for the other
> format. Upload those two "raw" clipboard files. Finally, run the Apache
> Tika App in --detect mode on the two clipboard files and report what that
> thinks they are
>
> You'll likely need to do much of the work yourself, but with the above we
> might be able to give you some pointers!
>
> Nick
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
>
>
Re: POI XSSF and ClipBoard issue
Posted by Nick Burch <ap...@gagravarr.org>.
On Thu, 22 Oct 2015, Sam' wrote:
> Yes the attachment is in XSSF format. I produced the file without POI. That
> means I opened Excel on my computer, then fill the cell and add a comment
> and saved it.
>
> Then I opened it again, clicked on the first cell and did a copy of it.
> Then after, I do a "paste" in my Java application and I'm trying to decode
> what's in it, and give it to POI.
Ah, that explains why things might be being a bit odd. (It might be like
password protected files, which get wrapped up in odd ways, or might be
something else...)
> So technically, I am not providing a full spreadsheet file. Simply
> extracting what Excel has put into the clipboard. And apparently something
> was put in it into a Biff8 format. And that "something" was ok for POI. Now
> that if I'm extracting from the clipboard the "XML Spreadsheet" content and
> I give it to POI, it's not working.
>
> But maybe the cause is that : what is inside the clipboard is not a fully
> constructed content and POI doesn't recognize that as an Excel file.
It probably isn't a full file. Quite what it is, and how close, I'm not
sure. It'll be interesting to find out!
I'd suggest you open an enhancement ticket in bugzilla. Then, create a
simple spreadsheet in XLS and XLSX format, and attach those. Next, copy a
cell, paste it into your app, save that to disk, then repeat for the other
format. Upload those two "raw" clipboard files. Finally, run the Apache
Tika App in --detect mode on the two clipboard files and report what that
thinks they are
You'll likely need to do much of the work yourself, but with the above we
might be able to give you some pointers!
Nick
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org
Re: POI XSSF and ClipBoard issue
Posted by Sam' <ma...@gmail.com>.
Hi,
I'm sorry if I'm not clear enough.
Yes the attachment is in XSSF format. I produced the file without POI. That
means I opened Excel on my computer, then fill the cell and add a comment
and saved it.
Then I opened it again, clicked on the first cell and did a copy of it.
Then after, I do a "paste" in my Java application and I'm trying to decode
what's in it, and give it to POI.
So technically, I am not providing a full spreadsheet file. Simply
extracting what Excel has put into the clipboard. And apparently something
was put in it into a Biff8 format. And that "something" was ok for POI. Now
that if I'm extracting from the clipboard the "XML Spreadsheet" content and
I give it to POI, it's not working.
But maybe the cause is that : what is inside the clipboard is not a fully
constructed content and POI doesn't recognize that as an Excel file.
I hope that it's clearer for you.. I can provide you some simple test
applications to run if you want to play around the copy/paste content. I
have the feeling that people are using POI in order to construct or read
files, but not many have tried to use it with the Clipboard.
Regards,
2015-10-22 15:31 GMT+02:00 Dominik Stadler <do...@gmx.at>:
> Hi,
>
> I am still confused because the attachment you provided is in XSSF
> format, how did you produce this out of the Clipboard-Data when you
> state that you work with .xls/Biff8/HSSF formatted data?
>
> POI can read XSSF and HSSF just fine and as long as the data is a full
> spreadsheet file, it should not matter where it comes from, so you can
> try the "XML Spreadsheet" format listed.
>
> Dominik.
>
> On Thu, Oct 22, 2015 at 10:18 AM, Sam' <ma...@gmail.com> wrote:
> > Hi guys,
> >
> > I initially opened this bug (
> > https://bz.apache.org/bugzilla/show_bug.cgi?id=58510) but apparently the
> > user list suits better.
> >
> > What I want is to be able to read the content of the system clipboard
> > (after someone copied something from Excel). I was doing that with POI
> > (HSSF). I was finding the "Biff8" format inside the clipboard (among
> > others) and giving it to POI and everything was fine.
> >
> > Apparently the Biff8 format is for Excel 97-2007. So my question is, is
> it
> > still possible to use POI for reading clipboard out of newer version of
> > Excel? Has anyone attempted that?
> >
> > I know you people are used to open files directly with POI so my needs
> are
> > a bit different. Here is a list Formats available when copying (XML
> > Spreadsheet, text/rtf, cf5, cf4,cf129, Biff5 , Biff12, text/plain,
> > Link,text/html, Biff8, Object Descriptor, Csv, Link Source Descriptor).
> >
> > Thank you,
> > Sam'
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
>
>
Re: POI XSSF and ClipBoard issue
Posted by Dominik Stadler <do...@gmx.at>.
Hi,
I am still confused because the attachment you provided is in XSSF
format, how did you produce this out of the Clipboard-Data when you
state that you work with .xls/Biff8/HSSF formatted data?
POI can read XSSF and HSSF just fine and as long as the data is a full
spreadsheet file, it should not matter where it comes from, so you can
try the "XML Spreadsheet" format listed.
Dominik.
On Thu, Oct 22, 2015 at 10:18 AM, Sam' <ma...@gmail.com> wrote:
> Hi guys,
>
> I initially opened this bug (
> https://bz.apache.org/bugzilla/show_bug.cgi?id=58510) but apparently the
> user list suits better.
>
> What I want is to be able to read the content of the system clipboard
> (after someone copied something from Excel). I was doing that with POI
> (HSSF). I was finding the "Biff8" format inside the clipboard (among
> others) and giving it to POI and everything was fine.
>
> Apparently the Biff8 format is for Excel 97-2007. So my question is, is it
> still possible to use POI for reading clipboard out of newer version of
> Excel? Has anyone attempted that?
>
> I know you people are used to open files directly with POI so my needs are
> a bit different. Here is a list Formats available when copying (XML
> Spreadsheet, text/rtf, cf5, cf4,cf129, Biff5 , Biff12, text/plain,
> Link,text/html, Biff8, Object Descriptor, Csv, Link Source Descriptor).
>
> Thank you,
> Sam'
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org