Unity写EXCEL
来源:互联网 发布:雪姨王琳撕网络喷子 编辑:程序博客网 时间:2024/06/05 17:04
unity环境:5.34f1
需要用到的dll:EPPlus.dll 下载地址:https://epplus.codeplex.com/downloads/get/1591093
里面有2个版本:1个4.0的、1个2.0的 用2.0的[因为Unity默认的.net框架是3.5]
如图
准备工作:新建Plugins文件夹 把dll拖进去
如图
下面上代码
using UnityEngine;
using System.Linq;
using System.IO;
using System.Collections.Generic;
using OfficeOpenXml;
using Assets.Scripts.CameraControls;
namespace Assets.Scripts.Excel
{
public static class ExcelHelper
{
public static void ExportExcel()
{
string outPutDir = Application.dataPath + "\\SaleData.xls";
FileInfo newFile = new FileInfo(outPutDir);
if (newFile.Exists)
{
newFile.Delete(); // ensures we create a new workbook
newFile = new FileInfo(outPutDir);
}
using (ExcelPackage package = new ExcelPackage(newFile))
{
ExcelWorksheet worksheet = package.Workbook.Worksheets.Add("车位售卖数据");
worksheet.Cells[1, 1].Value = "序号";
worksheet.Cells[1, 2].Value = "车位编号";
worksheet.Cells[1, 3].Value = "长(mm)";
worksheet.Cells[1, 4].Value = "宽(mm)";
worksheet.Cells[1, 5].Value = "状态";
int i = 1;
List<SationNode> sationNodeList = StaticMemory.SastionInfomation.OrderBy(p=>p.No).ToList();
foreach (SationNode node in sationNodeList)
{
i++;
worksheet.Cells[i,1].Value = i.ToString();
worksheet.Cells[i, 2].Value = node.No;
worksheet.Cells[i, 3].Value = node.SationLong;
worksheet.Cells[i, 4].Value = node.SationWidth;
string state = "未售";
int saleFlag = PlayerPrefs.GetInt(node.Id);
switch (saleFlag)
{
case 0: state = "未售"; break;
case 1: state = "预售"; break;
case 2: state = "已售"; break;
}
worksheet.Cells[i, 5].Value = state;
}
package.Save();
}
}
}
}
效果
- Unity写EXCEL
- Unity读取Excel数据
- Unity 解析Excel
- Unity生成Excel表
- 201710020135->unity读excel
- Java 写文件 写excel
- java 写EXCEL文件
- 写一个excel文件
- JXL实例 写excel
- jxl 写excel(转)
- poi写excel文件
- C1XLS写Excel文件
- 自己写的Excel
- jxl 写Excel
- poi写Excel文档
- struts2写EXCEL输出
- jxl写Excel文件
- jxl 写 excel
- 最左原位、完全二叉树计数、快速N次方
- 主从复制GTID模式下主库binary log被删除后的处理方法
- Eclipse安装SVN的步骤
- CentOS下安装配置SVN简易步骤---实际操作记录
- Hadoop免密登录之SSH协议
- Unity写EXCEL
- 价值2.5万美金的思维方法
- 防破解嵌入式安全加密芯片SMEC98SP快速上手指南
- 让cmake显示gcc/g++的编译信息
- 前端解决跨域问题的8种方案(最新最全)
- 重定位
- 1057 N的阶乘 【数论】
- mybatis 一对一、一对多、多对多的设计
- 【转载】 IEC104规约的超时和报文丢失重发的处理机制