/// <summary>
/// 设置某区域的有效性列表
/// </summary>
/// <param name="list"></param>
/// <param name="colIndex"></param>
/// <returns></returns>
private static HSSFDataValidation GetDataListValidation(string[] list, int colIndex) //add by xl
{
//设置数据有效性作用域
CellRangeAddressList regions = GetRegionByColIndex(colIndex);
//生成下拉框内容
DVConstraint constraint = DVConstraint.CreateExplicitListConstraint(list);
//绑定下拉框和作用区域
HSSFDataValidation data_validation = new HSSFDataValidation(regions, constraint);
//data_validation.CreateErrorBox("输入不合法", "请输入下拉列表中的值。");
return data_validation;
}
/// <summary>
/// 根据列序号获取整列区域
/// </summary>
/// <param name="colIndex"></param>
/// <returns></returns>
private static CellRangeAddressList GetRegionByColIndex(int colIndex) //add by xl
{
return new CellRangeAddressList(3, 65535, colIndex, colIndex);
}
|
|