Now for the bad news; currently, the api does not provide the necessary interface to set the value within the xml markup for the workbook to control the view in the way you require.
During today, I have had the opportunity to dig around and experiment with some code. By looking at the raw xml markup, I have found that it is the sheetView element and more specifically the topLeftCell attribute that influences the workbooks behaviour in the way you require. To test this, I created a workbook with a few sheets that had lots of rows and cells populated. Using LibreOffice Calc, I opened the workbook and scrolled away down the sheets selecting a cell at random before saving the workbook away again. Unzipping the xml, I saw a few settings that could be changed and did so in sequence, rezipping the xml markup and opening it again with Calc. If I set the value of the topLeftCell attribute to A!, then the sheet would be opened with that cell in the top left hand corner of the display, just as you wanted. This did not make the cell active, nor give it focus, only made sure it was displayed at the top left hand corner of the sheet. It is possible to get at the address of this cell using the api. Two methods are defined on the XSSFSheet class - getTopRow() and getLeftCol() - but there are no corresponding setters for these values. In addition, the sheet view object is declared as private within the class and I cannot see a quick and easy way to get at it yet. I may well be able to do so but until then, I am afraid your quest will have to be placed on hold. Just for the sake of completeness, setActiveCell() will work but it does not cause the cell to be scrolled into view. In like manner, showInPane() will work but only if employed with the locking I described earlier. Called either separately or together they will not have the effect you desire, sorry. I suspect that only by setting the value of the topLeftCell() attribute of the sheetView element will we accomplish this. I have the time to dig around more this weekend and will let you know if I can make any progress. Hopefully, I will be able to do something without needing to patch the api. -- View this message in context: http://apache-poi.1045710.n5.nabble.com/showInPane-does-not-work-tp5720321p5720431.html Sent from the POI - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
