@Test
public void readWithReferencesToTwoExternalBooks() {
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("ref2-56737.xlsx");
assertNotNull(wb.getExternalLinksTable());
Name name = null;
assertEquals(2, wb.getExternalLinksTable().size());
// Check the first one, links to 56737.xlsx
ExternalLinksTable links = wb.getExternalLinksTable().get(0);
assertEquals("56737.xlsx", links.getLinkedFileName());
assertEquals(3, links.getSheetNames().size());
assertEquals(2, links.getDefinedNames().size());
assertEquals("Uses", links.getSheetNames().get(0));
assertEquals("Defines", links.getSheetNames().get(1));
assertEquals("56737", links.getSheetNames().get(2));
name = links.getDefinedNames().get(0);
assertEquals("NR_Global_B2", name.getNameName());
assertEquals(-1, name.getSheetIndex());
assertEquals(null, name.getSheetName());
assertEquals("'Defines'!$B$2", name.getRefersToFormula());
name = links.getDefinedNames().get(1);
assertEquals("NR_To_A1", name.getNameName());
assertEquals(1, name.getSheetIndex());
assertEquals("Defines", name.getSheetName());
assertEquals("'Defines'!$A$1", name.getRefersToFormula());
// Check the second one, links to 56737.xls, slightly differently
links = wb.getExternalLinksTable().get(1);
assertEquals("56737.xls", links.getLinkedFileName());
assertEquals(2, links.getSheetNames().size());
assertEquals(2, links.getDefinedNames().size());
assertEquals("Uses", links.getSheetNames().get(0));
assertEquals("Defines", links.getSheetNames().get(1));
name = links.getDefinedNames().get(0);
assertEquals("NR_Global_B2", name.getNameName());
assertEquals(-1, name.getSheetIndex());
assertEquals(null, name.getSheetName());
assertEquals("'Defines'!$B$2", name.getRefersToFormula());
name = links.getDefinedNames().get(1);
assertEquals("NR_To_A1", name.getNameName());
assertEquals(1, name.getSheetIndex());
assertEquals("Defines", name.getSheetName());
assertEquals("'Defines'!$A$1", name.getRefersToFormula());
}