-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathExcelTableData.cs
39 lines (34 loc) · 1.14 KB
/
ExcelTableData.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
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ExcelDataReader;
namespace ExcelExport
{
public class ExcelTableData
{
public List<ExcelSheetData> excelSheets = new List<ExcelSheetData>();
public void LoadFromFile(string fileName)
{
var stream = File.Open(fileName, FileMode.Open, FileAccess.Read);
var reader = ExcelReaderFactory.CreateReader(stream);
for (int i = 0; i < reader.ResultsCount; i++)
{
var sheet = new ExcelSheetData();
LogUtils.instance.AddLog("读取页签:" + reader.Name);
sheet.ReadFromExcel(reader.Name, reader);
if (sheet.isNeedExprot)
{
excelSheets.Add(sheet);
} else
{
LogUtils.instance.AddLog("页签无需导出 , 跳过 :" + reader.Name);
}
reader.NextResult();
}
stream.Close();
}
}
}