![]() Return "Employer code is Empty in the attached Excel Sheet" įor (int i = 0 i x.EmployerCode = Convert.ToString(dt.Rows)).FirstOrDefault() If (result != null & > 0)ĭt.Columns.ColumnName = "EmployerCode" ĭt.Columns.ColumnName = "Employer Last Name" ĭt.Columns.ColumnName = "Employer First Name" ĭt.Columns.ColumnName = "Employer DOB" ĭt.Columns.ColumnName = "Certificate Name" ĭt.Columns.ColumnName = "Certificate Number" ĭt.Columns.ColumnName = "Recognizing Countries" ĭataRow drrr = dt.Select(" IS NULL") If (Inputfile != null & FileStream != null)ĮxcelReader = ExcelReaderFactory.CreateReader(FileStream) ĭataSet result = excelReader.AsDataSet() If (!Directory.Exists(Path.Combine(Environment.GetFolderPath(), "logs")))ĭirectory.CreateDirectory(Path.Combine(Environment.GetFolderPath(), "logs")) Įncoding.RegisterProvider(CodePagesEncodingProvider.Instance) String logfileName = logpathDestination = Path.Combine(Environment.GetFolderPath(), logfileName) public string XLToJson(HttpContext context, string pathDestination) From the Excel reader, we can convert it to Dataset and we can manipulate it as how we want. In the core Converter logic class, read the excel file from http request as file streams and pass it to excelreader factory to create an instance of Excel reader. So I created a separate class for these models public class Employee In our example, I want to display employee and its certificates and its recognizing countries. ![]() Will create a separate class for writing the core converter logic.ĭefine the model class, like how we want to display in our json. Return StatusCodeResult(HttpStatusCode.InternalServerError) Return Ok(excelConverter.XLToJson(HttpContext, pathDestination)) Public IActionResult ConvertToJsonAsResult()ĮxcelConverter excelConverter = new ExcelConverter() Will receive the excel data from the httpcontext request through file option. It is the library written in C# for reading data from Excel files.Īdd an Endpoint in the Controller File, which then calls our Conversion logic.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |