Top Description Inners Fields Constructors Methods
org.apache.poi.hssf.model

pack-priv final Class LinkTable

extends Object
Class Inheritance
Imports
java.util.ArrayList, .Iterator, .List, .Map, org.apache.poi.hssf.record.CRNCountRecord, .CRNRecord, .CountryRecord, .ExternSheetRecord, .ExternalNameRecord, .NameCommentRecord, .NameRecord, .Record, .SSTRecord, .SupBookRecord, org.apache.poi.ss.formula.SheetNameFormatter, org.apache.poi.ss.formula.ptg.Area3DPtg, .ErrPtg, .NameXPtg, .Ptg, .Ref3DPtg, org.apache.poi.ss.usermodel.Workbook

Link Table (OOO pdf reference: 4.10.3 )

The main data of all types of references is stored in the Link Table inside the Workbook Globals Substream (4.2.5). The Link Table itself is optional and occurs only if there are any references in the document.

In BIFF8 the Link Table consists of

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static class

Field Summary

Modifier and TypeField and Description
private final List<NameRecord>
private LinkTable.ExternalBookBlock[]
private final ExternSheetRecord
private final int
private final WorkbookRecordList

Constructor Summary

AccessConstructor and Description
public
LinkTable(List<Record> inputList, int startIndex, WorkbookRecordList workbookRecordList, Map<String, NameCommentRecord> commentRecords)

public
LinkTable(int numberOfSheets, WorkbookRecordList workbookRecordList)

Method Summary

Modifier and TypeMethod and Description
public void
public NameXPtg

Returns:

a NameXPtg describing this name
addNameXPtg
(String
the name to register
name
)

Register an external name in this workbook

public boolean

Returns:

true if the oldUrl was found and replaced with newUrl. Otherwise false
changeExternalReference
(String
The old URL to search for and which is to be replaced
oldUrl
,
String
The URL replacement
newUrl
)

Changes an external referenced file to another file.

public int
checkExternSheet(int sheetIndex)

public int
checkExternSheet(int firstSheetIndex, int lastSheetIndex)

private int
private int
findFirstRecordLocBySid(short sid)

copied from Workbook

private int
findRefIndexFromExtBookIndex(int extBookIndex)

public String[]
getExternalBookAndSheetName(int extRefIndex)

public int
getExternalSheetIndex(String workbookName, String firstSheetName, String lastSheetName)

private int
public int

Returns:

-1 if the reference is to an external book
getFirstInternalSheetIndexForExtIndex
(int
as from a Ref3DPtg or Area3DPtg
extRefIndex
)

public int

Returns:

-1 if the reference is to an external book
getLastInternalSheetIndexForExtIndex
(int
as from a Ref3DPtg or Area3DPtg
extRefIndex
)

public NameRecord
getNameRecord(int index)

public NameXPtg
getNameXPtg(String name, int
The Extern Sheet Index to look for, or -1 if any
sheetRefIndex
)

Finds the external name definition for the given name, optionally restricted by externsheet index, and returns (if found) as a NameXPtg.

public int
public int
getRecordCount()

TODO - would not be required if calling code used RecordStream or similar

private static int
getSheetIndex(String[] sheetNames, String sheetName)

public NameRecord
getSpecificBuiltinRecord(byte
a BUILTIN_~ constant from NameRecord
builtInCode
,
int
1-based sheet number
sheetNumber
)

private static boolean
private static boolean
isSameSheetNames(NameRecord firstName, NameRecord lastName)

public int
linkExternalWorkbook(String name, Workbook externalWorkbook)

public boolean
nameAlreadyExists(NameRecord name)

checks if the given name is already included in the linkTable

private static ExternSheetRecord
public void
removeBuiltinRecord(byte name, int sheetIndex)

public void
removeName(int namenum)

public void
removeSheet(int sheetIdx)

public int
resolveNameXIx(int refIndex, int definedNameIndex)

public String
resolveNameXText(int refIndex, int definedNameIndex, InternalWorkbook workbook)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

_definedNamesback to summary
private final List<NameRecord> _definedNames
_externalBookBlocksback to summary
private LinkTable.ExternalBookBlock[] _externalBookBlocks
_externSheetRecordback to summary
private final ExternSheetRecord _externSheetRecord
_recordCountback to summary
private final int _recordCount
_workbookRecordListback to summary
private final WorkbookRecordList _workbookRecordList

Constructor Detail

LinkTableback to summary
public LinkTable(List<Record> inputList, int startIndex, WorkbookRecordList workbookRecordList, Map<String, NameCommentRecord> commentRecords)
LinkTableback to summary
public LinkTable(int numberOfSheets, WorkbookRecordList workbookRecordList)

Method Detail

addNameback to summary
public void addName(NameRecord name)
addNameXPtgback to summary
public NameXPtg addNameXPtg(String name)

Register an external name in this workbook

Parameters
name:String

the name to register

Returns:NameXPtg

a NameXPtg describing this name

changeExternalReferenceback to summary
public boolean changeExternalReference(String oldUrl, String newUrl)

Changes an external referenced file to another file. A formular in Excel which refers a cell in another file is saved in two parts: The referenced file is stored in an reference table. the row/cell information is saved separate. This method invokation will only change the reference in the lookup-table itself.

Parameters
oldUrl:String

The old URL to search for and which is to be replaced

newUrl:String

The URL replacement

Returns:boolean

true if the oldUrl was found and replaced with newUrl. Otherwise false

checkExternSheetback to summary
public int checkExternSheet(int sheetIndex)
checkExternSheetback to summary
public int checkExternSheet(int firstSheetIndex, int lastSheetIndex)
extendExternalBookBlocksback to summary
private int extendExternalBookBlocks(LinkTable.ExternalBookBlock newBlock)
findFirstRecordLocBySidback to summary
private int findFirstRecordLocBySid(short sid)

