|
-
Mar 26th, 2006, 11:37 PM
#1
Thread Starter
Fanatic Member
[VS2005] Data Structures
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
-
Mar 27th, 2006, 02:48 AM
#2
Re: [VS2005] Data Structures
I really don't see how an ArrayList can "lose" files. Items are only removed when you remove them, so that would imply that you are removing items from one or both of the Arraylists when you shouldn't be.
Also, I really think methods would be more appropriate than properties, particulary for XLQueueFile. A property is absolutely not appropriate for that, while a case could at least be made for the other two, although getting a property shouldn't change that property, so a method would still be more appropriate for those two as well.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|