Skip to content

Commit

Permalink
1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcin kotynia committed Jul 18, 2017
1 parent 9c6709e commit e899425
Show file tree
Hide file tree
Showing 10 changed files with 93 additions and 1,224 deletions.
118 changes: 64 additions & 54 deletions ExcelToHtml.console/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ static void Main(string[] args)
#if DEBUG //TEST DATA
var testdata = new List<string>{
@"-t=c:\git\ExcelToHtml\Test\test1.xlsx",
@"-data=https://transit.land//api/v1/changesets/1/change_payloads",
@"-output=pdf"
@"-data=http://nflarrest.com/api/v1/crime"
// @"-data=https://transit.land//api/v1/changesets/1/change_payloads",
// @"-output=pdf"
};
args = testdata.ToArray();
#endif
Expand All @@ -24,7 +25,7 @@ static void Main(string[] args)
string ExcelPath;
string DataUrl;
string Output = "html";

string OutputPath;

if (args.Length == 1)
ExcelPath = args[0];
Expand All @@ -44,77 +45,86 @@ static void Main(string[] args)
{
#endif

Console.WriteLine(" Processing {0}", ExcelPath);
Console.WriteLine(" Processing {0}", ExcelPath);

//Read Excel File
FileInfo ExcelFile = new FileInfo(ExcelPath);
//Read Excel File
FileInfo ExcelFile = new FileInfo(ExcelPath);


var WorksheetHtml = new ExcelToHtml.ToHtml(ExcelFile);
var WorksheetHtml = new ExcelToHtml.ToHtml(ExcelFile);

WorksheetHtml.DebugMode = true;
WorksheetHtml.DebugMode = true;

//Read Data Simple JSON cell,value
FileInfo DataFile = new FileInfo(DataPath);
if (!DataFile.Exists)
{
Console.WriteLine(" Loading optional configuration {0} - Not found.", DataFile);
}
else
{
string Data = File.ReadAllText(DataPath);
//Read Data Simple JSON cell,value
FileInfo DataFile = new FileInfo(DataPath);
if (!DataFile.Exists)
{
Console.WriteLine(" Loading optional configuration {0} - Not found.", DataFile);
}
else
{
string Data = File.ReadAllText(DataPath);

//Read Data From Yaml
var DeSerializer = new YamlDotNet.Serialization.Deserializer();
Dictionary<string, string> Cells = DeSerializer.Deserialize<Dictionary<string, string>>(Data);
//Read Data From Yaml
var DeSerializer = new YamlDotNet.Serialization.Deserializer();
Dictionary<string, string> Cells = DeSerializer.Deserialize<Dictionary<string, string>>(Data);

//Get Set Cells and write to Yaml
var output = WorksheetHtml.DataGetSet(Cells);
var Serializer = new YamlDotNet.Serialization.Serializer();
string Yaml = Serializer.Serialize(output);
File.WriteAllText(DataPath, Yaml);
}
//Get Set Cells and write to Yaml
var output = WorksheetHtml.DataGetSet(Cells);
var Serializer = new YamlDotNet.Serialization.Serializer();
string Yaml = Serializer.Serialize(output);
File.WriteAllText(DataPath, Yaml);
}

ExcelToHtml.console.Company test = new ExcelToHtml.console.Company();
ExcelToHtml.console.Company test = new ExcelToHtml.console.Company();


if (arguments.TryGetValue("-data", out DataUrl))
WorksheetHtml.DataFromUrl(DataUrl);
if (arguments.TryGetValue("-data", out DataUrl))
WorksheetHtml.DataFromUrl(DataUrl);

if (!arguments.TryGetValue("-outputpath", out OutputPath))
OutputPath = ExcelPath;

arguments.TryGetValue("-output", out Output);
arguments.TryGetValue("-output", out Output);
if (Output == null)
Output = "html";

if (Output.ToLower() == "html")
{
string html = WorksheetHtml.GetHtml();
File.WriteAllText(ExcelPath + "." + Output, html);
if (Output.ToLower() == "html")
{
string html = WorksheetHtml.GetHtml();
File.WriteAllText(OutputPath + "." + Output, html);

}
else if (Output.ToLower() == "htmlw3css")
{
string html = WorksheetHtml.GetHtml();
File.WriteAllText(ExcelPath + "." + Output, String.Format(ExcelToHtml.Helpers.Strings.w3cssHTML, html));
}
else if (Output.ToLower() == "htmlw3css")
{
string html = WorksheetHtml.GetHtml();
File.WriteAllText(OutputPath + ".html", String.Format(ExcelToHtml.Helpers.Strings.w3cssHTML, html));

}
else if (Output.ToLower() == "pdf")
{
string html = String.Format(ExcelToHtml.Helpers.Strings.w3cssHTML, WorksheetHtml.GetHtml());
PdfConvert.ConvertHtmlToPdf(new PdfDocument
}
else if (Output.ToLower() == "pdf")
{
Html = html
string html = String.Format(ExcelToHtml.Helpers.Strings.w3cssHTML, WorksheetHtml.GetHtml());
PdfConvert.ConvertHtmlToPdf(new PdfDocument
{
Html = html

}, new PdfOutput
{
OutputFilePath = OutputPath + "." + Output
});

}, new PdfOutput
}
else if (Output.ToLower() == "xlsx")
{
OutputFilePath = ExcelPath + "." + Output
});
File.WriteAllBytes(OutputPath + "." + Output, WorksheetHtml.GetBytes());
}
else
{
throw new Exception("-output expected pdf,xlsx,html,htmlw3css");

}
else if (Output.ToLower() == "xlsx")
{
File.WriteAllBytes(ExcelPath + "." + Output, WorksheetHtml.GetBytes());
}
}

