forked from neil3d/excel2json
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathProgram.Options.cs
69 lines (60 loc) · 2.18 KB
/
Program.Options.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
65
66
67
68
69
using System;
using CommandLine;
using CommandLine.Text;
namespace excel2json {
partial class Program {
/// <summary>
/// 命令行参数定义
/// </summary>
internal sealed class Options {
public Options() {
this.HeaderRows = 3;
this.Encoding = "utf8-nobom";
this.Lowcase = false;
this.ExportArray = false;
this.ForceSheetName = false;
}
[Option('e', "excel", Required = true, HelpText = "input excel file path.")]
public string ExcelPath {
get;
set;
}
[Option('j', "json", Required = false, HelpText = "export json file path.")]
public string JsonPath {
get;
set;
}
[Option('h', "header", Required = false, DefaultValue = 1, HelpText = "number lines in sheet as header.")]
public int HeaderRows {
get;
set;
}
[Option('c', "encoding", Required = false, DefaultValue = "utf8-nobom", HelpText = "export file encoding.")]
public string Encoding {
get;
set;
}
[Option('l', "lowcase", Required = false, DefaultValue = false, HelpText = "convert filed name to lowcase.")]
public bool Lowcase {
get;
set;
}
[Option('a', "array", Required = false, DefaultValue = false, HelpText = "export as array, otherwise as dict object.")]
public bool ExportArray {
get;
set;
}
[Option('d', "date", Required = false, DefaultValue = "yyyy/MM/dd", HelpText = "Date Format String, example: dd / MM / yyy hh: mm:ss.")]
public string DateFormat {
get;
set;
}
[Option('s', "sheet", Required = false, DefaultValue = false, HelpText = "export with sheet name, even there's only one sheet.")]
public bool ForceSheetName
{
get;
set;
}
}
}
}