How to Column Span using Apache POI for parsing XLS?
In the Above pic Row1 contains Col1 and Col2
Row2 contains few variables .
My Requirement , Using Apache POI is there way or an API where i can get开发者_如何转开发 the
If i say Col1 i need to get the list of var1 to var4 (Note: It can be dynamic since i am parsing the file).
Similarly for Col2 var5 to var10
You can get pretty close. Use the HSSFSheet.getMergedRegion(int index) method to get a reference to a merged region. That returns a CellRangeAddress, for which you can call getNumberOfCells() which should get you pretty close.
You need to know which merged regions you are after, you can get the total number of them using HSSFSheet.getNumMergedRegions(). It's still possible that there may be a merged region other than your headers, this is just a matter of your input format.
Here is a link to the POI API: http://poi.apache.org/apidocs/index.html
The notable classes are HSSFSheet and CellRangeAddress
精彩评论