zoukankan      html  css  js  c++  java
  • unity, 读写xls

    可以用npoi:

    http://npoi.codeplex.com/

    把npoi.dll放在unity里即可。

    读取代码:

    using System.IO;
    using NPOI.SS.UserModel;
    using NPOI.HSSF.UserModel;


    using (FileStream stream = File.Open(m_excelPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
    {
      IWorkbook book = new HSSFWorkbook(stream);

      for (int i = 0; i < book.NumberOfSheets; ++i) {
        ISheet s = book.GetSheetAt (i);
        Debug.Log ("sheetName:"+s.SheetName);
        //s.LastRowNum的索引值,不是行总数,从0开始计数
        for (int k = 0; k <= s.LastRowNum; ++k) {
          IRow row = s.GetRow (k);
          if (null == row) {
            continue;
          }

          //print cell[0]

          ICell cell = row.GetCell (0);
          string cellValueStr= getCellValue (cell);
          Debug.Log ("cellValueStr:"+cellValueStr);
        }
      }

    }


    protected string getCellValue(ICell cell)
    {
      if (null == cell) return "";

      if (CellType.NUMERIC == cell.CellType) {
        return cell.NumericCellValue.ToString ();
      } else {
        return cell.StringCellValue;
      }
    }

  • 相关阅读:
    在已安装的PHP版本之间切换
    LDAP系列(一)完整的 LDAP + phpLDAPadmin安装部署流程
    如何关闭Windows自动更新
    win10安装SDK、JAVA、Python配置环境变量
    怎么看懂接口文档
    全面解析 Postman 工具
    API接口监控
    jmeter面试题
    Navicat for MySQL 连接数据库
    Linux系统
  • 原文地址:https://www.cnblogs.com/wantnon/p/6051419.html
Copyright © 2011-2022 走看看