Created
August 25, 2018 07:00
-
-
Save eternalharvest/63ba25b5def2ad05b5eb9425552c3327 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// Compose Data | |
Dictionary<string, object> data = new Dictionary<string, object>(); | |
data["NAME"] = "Takuya Sawada"; | |
data["GENDER"] = "Male"; | |
data["BIRTH"] = new DateTime(1989, 3, 3).Date; | |
data["TODAY"] = DateTime.Today.Date; | |
data["LEVEL"] = 99; | |
// Render template | |
XLWorkbook workbook = new XLWorkbook(@"C:\Users\takuya\Desktop\template.xlsx"); | |
IXLWorksheet sheet = workbook.Worksheet("Sheet1"); | |
foreach (IXLNamedRange nr in workbook.NamedRanges) | |
{ | |
if (data.ContainsKey(nr.Name)) | |
{ | |
workbook.Cell(nr.Name).Value = data[nr.Name]; | |
} | |
} | |
// Save | |
workbook.SaveAs(@"C:\Users\takuya\Desktop\takuya.xlsx"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment