Bug 55745 - XSSFSheet's method getTables() fails when the sheet contains more than 6 tables and some table cells are commented.
Summary: XSSFSheet's method getTables() fails when the sheet contains more than 6 tabl...
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: XSSF (show other bugs)
Version: 3.9-FINAL
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-11-06 03:46 UTC by Walker
Modified: 2013-11-28 15:17 UTC (History)
0 users



Attachments
workbook with sheet on which getTables() doesn't work (13.89 KB, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)
2013-11-06 10:17 UTC, Walker
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Walker 2013-11-06 03:46:32 UTC
I'm using excel 2007 and POI-3.9.
When the number of tables in a sheet is greater than 6, the XSSFSheet.getTables() method fails to get all the tables, the result of expression getTables().size() equals zero.
I've tried with POI-3.10beta2, It failed, too.
Comment 1 Dominik Stadler 2013-11-06 06:08:29 UTC
Can you provide a sample file and test code which shows the problem? Preferably as unit test?
Comment 2 Walker 2013-11-06 10:17:53 UTC
Created attachment 31016 [details]
workbook with sheet on which getTables() doesn't work
Comment 3 Walker 2013-11-06 10:22:35 UTC
(In reply to Dominik Stadler from comment #1)
> Can you provide a sample file and test code which shows the problem?
> Preferably as unit test?

I tried it again, and found that: 
1). getTables() works when no table cells are commented;
2). getTables() works when some table cell is commented and the number of tables is less than 7, it fails when the number of tables is no less than 7.


The test class:

public class TablesTest {	
		public static void main(String[] args) throws InvalidFormatException, IOException {
			String workbook = "workbook.xlsx";
			OPCPackage pkg = OPCPackage.open(new File(workbook));
			XSSFWorkbook wb = new XSSFWorkbook(pkg);
			XSSFSheet sheet = wb.getSheetAt(0);
			System.out.println(sheet.getTables().size());
		}
}
Comment 4 Dominik Stadler 2013-11-28 15:17:49 UTC
This is fixed as part of r1546385, it was a simple coding error when handling comments and tables in XSSF, a loop was left upon the first comment table, disregarding all subsequent normal tables, thus leading to this problem. In fact it was kind of unpredictable, as I saw 1 table before putting the fix in place.