資源簡介
Unity3d動態創建excel并寫入數據

代碼片段和文件信息
using?UnityEngine;??
using?System.Collections;??
using?org.in2bits.MyXls;??
using?System.Collections.Generic;??
public?class?TestInfo??
{??
????public?string?name;??
????public?string?id;??
????public?string?num;??
};??
public?class?ExcelMakerManager??{??
??
????public?static?ExcelMakerManager?eInstance;??
????public?static?ExcelMakerManager?CreateExcelMakerManager()???
????{??
????????if(eInstance==null)??
????????{??
????????????eInstance?=?new?ExcelMakerManager();??
????????}??
????????return?eInstance;??
????}??
????//鏈表為?物體信息?.??
????public?void?ExcelMaker(string?name?List?listInfo)??
????{??
????????XlsDocument?xls?=?new?XlsDocument();//新建一個xls文檔??
????????xls.FileName?=?name;//?@“D:\tests.xls“;//設定文件名??
??
????????//Add?some?metadata?(visible?from?Excel?under?File?->?Properties)??
????????xls.SummaryInformation.Author?=?“xyy“;?//填加xls文件作者信息??
????????xls.SummaryInformation.Subject?=?“test“;//填加文件主題信息??
??
????????string?sheetName?=?“Sheet0“;??
????????Worksheet?sheet?=?xls.Workbook.Worksheets.AddNamed(sheetName);//填加名為“chc?實例“的sheet頁??
????????Cells?cells?=?sheet.Cells;//Cells實例是sheet頁中單元格(cell)集合??
??
????????int?rowNum?=?listInfo.Count;??
????????int?rowMin?=?1;??
????????int?row?=?0;??
??
????????for?(int?x?=?0;?x?????????{??
????????????if?(x?==?0)??
????????????{??
????????????????//根據具體的物體信息?.需要重新寫??
????????????????cells.Add(1?1?“名字“);??
????????????????cells.Add(1?2?“ID“);??
????????????????cells.Add(1?3?“數量“);??
????????????}??
????????????else??
????????????{??
????????????????cells.Add(rowMin?+?x?1?listInfo[row].id);??
????????????????cells.Add(rowMin?+?x?2?listInfo[row].name);??
????????????????cells.Add(rowMin?+?x?3?listInfo[row].num);??
????????????????row++;??
????????????}??
????????}??
????????xls.Save();??
????}??
}??
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2013-09-18?14:55??Unity3d動態創建excel并寫入數據\
?????文件????????1960??2013-09-18?14:47??Unity3d動態創建excel并寫入數據\ExcelMakerManager.cs
?????文件??????125952??2010-01-27?12:38??Unity3d動態創建excel并寫入數據\org.in2bits.MyXls.dll
?????文件????????1808??2013-10-24?11:48??Unity3d動態創建excel并寫入數據\test.cs
評論
共有 條評論