npoi设置数据有效性

    public void SetDataValidate(ISheet sheet, int firstCol, int lastCol)
{
CellRangeAddressList regions = new CellRangeAddressList(1, 65535, firstCol, lastCol);
DVConstraint constraint = DVConstraint.CreateDateConstraint(
(int)ComparisonOperator.Between, "1900-01-01", "2999-12-31", "yyyy-MM-dd");
HSSFDataValidation dataValidate = new HSSFDataValidation(regions, constraint);
dataValidate.EmptyCellAllowed = false;
dataValidate.CreateErrorBox("错误提示", "请输入日期'yyyy年MM月dd日'"); sheet.AddValidationData(dataValidate);
}

  

  

npoi设置数据有效性的更多相关文章

  1. poi操作excel设置数据有效性

    private void setDataValidationList(short firstRow,short endRow,short firstCol, short endCol,String d ...

  2. NPOI设置单元格背景色

    NPOI设置单元格背景色在网上有好多例子都是设置为NPOI内置的颜色值 但是想用rgb值来设置背景色,即:通过HSSFPalette类获取颜色值时会抛出异常:Could not Find free c ...

  3. NPOI设置Excel保护

    有时,我们可能需要某些单元格只读,如在做模板时,模板中的数据是不能随意让别人改的.在Excel中,可以通过“审阅->保护工作表”来完成,如下图:  那么,在NPOI中有没有办法通过编码的方式达到 ...

  4. Excel设置数据有效性实现单元格下拉菜单的3种方法(转)

    http://blog.csdn.net/cdefu/article/details/4129136 一.直接输入: 1.选择要设置的单元格,譬如A1单元格: 2.选择菜单栏的“数据”→“有效性”→出 ...

  5. NPOI设置单元格格式

    转自:http://www.cr173.com/html/18143_2.html //创建一个常用的xls文件 private void button3_Click(object sender, E ...

  6. NPOI设置Excel单元格字体、边框、对齐、背景色

    代码: ICellStyle cellStyle = workbook.CreateCellStyle(); cellStyle.BorderBottom = BorderStyle.Thin; ce ...

  7. NPOI 设置导出的excel内容样式

    导出excel时,有时要根据需要加上一些样式,以上几种样式是我在项目中用到的 一.给单元格加背景色只需两步:一是创建单元格背景景色对象:二是给单元格绑定样式 //创建单元格背景颜色对象 HSSFPal ...

  8. npoi 设置单元格格式

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

  9. NPOI设置水平、垂直居中

    C#语法: string fs = "@report.xls";//文件路径 FileStream excelPath = File.Open(@fs, FileMode.Open ...

随机推荐

  1. where后一个条件和多个条件的查询速度

    如果记录中有两个都是 唯一标识的  ,那是都where  and 还是只写一个比较快 ---- 一个快

  2. Git设置/取消代理

    设置代理 git config --global http.proxy http://proxy.com:1234 git config --global https.proxy http://pro ...

  3. Python类的进阶.md

    属性绑定 在python中可以给类对象动态的绑定属性 但是由于这种特性,随意动态绑定也会带来麻烦,因此可用__slots__来限制可绑定的属性名称 __slots__的绑定对于子类是不生效的,只对当前 ...

  4. python 基础回顾 一

    Python 基础回顾 可变类型:list ,dict 不可变类型:string,tuple,numbers tuple是不可变的,但是它包含的list dict是可变的. set 集合内部是唯一的 ...

  5. 动态修改属性设置 easyUI

    if(条件){  $("#area").combobox({ required:false }); }else{ $("#area").combobox({ r ...

  6. DBCC维护语句语法

    一.DBCC维护语句:对数据库.索引或文件组进行维护的任务--1.DBCC CLEANTABLE,回收删除的可变长度列和文本列的空间 DBCC CLEANTABLE  ( { 'database_na ...

  7. spring boot 使用war包部署

  8. hdu1215-七夕节-(埃氏筛+唯一分解定理)

    七夕节 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submiss ...

  9. 3D 模型

    http://www.imooc.com/article/12670

  10. Python Try Except

    Python Try: Except Except 类型一: try: file_size = os.path.getsize('maoyan.csv'); except OSError as err ...