public NameXPtg addNameXPtg(String name) {int extBlockIndex = -1;ExternalBookBlock extBlock = null;for (int i = 0; i < _externalBookBlocks.length; i++) {SupBookRecord ebr = _externalBookBlocks[i].getExternalBookRecord();if (ebr.isAddInFunctions()) {extBlock = _externalBookBlocks[i];extBlockIndex = i;break;}}if (extBlock == null) {extBlock = new ExternalBookBlock();extBlockIndex = extendExternalBookBlocks(extBlock);int idx = findFirstRecordLocBySid(ExternSheetRecord.sid);_workbookRecordList.add(idx, extBlock.getExternalBookRecord());_externSheetRecord.addRef(_externalBookBlocks.length - 1, -2, -2);}ExternalNameRecord extNameRecord = new ExternalNameRecord();extNameRecord.setText(name);extNameRecord.setParsedExpression(new Ptg[]{ErrPtg.REF_INVALID});int nameIndex = extBlock.addExternalName(extNameRecord);int supLinkIndex = 0;for (org.apache.poi.hssf.record.Record record : _workbookRecordList.getRecords()) {if (record instanceof SupBookRecord && ((SupBookRecord) record).isAddInFunctions()) {break;}supLinkIndex++;}int numberOfNames = extBlock.getNumberOfNames();_workbookRecordList.add(supLinkIndex + numberOfNames, extNameRecord);int fakeSheetIdx = -2; int ix = _externSheetRecord.getRefIxForSheet(extBlockIndex, fakeSheetIdx, fakeSheetIdx);return new NameXPtg(ix, nameIndex);}

public NameXPtg AddNameXPtg(String name){int extBlockIndex = -1;ExternalBookBlock extBlock = null;for (int i = 0; i < _externalBookBlocks.Length; i++){SupBookRecord ebr = _externalBookBlocks[i].GetExternalBookRecord();if (ebr.IsAddInFunctions){extBlock = _externalBookBlocks[i];extBlockIndex = i;break;}}if (extBlock == null){extBlock = new ExternalBookBlock();extBlockIndex = ExtendExternalBookBlocks(extBlock);int idx = FindFirstRecordLocBySid(ExternSheetRecord.sid);_workbookRecordList.Add(idx, extBlock.GetExternalBookRecord());_externSheetRecord.AddRef(_externalBookBlocks.Length - 1, -2, -2);}ExternalNameRecord extNameRecord = new ExternalNameRecord();extNameRecord.Text = (name);extNameRecord.SetParsedExpression(new Ptg[] { ErrPtg.REF_INVALID });int nameIndex = extBlock.AddExternalName(extNameRecord);int supLinkIndex = 0;for (IEnumerator iterator = _workbookRecordList.GetEnumerator(); iterator.MoveNext(); supLinkIndex++){Record record = (Record)iterator.Current;if (record is SupBookRecord){if (((SupBookRecord)record).IsAddInFunctions) break;}}int numberOfNames = extBlock.NumberOfNames;_workbookRecordList.Add(supLinkIndex + numberOfNames, extNameRecord);int fakeSheetIdx = -2; int ix = _externSheetRecord.GetRefIxForSheet(extBlockIndex, fakeSheetIdx, fakeSheetIdx);return new NameXPtg(ix, nameIndex);}
