-
Notifications
You must be signed in to change notification settings - Fork 493
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
49 changed files
with
4,774 additions
and
63,490 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,8 @@ | |
*.sln.docstates | ||
|
||
# Build results | ||
packages/ | ||
.vs/ | ||
[Dd]ebug/ | ||
[Dd]ebugPublic/ | ||
[Rr]elease/ | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
{ | ||
"NPC": { | ||
"BS001": { | ||
"ID": "BS001", | ||
"Name": "鬼道士", | ||
"AssetName": "BS001", | ||
"HP": 100, | ||
"Attack": 15, | ||
"Defence": 0, | ||
"ActPoints": 5, | ||
"ActSpeed": 1.5, | ||
"Hit": 8, | ||
"Dodge": 0, | ||
"Critical": 8, | ||
"BS001": "BS001" | ||
}, | ||
"BS002": { | ||
"ID": "BS002", | ||
"Name": "钟馗", | ||
"AssetName": "BS002", | ||
"HP": 352, | ||
"Attack": 22, | ||
"Defence": 3, | ||
"ActPoints": 32, | ||
"ActSpeed": 4, | ||
"Hit": 3, | ||
"Dodge": 4, | ||
"Critical": 2, | ||
"BS002": "BS002" | ||
}, | ||
"BS003": { | ||
"ID": "BS003", | ||
"Name": "", | ||
"AssetName": "BS003", | ||
"HP": 332, | ||
"Attack": 3, | ||
"Defence": 44, | ||
"ActPoints": 432, | ||
"ActSpeed": 4, | ||
"Hit": 3, | ||
"Dodge": 4, | ||
"Critical": 2, | ||
"BS003": "BS003" | ||
} | ||
}, | ||
"Item": { | ||
"WP001": { | ||
"ID": "WP001", | ||
"Name": "倚天剑", | ||
"AssetName": "ICON01", | ||
"WP001": "WP001" | ||
}, | ||
"WP002": { | ||
"ID": "WP002", | ||
"Name": "屠龙刀", | ||
"AssetName": "ICON02", | ||
"WP002": "WP002" | ||
} | ||
} | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
using System; | ||
using System.IO; | ||
using System.Data; | ||
using ExcelDataReader; | ||
|
||
namespace excel2json { | ||
/// <summary> | ||
/// 将 Excel 文件(*.xls 或者 *.xlsx)加载到内存 DataSet | ||
/// </summary> | ||
class ExcelLoader { | ||
private DataSet mData; | ||
|
||
// TODO: add Sheet Struct Define | ||
|
||
public ExcelLoader(string filePath, int headerRow) { | ||
using (var stream = File.Open(filePath, FileMode.Open, FileAccess.Read)) { | ||
// Auto-detect format, supports: | ||
// - Binary Excel files (2.0-2003 format; *.xls) | ||
// - OpenXml Excel files (2007 format; *.xlsx) | ||
using (var reader = ExcelReaderFactory.CreateReader(stream)) { | ||
// Use the AsDataSet extension method | ||
// The result of each spreadsheet is in result.Tables | ||
var result = reader.AsDataSet(createDataSetReadConfig(headerRow)); | ||
this.mData = result; | ||
} | ||
} | ||
|
||
if (this.Sheets.Count < 1) { | ||
throw new Exception("Excel file is empty: " + filePath); | ||
} | ||
} | ||
|
||
public DataTableCollection Sheets { | ||
get { | ||
return this.mData.Tables; | ||
} | ||
} | ||
|
||
private ExcelDataSetConfiguration createDataSetReadConfig(int headerRow) { | ||
var tableConfig = new ExcelDataTableConfiguration() { | ||
// Gets or sets a value indicating whether to use a row from the | ||
// data as column names. | ||
UseHeaderRow = true, | ||
|
||
// Gets or sets a callback to determine whether to include the | ||
// current row in the DataTable. | ||
FilterRow = (rowReader) => { | ||
return rowReader.Depth > headerRow - 1; | ||
}, | ||
}; | ||
|
||
return new ExcelDataSetConfiguration() { | ||
// Gets or sets a value indicating whether to set the DataColumn.DataType | ||
// property in a second pass. | ||
UseColumnDataType = true, | ||
|
||
// Gets or sets a callback to obtain configuration options for a DataTable. | ||
ConfigureDataTable = (tableReader) => { return tableConfig; }, | ||
}; | ||
} | ||
} | ||
} |
Oops, something went wrong.