/// <summary> /// Example using a wrapper library over OpenXml to read a specific worksheet /// where the data will match up to a concrete class, in this case Customer. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void cmdReadUsingWrapperLibOverOpenXml_Click(object sender, EventArgs e) { var helper = new OpenXmlExamples(); var fileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Customers.xlsx"); var customers = helper.ClassToExcelReaderServiceReader(fileName); var f = new frmCustomers(customers); try { f.ShowDialog(); } finally { f.Dispose(); } }
/// <summary> /// Read in a work sheet using OleDb data provider. One must be careful when /// there is mixed data in a column. This demo does not have mixed data so /// there will be no issues unlike working with mixed data there is no one /// solution. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void cmdReadCustomersOleDb_Click(object sender, EventArgs e) { var helper = new OledbCode.Operations(); var fileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Customers.xlsx"); var customers = helper.ReadCustomers(fileName); //var test = helper.ReaDataTable(fileName); var f = new frmCustomers(customers); try { f.ShowDialog(); } finally { f.Dispose(); } }