private async void button1_Click(object sender, System.EventArgs e) { var dataSet = XlsImport.ReadExcel("./app_data/schedule.xls"); var collection = XlsImport.ReadFromDataset(dataSet, "расписание"); collection.ForEach(x => { Assert(() => !string.IsNullOrWhiteSpace(x.TimeBegin)); Assert(() => !string.IsNullOrWhiteSpace(x.TimeEnd)); }); using (var writer = new StreamWriter("./App_Data/output.json")) { await writer.WriteLineAsync(JsonConvert.SerializeObject(collection, Formatting.Indented)); } button1.Text = @"Done"; }
private DataTable GetData() { DataTable oTable = new DataTable(); if (!string.IsNullOrEmpty(txtUploadedFileName.Text)) { string filePath = Path.Combine(mstrDirectory, txtUploadedFileName.Text); string[] sheetNames = XlsImport.GetExcelSheetNames(filePath); if (sheetNames != null && sheetNames.Length > 0) { // Get data in the first sheet oTable = XlsImport.BindData(filePath, sheetNames[0]); } } return(oTable); }