What does the parameter `index` mean in Apache POI sheet `getMergedRegion`?
apache-poi, java
Solution
From the freely available source downloadable here http://poi.apache.org/download.html we have ...
/**
* @return the merged region at the specified index
*/
public CellRangeAddress getMergedRegion(int index) {
return _sheet.getMergedRegionAt(index);
}
When we drill down to `getMergedRegionAt` we find
public CellRangeAddress getMergedRegionAt(int index) {
//safety checks
MergedCellsTable mrt = getMergedRecords();
if (index >= mrt.getNumberOfMergedRegions()) {
return null;
}
return mrt.get(index);
}
Here we can see that there is a `MergedCellsTable` this would indicate that each worksheet has a data structure that maintains a list of the Merged Cells in a WorkSheet.
From reviewing the code the index references the specific MergedRegion whose CellRangeAddress was required in the context of having many regions.
You could log that as a doc bug or submit a patch to improve the JavaDoc.
Problem
What does `index` mean in `getMergedRegion`? Apache's HSSFSheet documentation does not explicitly describe what the `index` parameter means.