positionId or sheetId ?

Topics: Developer Forum
Nov 9, 2007 at 7:08 AM
PositionId is the key of the worksheets dictionary, when I add a new worksheet into worksheets, positionId will set to worksheets.count+1:

int positionID = _worksheets.Count + 1;
_worksheets.Add(positionID, worksheet);

But when I delete a worksheet from worksheets with ExcelWorkshees.Delete(int positionID) method, these positionId keys of worksheets was not be renumbered, so If I add a new worksheet again, these codes will throw the exception "An item with the same key has already been added."
And, the positionId is not a public property of worksheet, so we can not get the key value out of the class, then we can not remove the sheet that we want to delete.

Why ExcelWorksheet.SheetId is protected internal ? and why said "... that these can be random ..." in comment summary? I think the positionId is a garbage design, it should be replaced by sheetId, and the SheetId property should be public.