123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- using System;
- using System.Collections.Generic;
- using System.Text;
- using System.Collections;
- namespace Biff8Excel.Excel
- {
- public class WorkSheetCollection : CollectionBase, IDisposable
- {
- Dictionary<string, ExcelWorksheet> Dictionary;
- public void Add(ExcelWorksheet worksheet)
- {
- this.Dictionary.Add(worksheet.SheetName, worksheet);
- this.List.Add(worksheet);
- }
- public ExcelWorksheet this[int index]
- {
-
-
-
-
- set
- {
- if (index < 1)
- throw new System.ArgumentException(" smaller than ","index");
-
- this.List[index-1] = value;
- }
- get
- {
- if (index < 1)
- throw new System.ArgumentException( " smaller than ","index");
-
- return this.List[index - 1] as ExcelWorksheet;
- }
- }
- public ExcelWorksheet this[string key]
- {
- set
- {
- if (this.Dictionary.ContainsKey(key))
- this.Dictionary[key] = value;
- else
- throw new Biff8ExcelException("no this key" + key);
- }
- get
- {
- ExcelWorksheet ew ;
- if ( this.Dictionary.TryGetValue(key, out ew))
- return ew;
- else
- throw new Biff8ExcelException("no this key" + key);
-
- }
- }
- public bool Contains(ExcelWorksheet sheet)
- {
- return this.List.Contains(sheet);
- }
- public void CopyTo(ExcelWorksheet[] sheets, int index)
- {
- this.List.CopyTo(sheets, index);
- }
- public new int Count
- {
-
-
- get { return this.Dictionary.Count; }
- }
- public int IndexOf(ExcelWorksheet sheet)
- {
- return this.List.IndexOf(sheet);
- }
- public void Remove(string vntIndexKey)
- {
-
-
-
-
- this.Dictionary.Remove(vntIndexKey);
- this.List.Remove(vntIndexKey);
- }
- public WorkSheetCollection()
- {
- Dictionary = new Dictionary<string, ExcelWorksheet>();
- }
- #region IDisposable 成员
- public void Dispose()
- {
- Dictionary = null;
- }
- #endregion
- }
- }
|