Console.WriteLine(" File Saved {0}", ExcelPath + "." + Output);
Console.WriteLine(" File Saved {0}", OutputPath + "." + Output);


#if DEBUG //DEBUG MODE
Expand Down
4 changes: 2 additions & 2 deletions ExcelToHtml.console/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.3.0.0")]
[assembly: AssemblyFileVersion("1.3.0.0")]
[assembly: AssemblyVersion("1.4.0.0")]
[assembly: AssemblyFileVersion("1.4.0.0")]
4 changes: 2 additions & 2 deletions ExcelToHtml/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.3.0.0")]
[assembly: AssemblyFileVersion("1.3.0.0")]
[assembly: AssemblyVersion("1.4.0.0")]
[assembly: AssemblyFileVersion("1.4.0.0")]
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ exceltohtml.console.exe Test1.xlsx
exceltohtml.console.exe -t=Test1.xlsx -output=xlsx
@Echo Output Test1.xlsx.xlsx
@Echo Get html PAGE with https://www.w3schools.com/w3css/default.asp stylesheet
exceltohtml.console.exe -t=Test1.xlsx -output=htmlw3css
@Echo Output Test1.xlsx.html
@Echo Get PDF !! Warning require https://wkhtmltopdf.org/downloads.html
exceltohtml.console.exe -t=Test1.xlsx -output=pdf
@Echo Output Test1.xlsx.pdf
Expand Down Expand Up @@ -149,21 +153,21 @@ To use this data you can put following template fields
- *[[d[0][!].arrest_count]]* will render to list of elements from arrest_count
- *[[d[0][0].arrest_count]]* will render to element value 187

# Versions
# Evolution

Excel ScreenShot
![Image](Test/Test1%20ExcelToHtml.png?raw=true)

Result version 1.0.0
Version 1.0.0 result
![1.0.0](Test/Test1%20ExcelToHtml1.0.0.png?raw=true)

Result version 1.1.0
Version 1.1.0 result
![1.1.0](/Test/Test1%20ExcelToHtml1.1.0.png?raw=true)

Result version 1.2.0
Version 1.2.0 result
![1.2.0](/Test/Test1%20ExcelToHtml1.2.0.png?raw=true)

Result version 1.3.0
Version 1.3.0 result
![1.3.0](/Test/Test1%20ExcelToHtml1.3.0.png?raw=true)

# Technical Appendix
Expand Down
Binary file added Test/ExcelToHtml.console.exe
Binary file not shown.
File renamed without changes
Binary file added Test/Test1 ExcelToHtml1.3.0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit e899425

Please sign in to comment.