资源简介
unity读取Excel
代码片段和文件信息
using UnityEngine;
using System;
using System.IO;
using System.Data;
using Excel;
using OfficeOpenxml;
using System.Collections.Generic;
using ICSharpCode.SharpZipLib;
public class excel : MonoBehaviour
{
// Use this for initialization
void Start()
{
//WriteExcel(Application.dataPath + “/Book1.xls“);
//ReadExcel(Application.dataPath + “/Book1.xls“);
}
// Update is called once per frame
void Update()
{
}
public static void ReadExcel(string outputDir)
{
FileStream stream = File.Open(outputDir FileMode.Open FileAccess.Read);
IExcelDataReader excelReader = ExcelReaderFactory.CreateOpenxmlReader(stream);
do
{
// sheet name
Debug.Log(excelReader.Name);
while (excelReader.Read())
{
for (int i = 0; i < excelReader.FieldCount; i++)
{
string value = excelReader.IsDBNull(i) ? ““ : excelReader.GetString(i);
Debug.Log(value);
}
}
} while (excelReader.NextResult());
}
public static void WriteExcel(string outputDir)
{
//string outputDir = EditorUtility.SaveFilePanel(“Save Excel“ ““ “New Resource“ “xlsx“);
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))
{
// add a new worksheet to the empty workbook
ExcelWorksheet worksheet = package.Workbook.Worksheets.Add(“Sheet1“);
//Add the headers
worksheet.Cells[1 1].Value = “ID“;
worksheet.Cells[1 2].Value = “Product“;
worksheet.Cells[1 3].Value = “Quantity“;
worksheet.Cells[1 4].Value = “Price“;
worksheet.Cells[1 5].Value = “Value“;
//Add some items...
worksheet.Cells[“A2“].Value = 12001;
worksheet.Cells[“B2“].Value = “Nails“;
worksheet.Cells[“C2“].Value = 37;
worksheet.Cells[“D2“].Value = 3.99;
worksheet.Cells[“A3“].Value = 12002;
worksheet.Cells[“B3“].Value = “Hammer“;
worksheet.Cells[“C3“].Value = 5;
worksheet.Cells[“D3“].Value = 12.10;
worksheet.Cells[“A4“].Value = 12003;
worksheet.Cells[“B4“].Value = “Saw“;
worksheet.Cells[“C4“].Value = 12;
worksheet.Cells[“D4“].Value = 15.37;
//save our new workbook and we are done!
package.Save();
}
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 1068032 2016-01-08 10:00 Plugins\EPPlus.dll
文件 1584498 2016-01-08 10:00 Plugins\EPPlus.xm
文件 68608 2014-01-30 20:10 Plugins\Excel.dll
文件 237056 2014-01-30 20:10 Plugins\Excel.pdb
文件 680960 2014-05-26 15:56 Plugins\I18N.CJK.dll
文件 32256 2014-05-26 15:56 Plugins\I18N.dll
文件 66048 2014-05-26 15:56 Plugins\I18N.West.dll
文件 192512 2014-01-02 21:05 Plugins\ICSharpCode.SharpZipLib.dll
文件 712192 2014-05-26 15:56 Plugins\System.Data.dll
文件 2800 2017-06-06 12:40 excel.cs
目录 0 2017-06-07 15:07 Plugins
----------- --------- ---------- ----- ----
4644962 11
相关资源
- polyvav2D-1.5.2_BehaviorDesigner.unitypackage
- C# 读写excel word(不用安装office)
- 读取mdb输出到Excel
-
xm
l操作类(xm lProcess.cs) - 软键盘(Package_KeyBoard.unitypackage)
- EF(oracel数据库的增、删、改、查)
- unity5圣典中文API手册v0.02.chm
- 各种方式对excel导出导入
- Unity 房间游览
- 程序发布服务WindowsService
- excel转化成datatable 并加载到datagridvi
- 读取Excel表格内容到treeview
- ADO.NET操作EXCEL
- 百塞尔曲线粒子插件(.unitypackage)
- 关于C#中VCI_BOARD_INFO1结构体与VCI_Find
- excel导入 导出分析源码
- 皮带传送、齿轮unity
- C# Access版资产管理系统源代码
- unity3d脚本学习教程
- C# 创建doc文档(基于Microsoft.Office.In
- c#茶楼管理系统源码(ACCESS )
- C#进销存管理系统(Access数据库)英文
- Unity日历插件
- 空间拓扑查询(ArcEngine)
- 学生管理系统(源码+access数据库)
- XenCenter开发
- C#编写的KTV系统(附access数据库)
- lua C# .Net4.0 vs2010 LuaInterface
- C#文件流读取CSV文件
- 安卓和asp.net通过webservice上传图片到服
评论
共有 条评论