zoukankan      html  css  js  c++  java
  • Excel导出下拉框(导出下拉框较多的选项)

    二、导出下拉框较多的选项

    使用常规下拉框的导出,会出现超过255字段异常的问题,可以使用引用隐藏的sheet来解决

    #region 设置下拉框
    if (dicDropList != null)
    {
    int bookIdenx = 1;
    foreach (var item in dicDropList)
    {
    if (item.Value == null || item.Value.Rows.Count == 0)
    {
    continue;
    }
    ISheet sheet2 = workbook.CreateSheet("ShtDictionary" + item.Key);
    for (int j = 0; j < item.Value.Rows.Count; j++)
    {
    sheet2.CreateRow(j).CreateCell(0).SetCellValue(item.Value.Rows[j][0].ToString());
    }
    IName range = workbook.CreateName();
    range.RefersToFormula = "ShtDictionary" + item.Key + "!$A$1:$A$" + item.Value.Rows.Count;    //这里引用位置不用错了 "!$A$1:$A$" + item.Value.Rows.Count
    range.NameName = "dicRange" + item.Key;

    CellRangeAddressList regions = new CellRangeAddressList(2, 65535, item.Key, item.Key);
    DVConstraint constraint = DVConstraint.CreateFormulaListConstraint("dicRange" + item.Key);
    HSSFDataValidation dataValidate = new HSSFDataValidation(regions, constraint);
    dataValidate.CreateErrorBox("输入不合法", "请输入下拉列表中的值。");
    sheet.AddValidationData(dataValidate);
    workbook.SetSheetHidden(bookIdenx, true);
    bookIdenx += 1;
    }
    }
    #endregion

  • 相关阅读:
    【美团面试题】——图遍历
    ubuntu15.04 + ROS jade
    3P(PS、PR、PDF编辑器Acrobat)中的基基本操作(三)
    谈谈你对组件的看法
    Web开发中跨域的几种解决方案
    JS事件模型
    zepto的clone方法于textarea和select的bug修复
    SASS使用总结
    git用法总结
    去除inline-block元素间间距
  • 原文地址:https://www.cnblogs.com/zhusk/p/10524986.html
Copyright © 2011-2022 走看看