Skip to content

Commit

Permalink
text
Browse files Browse the repository at this point in the history
  • Loading branch information
neil3d committed Oct 28, 2017
1 parent 7a6f21e commit 86dba48
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
16 changes: 8 additions & 8 deletions Program.Options.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,56 +11,56 @@ partial class Program
/// </summary>
private sealed class Options
{
[Option('e', "excel", Required=true, HelpText = "输入的Excel文件路径.")]
[Option('e', "excel", Required=true, HelpText = "input excel file path.")]
public string ExcelPath
{
get;
set;
}

[Option('j', "json", Required = false, HelpText = "指定输出的json文件路径.")]
[Option('j', "json", Required = false, HelpText = "export json file path.")]
public string JsonPath
{
get;
set;
}

[Option('s', "sql", Required = false, HelpText = "指定输出的SQL文件路径.")]
[Option('s', "sql", Required = false, HelpText = "export SQL file path.")]
public string SQLPath
{
get;
set;
}

[Option('p', "csharp", Required = false, HelpText = "指定输出的C#数据定义代码文件路径.")]
[Option('p', "csharp", Required = false, HelpText = "export C# data struct code file path.")]
public string CSharpPath
{
get;
set;
}

[Option('h', "header", Required = true, HelpText = "表格中有几行是表头.")]
[Option('h', "header", Required = true, HelpText = "number lines in sheet as header.")]
public int HeaderRows
{
get;
set;
}

[Option('c', "encoding", Required = false, DefaultValue="utf8-nobom", HelpText = "指定编码的名称.")]
[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 = "字段名称自动转换为小写")]
[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 = "导出为数组")]
[Option('a', "array", Required = false, DefaultValue = false, HelpText = "export as array, otherwise as dict object.")]
public bool ExportArray
{
get;
Expand Down
6 changes: 3 additions & 3 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ static void Main(string[] args)
System.DateTime endTime = System.DateTime.Now;
System.TimeSpan dur = endTime - startTime;
Console.WriteLine(
string.Format("[{0}]:\t转换完成[{1}毫秒].",
string.Format("[{0}]:\tConversion complete in [{1}ms].",
Path.GetFileName(options.ExcelPath),
dur.TotalMilliseconds)
);
Expand Down Expand Up @@ -68,14 +68,14 @@ private static void Run(Options options)
// 数据检测
if (book.Tables.Count < 1)
{
throw new Exception("Excel文件中没有找到Sheet: " + excelPath);
throw new Exception("Excel file is empty: " + excelPath);
}

// 取得数据
DataTable sheet = book.Tables[0];
if (sheet.Rows.Count <= 0)
{
throw new Exception("Excel Sheet中没有数据: " + excelPath);
throw new Exception("Excel Sheet is empty: " + excelPath);
}

//-- 确定编码
Expand Down

0 comments on commit 86dba48

Please sign in to comment.