-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathZipWorker.cs
executable file
·64 lines (59 loc) · 1.82 KB
/
ZipWorker.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*----------------------------------------------------------------
// Copyright (C) 2015 广州,Lucky Game
//
// 模块名:
// 创建者:D.S.Qiu
// 修改者列表:
// 创建日期:June 04 2016
// 模块描述:
//----------------------------------------------------------------*/
using System.IO;
using System.IO.Compression;
using System.Text;
namespace PureExcel
{
public static class ZipWorker
{
public static string GetXmlText(this ZipArchive archive, string fileNameInZip)
{
ZipArchive.ZipEntry entry = archive.GetEntry(fileNameInZip);
string xml = string.Empty;
if (entry != null)
{
MemoryStream ms = new MemoryStream();
archive.ExtractFile(entry, ms);
xml = Encoding.UTF8.GetString(ms.ToArray());
ms.Dispose();
}
return xml;
}
public static XMLNode GetXmlNode(this ZipArchive archive, string fileNameInZip)
{
string xmlText = GetXmlText(archive, fileNameInZip);
if (string.IsNullOrEmpty(xmlText))
return null;
return XMLParser.Parse(xmlText);
}
/*#if UNITY_EDITOR
[UnityEditor.MenuItem("Test/ParserExcel")]
public static void DoTest()
{
string excelFile = EditorUtils.ProjectPath + "Assets/Editor/GameConfig/c场景配置表1.xlsx";
m_Excel excel = new m_Excel(excelFile);
var works = excel.WorkSheets;
Worksheet work = excel.Read(0);
int rowIndex = 0;
foreach(Row row in work.Rows)
{
int cellIndex = 0;
foreach(Cell cell in row.Cells)
{
UnityEngine.Debug.Log ("ceil(" + rowIndex + "," + cellIndex + "):" + cell.Value);
cellIndex++;
}
rowIndex++;
}
}
#endif*/
}
}