Just had a quick play with Excel and the clipboard and found out a couple of interesting things.
Firstly, I created a worksheet and entered a value into one of the cells in a workbook. Not surprisingly, I was able to copy this - format and all - across to other cells/sheets in the same workbook. Next, I closed this workbook down and opened a new one and though I was able to paste the text that I had originally copied, the formatting information had been lost. So, secondly, I created and formated a cell then copied it to the clipboard. Next, I opened the clipboard viewer and saved the contents to my desktop as a .clp file. Opening this file and having a quick scan through it showed that the clipboard viewer is storing a lot of additional information about the application and cell but using a format that HSSF may not be able to understand. For example, I found a reference that would be familiar to VB developers - Excel.Sheet.8 - which I would guess is resolved internally by Windows to identify just where the cut data is to be copied from when you paste it. This, I guess, is why when a worksheet is open the formatting information can be copied over but when it is closed that same information cannot be copied over. How you would resolve these references yourself, I do not know. The information is there in the .clp file but I do not know how you could interpret it. HSSF may not be able to read the .clp file as it contains a lot of extraneous information - some even in the form of HTML markup seemingly. --- On Fri, 7/18/08, Anthony Andrews <[EMAIL PROTECTED]> wrote: From: Anthony Andrews <[EMAIL PROTECTED]> Subject: Re: Using POI to read the clipboard from Excel To: "POI Users List" <[email protected]> Date: Friday, July 18, 2008, 5:45 AM Must admit that my first thought was no, this is not possible. Thinking about it again however, it all depends upon what information is stored on the clipboard, where it is stored and how you could get at it. If you are very lucky and all of the information about a cell is stored in a very small file in the BIFF8 format then it could be possible to open a stream onto that file and access it using HSSF. I have never had to do anything like this and so I could very well be wrong but think I would begin by looking at what information is stored in the clipboard, where it is stored and in what format. Just as an aside, what happens if you try to copy between two Excel applications using the clipboard? I do not mean between two sheets within a workbook or even between two workbooks within an Excel session but between two Excel sessions (i.e. open Excel, enter a value into a cell on a worksheet, copy that cell then close down Excel,. Open Excel again and try to paste the cell onto a different worksheet)? --- On Thu, 7/17/08, neil hart <[EMAIL PROTECTED]> wrote: From: neil hart <[EMAIL PROTECTED]> Subject: Using POI to read the clipboard from Excel To: [email protected] Date: Thursday, July 17, 2008, 2:22 PM Currently we are copying data from Excel and reading it in Java through the clipboard. Our solution get only the String values for each cell. Can POI give us more of a leg up by providing the correct cell type (Number, Date, etc) in reading the clipboard. Again, we are taking clipboard, not reading a file. Thanks Neil
