public static void RunSample() { Console.WriteLine(InvoiceQueryHeader); Console.WriteLine(new string('-', 52)); using (var cnn = new Connection { ConnectionString = Properties.Settings.Default.ChinookDatabaseConnectionString }) { Console.WriteLine(OneStepText); var query = new InvoiceQuery(cnn) { Text = Invoice.InvoiceQuery }; var resultDataSet = query.Execute("Invoice"); var enumerable = from DataRow row in resultDataSet.Tables[0].Rows select new Invoice { Id = (int)row["ID"], Date = (DateTime)row["DATE"], CustomerFirstName = row["CUSTOMERFIRSTNAME"].ToString(), CustomerLastName = row["CUSTOMERLASTNAME"].ToString(), CustomerPhone = row["CUSTOMERPHONE"].ToString(), CustomerEmail = row["CUSTOMEREMAIL"].ToString(), BillingAddress = row["BILLINGADDRESS"].ToString(), BillingCity = row["BILLINGCITY"].ToString(), BillingState = row["BILLINGSTATE"].ToString(), BillingCountry = row["BILLINGCOUNTRY"].ToString(), BillingPostalCode = row["BILLINGPOSTALCODE"].ToString(), Total = (decimal)row["TOTAL"] }; var export = new EnumerableInput <Invoice>(enumerable, "Invoice"); Console.Write(TwoStepText); Console.WriteLine(); Console.WriteLine(ThreeStepText); Console.WriteLine(FourStepText); var model = CreateModel(); export.Export(ExportSettings.CreateFromModels(model, "enumerable-xlsx")); Console.WriteLine(FiveStepText); var configuration = new Uri(Properties.Settings.Default.InvoiceExportConfigurationFile, UriKind.Relative); export.Export(ExportSettings.ImportFrom(configuration, "enumerable-xlsx")); } }
/// <summary> /// Runs the sample. /// </summary> public static void RunFromCodeSample(int rows) { Console.WriteLine(Header); Console.WriteLine(FirstSampleStepText); var input = new EnumerableInput <CustomDataModel>(BuildCustomData(rows), "Sample7"); var configuration = new Uri(Settings.Default.EPPlusSample07Configuration, UriKind.Relative); input.Export(ExportSettings.ImportFrom(configuration)); }