adminwera.blogg.se

Xls to json
Xls to json













xls to json

LogWriter.WriteToLogFile(logpathDestination, ex) Using (StreamWriter writer = new StreamWriter(pathDestination))

xls to json xls to json

Json = JsonConvert.SerializeObject(employees) If (item = null & !string.IsNullOrEmpty(Convert.ToString( dt.Rows)))ĮmployerCode = Convert.ToString(dt.Rows)ĮmployerLastName = Convert.ToString(dt.Rows)ĮmployerFirstName = Convert.ToString(dt.Rows)ĮmployerDOB = Convert.ToDateTime(dt.Rows).ToString("dd-MM-yyyy")Ĭertificates = GetCertificates(dt, Convert.ToString(dt.Rows)) 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.

xls to json

  • Install ExcelDataReader through nuget package.
  • net core web API project with the framework of. I need to convert it to JSON through API. I have an Excel sheet consisting of Employee details.















    Xls to json