zoukankan      html  css  js  c++  java
  • c# 导入导出Excel

    1.引用两个js

    Codaxy.Xlio.dll
    Codaxy.Xlio.XmlSerializers.dll

    2.导出

     public string EntityListToExcel(string physicalPath, IList<ExportCatalog> enList, string sheetName)
            {
                var folderPath = MyPathHelper.GetFolderPath(physicalPath);
                var workbook = new Workbook();
                var sheet = workbook.Sheets.AddSheet(sheetName);
                var headers = sheet["A1", "C1"];
                headers[0].Value = "学段"; //access a cell relative to range's top-left corner
                headers[1].Value = "年级";
                headers[2].Value = "学科";
                headers[3].Value = "知识点目录";
                headers[4].Value = "知识点";
                int rowIndex = 1; // 从第二行开始赋值(第一行已设置为单元头)
                foreach (var en in enList)
                {
                    sheet[rowIndex, 0].Value = en.phaseName;
                    sheet[rowIndex, 1].Value = en.gradeName;
                    sheet[rowIndex, 2].Value =en.subjectName;
                    sheet[rowIndex, 3].Value = en.oneName;
                    sheet[rowIndex, 4].Value = en.twoName;
                    rowIndex++;
                }
                workbook.Save(physicalPath);
                return folderPath;
            }

    3.导入

  • 相关阅读:
    python中字典排序,列表中的字典排序
    Python模块:operator简单介绍
    java 物理资源回收 finally与try
    Eclipse相对路径
    java Lambda
    java 匿名内部类
    java File类
    java单例类
    java 创建子类
    jvm运行时数据区域
  • 原文地址:https://www.cnblogs.com/zhtbk/p/5116675.html
Copyright © 2011-2022 走看看