Export to Word / Excel / PDF / CSV / HTML
I have made a NuGet package that exports a List to Word(2003/2007) / Excel(2003/2007) / PDF / CSV / HTML.
It is made with Razor Templating – interpreted by WestWind Razor Engine ( source code at https://github.com/RickStrahl/Westwind.RazorHosting )
What it does it generates templates in Razor ( that can be freely modified after) and it generates the specific output.
The whole code is that simple
List<Electronics> list = Electronics.GetData(); List<Electronics> list = Electronics.GetData(); ExportList<Electronics> exp = new ExportList<Electronics>(); exp.PathTemplateFolder = Path.Combine(Environment.CurrentDirectory, "templates/electronics"); //export exp.ExportTo(list, ExportToFormat.HTML, "a.html"); exp.ExportTo(list, ExportToFormat.CSV, "a.csv"); exp.ExportTo(list, ExportToFormat.XML, "a.xml"); exp.ExportTo(list, ExportToFormat.Word2003XML, "a_2003.doc"); exp.ExportTo(list, ExportToFormat.Excel2003XML, "a_2003.xls"); exp.ExportTo(list, ExportToFormat.Excel2007, "a.xlsx"); exp.ExportTo(list, ExportToFormat.Word2007, "a.docx"); exp.ExportTo(list, ExportToFormat.itextSharpXML, "a.xml"); exp.ExportTo(list, ExportToFormat.PDFtextSharpXML, "a.pdf");
GitHub Console Demo at https://github.com/ignatandrei/Export_Word_Excel_PDF_CSV_HTML
The Nuget package is at http://www.nuget.org/packages/Exporter/
YouTube demo at http://youtu.be/2CBdn6ru47M
I just “Nuget installed” the Exporter tool (Feb 20, 2014) into my website application (MVC w/.NET 4), but there seems to be a little trouble.
My website’s “Target framework” is .Net 4, but the ExporterObjects tool seems to have been built on .Net 4.5. The description in the Nuget Package Installer states that the tool is dependent on .Net 4, but once I install it, implement the few lines of code (as you have demonstrated), my Visual Studio 12 compile stops with the following error message;
Warning 2 The primary reference “ExporterObjects” could not be resolved because it was built against the “.NETFramework,Version=v4.5” framework. This is a higher version than the currently targeted framework “.NETFramework,Version=v4.0”. Moneta.Global
Do you have a build that is tied back to .Net 4, instead of the current build?