copied from Workbook

findRefIndexFromExtBookIndexback to summary
private int findRefIndexFromExtBookIndex(int extBookIndex)
getExternalBookAndSheetNameback to summary
public String[] getExternalBookAndSheetName(int extRefIndex)
getExternalSheetIndexback to summary
public int getExternalSheetIndex(String workbookName, String firstSheetName, String lastSheetName)
getExternalWorkbookIndexback to summary
private int getExternalWorkbookIndex(String workbookName)
getFirstInternalSheetIndexForExtIndexback to summary
public int getFirstInternalSheetIndexForExtIndex(int extRefIndex)
Parameters
extRefIndex:int

as from a Ref3DPtg or Area3DPtg

Returns:int

-1 if the reference is to an external book

getLastInternalSheetIndexForExtIndexback to summary
public int getLastInternalSheetIndexForExtIndex(int extRefIndex)
Parameters
extRefIndex:int

as from a Ref3DPtg or Area3DPtg

Returns:int

-1 if the reference is to an external book

getNameRecordback to summary
public NameRecord getNameRecord(int index)
getNameXPtgback to summary
public NameXPtg getNameXPtg(String name, int sheetRefIndex)

Finds the external name definition for the given name, optionally restricted by externsheet index, and returns (if found) as a NameXPtg.

Parameters
sheetRefIndex:int

The Extern Sheet Index to look for, or -1 if any

getNumNamesback to summary
public int getNumNames()
getRecordCountback to summary
public int getRecordCount()

TODO - would not be required if calling code used RecordStream or similar

getSheetIndexback to summary
private static int getSheetIndex(String[] sheetNames, String sheetName)
getSpecificBuiltinRecordback to summary
public NameRecord getSpecificBuiltinRecord(byte builtInCode, int sheetNumber)
Parameters
builtInCode:byte

a BUILTIN_~ constant from NameRecord

sheetNumber:int

1-based sheet number

isDuplicatedNamesback to summary
private static boolean isDuplicatedNames(NameRecord firstName, NameRecord lastName)
isSameSheetNamesback to summary
private static boolean isSameSheetNames(NameRecord firstName, NameRecord lastName)
linkExternalWorkbookback to summary
public int linkExternalWorkbook(String name, Workbook externalWorkbook)
nameAlreadyExistsback to summary
public boolean nameAlreadyExists(NameRecord name)

checks if the given name is already included in the linkTable

readExtSheetRecordback to summary
private static ExternSheetRecord readExtSheetRecord(RecordStream rs)
removeBuiltinRecordback to summary
public void removeBuiltinRecord(byte name, int sheetIndex)
removeNameback to summary
public void removeName(int namenum)
removeSheetback to summary
public void removeSheet(int sheetIdx)
resolveNameXIxback to summary
public int resolveNameXIx(int refIndex, int definedNameIndex)
resolveNameXTextback to summary
public String resolveNameXText(int refIndex, int definedNameIndex, InternalWorkbook workbook)
org.apache.poi.hssf.model back to summary

private final Class LinkTable.CRNBlock

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final CRNCountRecord
private final CRNRecord[]

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public CRNRecord[]
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

_countRecordback to summary
private final CRNCountRecord _countRecord
_crnsback to summary
private final CRNRecord[] _crns

Constructor Detail

CRNBlockback to summary
public CRNBlock(RecordStream rs)

Method Detail

getCrnsback to summary
public CRNRecord[] getCrns()
org.apache.poi.hssf.model back to summary

private final Class LinkTable.ExternalBookBlock

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final LinkTable.CRNBlock[]
private final SupBookRecord
private ExternalNameRecord[]

Constructor Summary

AccessConstructor and Description
public
public
ExternalBookBlock(String url, String[] sheetNames)

Create a new block for external references.

public
ExternalBookBlock(int numberOfSheets)

Create a new block for internal references.

public
ExternalBookBlock()

Create a new block for registering add-in functions

Method Summary

Modifier and TypeMethod and Description
public int
public SupBookRecord
public int

Returns:

-1 if not found
getIndexOfName
(String name)

Performs case-insensitive search

public int
getNameIx(int definedNameIndex)

public String
getNameText(int definedNameIndex)

public int
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

_crnBlocksback to summary
private final LinkTable.CRNBlock[] _crnBlocks
_externalBookRecordback to summary
private final SupBookRecord _externalBookRecord
_externalNameRecordsback to summary
private ExternalNameRecord[] _externalNameRecords

Constructor Detail

ExternalBookBlockback to summary
public ExternalBookBlock(RecordStream rs)
ExternalBookBlockback to summary
public ExternalBookBlock(String url, String[] sheetNames)

Create a new block for external references.

ExternalBookBlockback to summary
public ExternalBookBlock(int numberOfSheets)

Create a new block for internal references. It is called when constructing a new LinkTable.

See Also
org.apache.poi.hssf.model.LinkTable#LinkTable(int, WorkbookRecordList)
ExternalBookBlockback to summary
public ExternalBookBlock()

Create a new block for registering add-in functions

See Also
org.apache.poi.hssf.model.LinkTable#addNameXPtg(String)

Method Detail

addExternalNameback to summary
public int addExternalName(ExternalNameRecord rec)
getExternalBookRecordback to summary
public SupBookRecord getExternalBookRecord()
getIndexOfNameback to summary
public int getIndexOfName(String name)

Performs case-insensitive search

Returns:int

-1 if not found

getNameIxback to summary
public int getNameIx(int definedNameIndex)
getNameTextback to summary
public String getNameText(int definedNameIndex)
getNumberOfNamesback to summary
public int getNumberOfNames()