My last note got out of sync.  I find a way to get what I needed as far as
the regions are concerend.  I appreciate your help, THANKS 



MSB wrote:
> 
> Sorry but I am not too sure what you are asking for. Are you asking
> whether it is possible to discover the size of a merged region of cells?
> If so, then the answer is yes, as the CellRangeAdress class conatins
> methods to tel you the first row and column in the merged region and the
> last row and column. That gives you, in effect, the cell co-ordinates of
> the regions top left and bottom right hand corners (getFirstColumn(),
> getFirstRow(), getLastColumn() and getLastRow()). Using those numbers, you
> can calculate the number of columns, rows and even cells - though there is
> also a getNumberOfCells() method you could call to get this figure - the
> merged region occupies.
> 
> Yours
> 
> Mark B
> 
> 
> pb2208 wrote:
>> 
>> Sorry, I was looking at the wrong class and the row/column indexes were
>> bad.  Everthng is working.
>> 
>> Is there a way to determine if the merge columns versus rows?   And if
>> so, how to determine the number of cells involved?
>> 
>> 
>> 
>> MSB wrote:
>>> 
>>> Are you looking at the correct class? The one I referred to is the
>>> org.apache.poi.ss.util.CellRangeAddress class. It extends the
>>> CellRangeAddressBase class and inherits the isInRange(int, int) method
>>> from that.
>>> 
>>> With regard to making the comparison, all you need to do is pass the row
>>> and column numbers of the cell to the isInRange() method for a
>>> CellRangeAddress object you have recovered from the array. You may know
>>> the address of the cell - depending on the code you are using to recover
>>> cells from your worksheets - but if not can recover it by calling the
>>> getRowIndex() and getColumnIndex() method on the cell object.
>>> 
>>> Yours
>>> 
>>> Mark B
>>> 
>>> 
>>> pb2208 wrote:
>>>> 
>>>> Interestng.  The documentation appears to indicate that
>>>> "CellRangeAddress" object is depricated.
>>>> http://poi.apache.org/apidocs/org/apache/poi/hssf/util/CellRangeAddress.html
>>>> 
>>>> I have written the code and have a question on the "isInRange" method. 
>>>> Where is it defined and how can it compare the values in the array?
>>>> 
>>>> 
>>>> MSB wrote:
>>>>> 
>>>>> I do not have the code to hand but the technique that I have used in
>>>>> the past goes like this.
>>>>> 
>>>>> Open the worksheet.
>>>>> Call the getNumMergedRegions() methods to recover an integer that
>>>>> indicates how manymerged regions there are on the sheet.
>>>>> Use this value to create and dimension an array of type
>>>>> CellRangeAddress.
>>>>> Use this value again to iterate through all of the merged regions -
>>>>> use a for() loop - calling the getMergedRegion(int) method and storing
>>>>> the returned CellRangeAdress object into the array.
>>>>> 
>>>>> Now when you encounter a cell, you can iterate through the objects in
>>>>> the cell range address array and call the isInGange(int, int) method
>>>>> passing the row and column indeices of the cell. That will return a
>>>>> boolean value indicating whether or not the cell is contained within
>>>>> the range.
>>>>> 
>>>>> Yours
>>>>> 
>>>>> Mark B
>>>>> 
>>>>> 
>>>>> pb2208 wrote:
>>>>>> 
>>>>>> I am parsing a spreadsheet and need to skip processing for an merged
>>>>>> cells.  How can i test a cell to see if it is part of merged set of
>>>>>> cells?
>>>>>> 
>>>>> 
>>>>> 
>>>> 
>>>> 
>>> 
>>> 
>> 
>> 
> 
> 


-----
Pete Beatty
-- 
View this message in context: 
http://old.nabble.com/Testing-for-Merged-cells-tp28811936p28831913.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]

Reply via email to