public void TestConstructorItemWithPerson() { var t = new Person { Name = "andrei", WebSite = "http://msprogrammer.serviciipeweb.ro/" }; var export = new ExportWord2007 <Person>(); Assert.AreEqual(@"<w:tr> <w:tc> <w:p> <w:r> <w:t>@Model.Name</w:t> </w:r> </w:p> </w:tc> <w:tc> <w:p> <w:r> <w:t>@Model.WebSite</w:t> </w:r> </w:p> </w:tc> <w:tc> <w:p> <w:r> <w:t>@Model.CV</w:t> </w:r> </w:p> </w:tc> </w:tr>", export.ExportItem); }
public void TestConstructorItemWithPerson() { var t = new Person {Name = "andrei", WebSite = "http://msprogrammer.serviciipeweb.ro/"}; var export = new ExportWord2007<Person>(); Assert.AreEqual(@"<w:tr> <w:tc> <w:p> <w:r> <w:t>@Model.Name</w:t> </w:r> </w:p> </w:tc> <w:tc> <w:p> <w:r> <w:t>@Model.WebSite</w:t> </w:r> </w:p> </w:tc> <w:tc> <w:p> <w:r> <w:t>@Model.CV</w:t> </w:r> </w:p> </w:tc> </w:tr>", export.ExportItem); }
public void TestConstructorItemWithPerson() { var t = new Person {Name = "andrei", WebSite = "http://msprogrammer.serviciipeweb.ro/"}; var export = new ExportWord2007<Person>(); Assert.AreEqual(@"<w:tr> <w:tc> <w:p> <w:r> <w:t>@System.Security.SecurityElement.Escape((((object)Model.Name) ?? """").ToString())</w:t> </w:r> </w:p> </w:tc> <w:tc> <w:p> <w:r> <w:t>@System.Security.SecurityElement.Escape((((object)Model.WebSite) ?? """").ToString())</w:t> </w:r> </w:p> </w:tc> <w:tc> <w:p> <w:r> <w:t>@System.Security.SecurityElement.Escape((((object)Model.CV) ?? """").ToString())</w:t> </w:r> </w:p> </w:tc> </w:tr>".Replace("\r", "").Replace("\n", ""), export.ExportItem.Replace("\r", "").Replace("\n", "")); }
public void TestWithPersonHeader() { var p = new Person {Name = "andrei", WebSite = "http://msprogrammer.serviciipeweb.ro/"}; var export = new ExportWord2007<Person>(); var data = export.ExportResultStringPart(new List<Person>() {p}); var str = data; Assert.IsTrue(str.Contains(export.ExportHeader),"must contain the header"); }
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 ExportWord2007<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"); }
//[TestMethod] public void TestWord2007() { var p = new Person { Name = "Andrei Ignat", WebSite = "http://msprogrammer.serviciipeweb.ro/", CV = "http://serviciipeweb.ro/iafblog/content/binary/cv.doc" }; var export = new ExportWord2007<Person>(); var data = export.ExportResult(new List<Person>() { p }); //var str = Encoding.Unicode.GetString(data); File.WriteAllBytes("a.docx",data); Process.Start("a.docx"); }
//[TestMethod] public void TestWord2007() { var p = new Person { Name = "Andrei Ignat", WebSite = "http://msprogrammer.serviciipeweb.ro/", CV = "http://serviciipeweb.ro/iafblog/content/binary/cv.doc" }; var export = new ExportWord2007 <Person>(); var data = export.ExportResult(new List <Person>() { p }); File.WriteAllBytes("a.docx", data); Process.Start("a.docx"); }
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 ExportWord2007 <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 ExportWord2007 <Person>(); var data = export.ExportResultStringPart(new List <Person>() { p }); var str = data; Assert.IsTrue(str.Contains(export.ExportHeader), "must contain the header"); }
static void Main(string[] args) { var p = new Person { Name = "andrei", WebSite = "http://msprogrammer.serviciipeweb.ro/", CV = "http://serviciipeweb.ro/iafblog/content/binary/cv.doc" }; Export <Person> export = new ExportHtml <Person>(); var data = export.ExportResult(new List <Person>() { p }); File.WriteAllBytes("a.html", data); Process.Start("a.html"); export = new ExportExcel2007 <Person>(); data = export.ExportResult(new List <Person>() { p }); File.WriteAllBytes("a.xlsx", data); Process.Start("a.xlsx"); export = new ExportWord2007 <Person>(); data = export.ExportResult(new List <Person>() { p }); File.WriteAllBytes("a.docx", data); Process.Start("a.docx"); export = new ExportPdfiTextSharp4 <Person>(); data = export.ExportResult(new List <Person>() { p }); File.WriteAllBytes("a.pdf", data); Process.Start("a.pdf"); //or you can use the factory data = ExportFactory.ExportData(new List <Person>() { p }, ExportToFormat.Excel2007); File.WriteAllBytes("b.xlsx", data); Process.Start("b.xlsx"); }
public void TestConstructorHeaderWithPerson() { var t = new Person { Name = "andrei", WebSite = "http://msprogrammer.serviciipeweb.ro/" }; var export = new ExportWord2007 <Person>(); Assert.AreEqual(@"<w:tr> <w:tc> <w:p> <w:r> <w:rPr> <w:b w:val='on'/> <w:t> Name </w:t> </w:rPr> </w:r> </w:p> </w:tc> <w:tc> <w:p> <w:r> <w:rPr> <w:b w:val='on'/> <w:t> WebSite </w:t> </w:rPr> </w:r> </w:p> </w:tc> <w:tc> <w:p> <w:r> <w:rPr> <w:b w:val='on'/> <w:t> CV </w:t> </w:rPr> </w:r> </w:p> </w:tc> </w:tr>", export.ExportHeader); }
public void TestConstructorHeaderWithPerson() { var t = new Person {Name = "andrei", WebSite = "http://msprogrammer.serviciipeweb.ro/"}; var export = new ExportWord2007<Person>(); Assert.AreEqual(@"<w:tr> <w:tc> <w:p> <w:r> <w:rPr> <w:b w:val='on'/> <w:t> Name </w:t> </w:rPr> </w:r> </w:p> </w:tc> <w:tc> <w:p> <w:r> <w:rPr> <w:b w:val='on'/> <w:t> WebSite </w:t> </w:rPr> </w:r> </w:p> </w:tc> <w:tc> <w:p> <w:r> <w:rPr> <w:b w:val='on'/> <w:t> CV </w:t> </w:rPr> </w:r> </w:p> </w:tc> </w:tr>", export.ExportHeader); }
static void Main(string[] args) { var p = new Person { Name = "andrei", WebSite = "http://msprogrammer.serviciipeweb.ro/" , CV = "http://serviciipeweb.ro/iafblog/content/binary/cv.doc" }; Export<Person> export = new ExportHtml<Person>(); var data = export.ExportResult(new List<Person>() { p }); File.WriteAllBytes("a.html",data); Process.Start("a.html"); export = new ExportExcel2007<Person>(); data = export.ExportResult(new List<Person>() { p }); File.WriteAllBytes("a.xlsx", data); Process.Start("a.xlsx"); export = new ExportWord2007<Person>(); data = export.ExportResult(new List<Person>() { p }); File.WriteAllBytes("a.docx", data); Process.Start("a.docx"); export = new ExportPdfiTextSharp4<Person>(); data = export.ExportResult(new List<Person>() { p }); File.WriteAllBytes("a.pdf", data); Process.Start("a.pdf"); //or you can use the factory data = ExportFactory.ExportData(new List<Person>() { p }, ExportToFormat.Excel2007); File.WriteAllBytes("b.xlsx", data); Process.Start("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); File.WriteAllBytes("bJson.xlsx", data); Process.Start("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); File.WriteAllBytes("bCSV.xlsx", data); Process.Start("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); File.WriteAllBytes("dta.xlsx",data); Process.Start("a.xlsx"); //advanced - modifying templates - in this case , added Number export = new ExportExcel2007<Person>(); //File.WriteAllText("Excel2007Header.txt",export.ExportHeader); //File.WriteAllText("Excel2007Item.txt", export.ExportItem); //File.WriteAllText("Excel2007Collection.txt", export.ExportCollection); export.ExportHeader = File.ReadAllText("Excel2007Header.txt"); export.ExportItem = File.ReadAllText("Excel2007Item.txt"); export.ExportCollection = File.ReadAllText("Excel2007Collection.txt"); data = export.ExportResult(new List<Person>() { p }); File.WriteAllBytes("WithId.xlsx", data); Process.Start("WithId.xlsx"); }
static void Main(string[] args) { var p = new Person { Name = "andrei", WebSite = "http://msprogrammer.serviciipeweb.ro/" , CV = "http://serviciipeweb.ro/iafblog/content/binary/cv.doc" }; Export<Person> export = new ExportHtml<Person>(); var data = export.ExportResult(new List<Person>() { p }); File.WriteAllBytes("a.html",data); Process.Start("a.html"); export=new ExportExcel2007<Person>(); data = export.ExportResult(new List<Person>() { p }); File.WriteAllBytes("a.xlsx", data); Process.Start("a.xlsx"); export = new ExportWord2007<Person>(); data = export.ExportResult(new List<Person>() { p }); File.WriteAllBytes("a.docx", data); Process.Start("a.docx"); export = new ExportPdfiTextSharp4<Person>(); data = export.ExportResult(new List<Person>() { p }); File.WriteAllBytes("a.pdf", data); Process.Start("a.pdf"); //or you can use the factory data = ExportFactory.ExportData(new List<Person>() {p}, ExportToFormat.Excel2007); File.WriteAllBytes("b.xlsx", data); Process.Start("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); File.WriteAllBytes("bJson.xlsx", data); Process.Start("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); File.WriteAllBytes("bCSV.xlsx", data); Process.Start("bCSV.xlsx"); }
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"); } }