-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathExcel.Worksheets.cs
executable file
·53 lines (51 loc) · 1.57 KB
/
Excel.Worksheets.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
/*----------------------------------------------------------------
// Copyright (C) 2015 广州,Lucky Game
//
// 模块名:
// 创建者:D.S.Qiu
// 修改者列表:
// 创建日期:June 03 2016
// 模块描述:
//----------------------------------------------------------------*/
using System;
using System.Collections.Generic;
namespace PureExcel
{
public partial class Excel
{
private Worksheet[] m_Worksheets;
/// <summary>
/// List of worksheets, loaded on first access of property
/// </summary>
public Worksheet[] WorkSheets
{
get
{
if (m_Worksheets == null)
{
m_Worksheets = GetWorksheetProperties();
}
return m_Worksheets;
}
}
private Worksheet[] GetWorksheetProperties()
{
PrepareArchive();
var worksheets = new List<Worksheet>();
XMLNode document = this.m_Archive.GetXmlNode("xl/workbook.xml");
if (document == null)
{
throw new Exception("Unable to load workbook.xml");
}
XMLNodeList nodeList = document.GetNodeList ("workbook>0>sheets>0>sheet");
foreach (XMLNode node in nodeList)
{
var worksheet = new Worksheet(this);
worksheet.Index = int.Parse(node.GetValue("@r:id").Replace("rId", ""));
worksheet.Name = node.GetValue ("@name");
worksheets.Add(worksheet);
}
return worksheets.ToArray();
}
}
}