I am having a problem trying to keep track of some Excel Files and Sheet names.
These excel files and sheets are created dynamically, when a user clicks some buttons is creates the excel file and the sheet. I have been trying to use an arraylist but for some reason it is loosing files. Is there a better structure I can use that can relate File to Sheet and Sheet to File.
I have thought about a Hashtable for each excel file be the key (since they will always be unique) and value as the sheet name but I need to file name as well.
Here is the code I am using this far...
cQueueExcelFiles and cSheets are both arraylist.
VB Code:
///<summary> /// Gets the next excel file in the queue, returns null if nothing left in queue. ///</summary> public string XlNextFile { get { string next = null; try { next = (String)cQueueExcelFile[this.cQueueExcelFile.Count - 1]; cQueueExcelFile.Remove(next); } catch (ArgumentOutOfRangeException) { next = null; } return next; } } ///<summary> /// Returns the next excel sheet name. ///</summary> private string XlNextSheet { get { string next = null; try { next = (String)this.cSheets[this.cSheets.Count - 1]; cSheets.Remove(next); } catch (ArgumentOutOfRangeException) { next = null; } return next; } } ///<summary> /// Sets the Excel Files waiting to be processed in a Queue. ///</summary> public string XlQueueFile { set { if (this.cQueueExcelFile == null) { cQueueExcelFile = new ArrayList(); } this.cQueueExcelFile.Add(value.ToString()); } } #endregion




Reply With Quote