87 lines
1.7 KiB
C#
87 lines
1.7 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
namespace CPF.ReoGrid
|
|
{
|
|
public class NamedRangeCollection : ICollection<NamedRange>, IEnumerable<NamedRange>, IEnumerable
|
|
{
|
|
internal NamedRangeCollection(Worksheet sheet)
|
|
{
|
|
this.sheet = sheet;
|
|
}
|
|
|
|
public void Add(NamedRange item)
|
|
{
|
|
this.sheet.AddNamedRange(item);
|
|
}
|
|
|
|
public void Clear()
|
|
{
|
|
this.sheet.registeredNamedRanges.Clear();
|
|
}
|
|
|
|
public bool Contains(NamedRange range)
|
|
{
|
|
return this.sheet.registeredNamedRanges.Values.Any((NamedRange nr) => nr.Name == range.Name && nr.Position == range.Position);
|
|
}
|
|
|
|
public void CopyTo(NamedRange[] array, int arrayIndex)
|
|
{
|
|
this.sheet.registeredNamedRanges.Values.CopyTo(array, arrayIndex);
|
|
}
|
|
|
|
public int Count
|
|
{
|
|
get
|
|
{
|
|
return this.sheet.registeredNamedRanges.Values.Count;
|
|
}
|
|
}
|
|
|
|
public bool IsReadOnly
|
|
{
|
|
get
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public bool Remove(NamedRange range)
|
|
{
|
|
return this.sheet.UndefineNamedRange(range.Name);
|
|
}
|
|
|
|
public IEnumerator<NamedRange> GetEnumerator()
|
|
{
|
|
return this.sheet.registeredNamedRanges.Values.GetEnumerator();
|
|
}
|
|
|
|
IEnumerator IEnumerable.GetEnumerator()
|
|
{
|
|
return this.sheet.registeredNamedRanges.Values.GetEnumerator();
|
|
}
|
|
|
|
public NamedRange this[string name]
|
|
{
|
|
get
|
|
{
|
|
NamedRange namedRange;
|
|
return this.sheet.TryGetNamedRange(name, out namedRange) ? namedRange : null;
|
|
}
|
|
set
|
|
{
|
|
bool flag = value.Name != name;
|
|
if (flag)
|
|
{
|
|
throw new ArgumentException("Specified name is different from the name that is set in the range instance.", "name");
|
|
}
|
|
this.sheet.AddNamedRange(value);
|
|
}
|
|
}
|
|
|
|
private Worksheet sheet;
|
|
}
|
|
}
|