public void TestWithPersonData() { var p = new Person { Name = "Andrei Ignat", WebSite = "http://msprogrammer.serviciipeweb.ro/", CV = "http://serviciipeweb.ro/iafblog/content/binary/cv.doc" }; var export = new ExportODS <Person>(); var data = export.ExportResultStringPart(new List <Person>() { p }); var str = data; Assert.IsTrue(str.Contains("http://serviciipeweb.ro/iafblog/content/binary/cv.doc"), "must contain the cv"); }
public void TestWithPersonHeader() { var p = new Person { Name = "andrei", WebSite = "http://msprogrammer.serviciipeweb.ro/" }; var export = new ExportODS <Person>(); var data = export.ExportResultStringPart(new List <Person>() { p }); var str = data; Assert.IsTrue(str.Contains(export.ExportHeader), "must contain the header"); }
//[TestMethod] public void TestODS() { var p = new Person { Name = "Andrei Ignat", WebSite = "http://msprogrammer.serviciipeweb.ro/", CV = "http://serviciipeweb.ro/iafblog/content/binary/cv.doc" }; var export = new ExportODS <Person>(); var data = export.ExportResult(new List <Person>() { p }); //var str = Encoding.Unicode.GetString(data); File.WriteAllBytes("ods.ods", data); Process.Start("ods.ods"); }
public void TestConstructorItemWithPerson() { var t = new Person { Name = "andrei", WebSite = "http://msprogrammer.serviciipeweb.ro/" }; var export = new ExportODS <Person>(); Assert.AreEqual(@"<table:table-row> <table:table-cell table:style-name='Standard' office:value-type='string'> <text:p>@System.Security.SecurityElement.Escape((((object)Model.Name) ?? """").ToString())</text:p> </table:table-cell> <table:table-cell table:style-name='Standard' office:value-type='string'> <text:p>@System.Security.SecurityElement.Escape((((object)Model.WebSite) ?? """").ToString())</text:p> </table:table-cell> <table:table-cell table:style-name='Standard' office:value-type='string'> <text:p>@System.Security.SecurityElement.Escape((((object)Model.CV) ?? """").ToString())</text:p> </table:table-cell> </table:table-row>".Replace("\r", "").Replace("\n", ""), export.ExportItem.Replace("\r", "").Replace("\n", "")); }
public void TestConstructorHeaderWithPerson() { var t = new Person { Name = "andrei", WebSite = "http://msprogrammer.serviciipeweb.ro/" }; var export = new ExportODS <Person>(); Assert.AreEqual(@"<table:table-column table:style-name='Standard' table:number-columns-repeated='3'/> <table:table-row> <table:table-cell table:style-name='Standard' office:value-type='string'> <text:p>Name</text:p> </table:table-cell> <table:table-cell table:style-name='Standard' office:value-type='string'> <text:p>WebSite</text:p> </table:table-cell> <table:table-cell table:style-name='Standard' office:value-type='string'> <text:p>CV</text:p> </table:table-cell> </table:table-row>".Replace("\r", "").Replace("\n", ""), export.ExportHeader.Replace("\r", "").Replace("\n", "")); }
static void SeeAllExport() { var p = new Person { Name = "andrei", WebSite = "http://msprogrammer.serviciipeweb.ro/", CV = "http://serviciipeweb.ro/iafblog/content/binary/cv.doc" }; var p1 = new Person { Name = "you", WebSite = "http://yourwebsite.com/" }; var list = new List <Person>() { p, p1 }; Export <Person> export = new ExportHtml <Person>(); var data = export.ExportResult(list); if (!writeAndStartFile("a.html", data)) { Console.WriteLine(" !!!!!!!!!!Could not delete a.html"); } export = new ExportExcel2003 <Person>(); data = export.ExportResult(list); if (!writeAndStartFile("a.xls", data)) { Console.WriteLine(" !!!!!!!!!!Could not delete a.xls"); } export = new ExportODS <Person>(); data = export.ExportResult(list); if (!writeAndStartFile("a.ods", data)) { Console.WriteLine(" !!!!!!!!!!Could not delete a.ods"); } export = new ExportExcel2007 <Person>(); data = export.ExportResult(list); if (!writeAndStartFile("a.xlsx", data)) { Console.WriteLine(" !!!!!!!!!!Could not delete a.xlsx"); } export = new ExportWord2003 <Person>(); data = export.ExportResult(list); if (!writeAndStartFile("a.doc", data)) { Console.WriteLine(" !!!!!!!!!!Could not delete a.doc"); } export = new ExportWord2007 <Person>(); data = export.ExportResult(list); if (!writeAndStartFile("a.docx", data)) { Console.WriteLine(" !!!!!!!!!!Could not delete a.docx"); } export = new ExportPdfiTextSharp4 <Person>(); data = export.ExportResult(list); if (!writeAndStartFile("a.pdf", data)) { Console.WriteLine(" !!!!!!!!!!Could not delete a.pdf"); } export = new ExportODT <Person>(); data = export.ExportResult(list); if (!writeAndStartFile("a.odt", data)) { Console.WriteLine(" !!!!!!!!!!Could not delete a.odt"); } //or you can use the factory data = ExportFactory.ExportData(list, ExportToFormat.Excel2007); if (!writeAndStartFile("b.xlsx", data)) { Console.WriteLine(" !!!!!!!!!!Could not delete b.xlsx"); } //export from JSON string dataJson = @"[ { 'Name':'Andrei Ignat', 'WebSite':'http://msprogrammer.serviciipeweb.ro/', 'CV':'http://serviciipeweb.ro/iafblog/content/binary/cv.doc' }, { 'Name':'Andrei Ignat', 'WebSite':'http://msprogrammer.serviciipeweb.ro/', 'CV':'http://serviciipeweb.ro/iafblog/content/binary/cv.doc' } ]"; data = ExportFactory.ExportDataJson(dataJson, ExportToFormat.Excel2007); if (!writeAndStartFile("bJson.xlsx", data)) { Console.WriteLine(" !!!!!!!!!!Could not delete bJson.xlsx"); } //or from CSV var dataCSV = new List <string>(); dataCSV.Add("Name,WebSite,CV"); dataCSV.Add("Andrei Ignat,http://msprogrammer.serviciipeweb.ro/,http://serviciipeweb.ro/iafblog/content/binary/cv.doc"); dataCSV.Add("Andrei Ignat,http://msprogrammer.serviciipeweb.ro/,http://serviciipeweb.ro/iafblog/content/binary/cv.doc"); data = ExportFactory.ExportDataCsv(dataCSV.ToArray(), ExportToFormat.Excel2007); if (!writeAndStartFile("bCSV.xlsx", data)) { Console.WriteLine(" !!!!!!!!!!Could not delete bCSV.xlsx"); } 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 "); data = ExportFactory.ExportDataFromDataTable(dta, ExportToFormat.Excel2007); if (!writeAndStartFile("dta.xlsx", data)) { Console.WriteLine(" !!!!!!!!!!Could not delete a.xlsx"); } }