[英]Custom formula list data validation
因此,在 excel 中,您可以使用由公式確定的列表來創建數據驗證規則。 有誰知道如何使用 C# 和 ClosedXML 做到這一點?
您可以使用ICollection
或IList
實現自己的集合,並實現添加和刪除操作的規則。
public class myList : IList
{
private List<string> _list;
public myList()
{
_list = new List<string>();
}
public object this[int index] { get => _list[index]; set => throw new NotImplementedException(); }
public bool IsFixedSize => throw new NotImplementedException();
public bool IsReadOnly => throw new NotImplementedException();
public int Count => throw new NotImplementedException();
public bool IsSynchronized => throw new NotImplementedException();
public object SyncRoot => throw new NotImplementedException();
public int Add(object value)
{
throw new NotImplementedException();
}
public void Clear()
{
throw new NotImplementedException();
}
public bool Contains(object value)
{
throw new NotImplementedException();
}
public void CopyTo(Array array, int index)
{
throw new NotImplementedException();
}
public IEnumerator GetEnumerator()
{
throw new NotImplementedException();
}
public int IndexOf(object value)
{
throw new NotImplementedException();
}
public void Insert(int index, object value)
{
throw new NotImplementedException();
}
public void Remove(object value)
{
throw new NotImplementedException();
}
public void RemoveAt(int index)
{
throw new NotImplementedException();
}
}
對於一些不需要任何更改的操作,使用_list
相同操作來實現它們,例如索引設置器。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.