Export DataSet

Andrei Ignat edited this page Feb 4, 2016 · 3 revisions

Video demo at https://youtu.be/mvlDjF1TeVc


var ds=new DataSet();
                var table = new DataTable("programmers");
                var idColumn = table.Columns.Add("ID", typeof(int));
                table.Columns.Add("Name", typeof(string));
                table.Columns.Add("WebSite", typeof(string));

                table.PrimaryKey = new DataColumn[] { idColumn };

                table.Rows.Add(new object[] { 1, "Andrei Ignat", "http://msprogrammer.serviciipeweb.ro" });
                table.Rows.Add(new object[] { 2, "Scott Hanselman", "http://www.hanselman.com/blog/" });


                var dta = new DataTable("andrei");
                dta.Columns.Add(new DataColumn("ID", typeof(int)));
                dta.Columns.Add(new DataColumn("Data", typeof(string)));
                dta.Rows.Add(1, "test 1 ");
                dta.Rows.Add(2, "test 2 ");
                dta.Rows.Add(3, "test 3 ");

                var export = new ExportExcel2007<Person>();
                var data=ExportFactory.ExportDataSet(ds, ExportToFormat.Excel2007);

                File.WriteAllBytes("multipleDataSet.xlsx", data);
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.