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
Hello!
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?
Sent by email
Hi Andrei,
Can you also send the build for .net 4 to me, same problem as @Bill Elliott. Can not compile from source.
Thanks
Check your email
Hi Ignat,
Is ExportDataTable only available in version 2?
Thanks,
Sandeep Sharma
Hi Andrei,
Can you also send the build for .net 4 also to me, same problem as @Bill Elliott. Can not compile from source.
Thanks
Hi Andrei,
I have the same problem the other folks have. Can you also send the .net 4 vesion. Thanks much.
Send me an email to Ignatandrei@yahoo.com
Hi Andrei,
Can you please send code for Export to Word / Excel / PDF / CSV / HTML with MVC(.net framework 4.0 version). Thanks Mahesh
I will put ASAP to github – or codeplex
Hi Andrei,
Can you also send the .net 4 vesion. Thanks Mohebbo
Send me an email to Ignatandrei@yahoo.com
Hi Andrei,
Additional information: Template File doesn’t exist.
How do I solve this error
Look at source code
Hi!! i need to add an image to the exported files, it’s that possible?
Add the same file
Can You Share the source code on github
an you please send me the .Net 4.0 build of ExporterObjects file.
Can you please send me the .Net 4.0 build of ExporterObjects file.
Hi Andrei,
I Used the Same Exporter i can able to see the cshtml file but there is no file created in the extension exls , Can you please provide me the issue
Hi Andre,
How can I have exporter preserve the data types of the columns being exported into Excel? Right now it just exports everything to “General” type columns in Excel.
Thanks,
Andrew
By modifying the template: https://github.com/ignatandrei/Exporter/wiki/Export-Modifying-Templates
o/ .. is there a simple way to support language specific date while exporting to CSV using ExporterObjects ?
our customer Database speaks German, I’ve overworked the JS and CS controller functions to support / convert german date format, PDF export works fine, and the html tables as well – only CSV export still gives british(?) date 1/1/2019 for example – can I somehow influence the used formatter ?
Modify the Current Thread Culture / UICulture to German 😉
Hey Andrei,
after twiddling with your hint – and finding the “correct place” to implement it .. it works wonderfully
thank you so much