-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
81 lines (61 loc) · 2.68 KB
/
Program.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
70
71
72
73
74
75
76
77
78
79
80
81
using System;
using Newtonsoft.Json;
using System.IO;
using exceltools.helpers;
namespace exceltools
{
class Program
{
static void Main(string[] args)
{
//runTest();
if (args.Length < 3)
{
Console.WriteLine("Arguments not found!");
Console.WriteLine("0 - required - action (excel2csv / csv2excel)");
Console.WriteLine("1 - required - FileIn");
Console.WriteLine("2 - required - FileOut");
Console.WriteLine("3 - optional - JSON config");
Environment.Exit(1);
}
string inFile = args[1];
string outFile = args[2];
ExcelTools obj = new ExcelTools();
switch (args[0])
{
case "excel2csv":
converterToExcelSettings[] settingsExcel = null;
if (args.Length > 3)
{
settingsExcel = JsonConvert.DeserializeObject<converterToExcelSettings[]>(args[3]);
}
obj.csv2excel(inFile, outFile, settingsExcel);
break;
case "csv2excel":
converterToCsvSettings settingsCsv = null;
if (args.Length > 3)
{
settingsCsv = JsonConvert.DeserializeObject<converterToCsvSettings>(args[3]);
}
obj.excel2csv(inFile, outFile, settingsCsv);
break;
}
Console.WriteLine(File.Exists(outFile) ? "ok" : "error");
}
static void runTest()
{
ExcelTools objx = new ExcelTools();
string _inFile = "/Users/robsonaugustolazzarinalviani/projects/files/out/112_salesout-week_kobo_20180507093048_569695af00eb813a6e.xlsx";
string _outFile = "/Users/robsonaugustolazzarinalviani/projects/files/out/112_salesout-week_kobo_20180507093048_569695af00eb813a6e.xlsx.csv";
converterToCsvSettings testSettings = new converterToCsvSettings();
testSettings.Sheets = new string[] { "Sheet1" };
testSettings.SkipHidden = true;
objx.excel2csv(_inFile, _outFile, testSettings);
//string _inFile = "/Users/robsonaugustolazzarinalviani/projects/files/in/112_salesout-week_kobo_20180507093048_569695af00eb813a6e.csv";
//string _outFile = "/Users/robsonaugustolazzarinalviani/projects/files/out/112_salesout-week_kobo_20180507093048_569695af00eb813a6e.xlsx";
//objx.csv2excel(_inFile, _outFile);
Console.WriteLine(File.Exists(_outFile) ? "ok" : "error");
Environment.Exit(1);
}
}
}