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


Posted

in

by

Tags:

Comments

26 responses to “Export to Word / Excel / PDF / CSV / HTML”

  1. Bill Elliott Avatar
    Bill Elliott

    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?

    1. Andrei Ignat Avatar
      Andrei Ignat

      Sent by email

      1. SSA Avatar
        SSA

        Hi Andrei,
        Can you also send the build for .net 4 to me, same problem as @Bill Elliott. Can not compile from source.
        Thanks

        1. Andrei Ignat Avatar
          Andrei Ignat

          Check your email

          1. SSA Avatar
            SSA

            Hi Ignat,
            Is ExportDataTable only available in version 2?
            Thanks,
            Sandeep Sharma

  2. MS Avatar
    MS

    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

    1. Enoch Avatar
      Enoch

      Hi Andrei,
      I have the same problem the other folks have. Can you also send the .net 4 vesion. Thanks much.

      1. Andrei Ignat Avatar
        Andrei Ignat

        Send me an email to Ignatandrei@yahoo.com

        1. Mahesh Avatar
          Mahesh

          Hi Andrei,
          Can you please send code for Export to Word / Excel / PDF / CSV / HTML with MVC(.net framework 4.0 version). Thanks Mahesh

          1. Andrei Ignat Avatar
            Andrei Ignat

            I will put ASAP to github – or codeplex

  3. Mohebbo Avatar

    Hi Andrei,
    Can you also send the .net 4 vesion. Thanks Mohebbo

    1. Andrei Ignat Avatar
      Andrei Ignat

      Send me an email to Ignatandrei@yahoo.com

  4. Murat Avatar
    Murat

    Hi Andrei,
    Additional information: Template File doesn’t exist.
    How do I solve this error

    1. Andrei Ignat Avatar
      Andrei Ignat

      Look at source code

  5. Nicolas Ottaviano Avatar

    Hi!! i need to add an image to the exported files, it’s that possible?

    1. Andrei Ignat Avatar
      Andrei Ignat

      Add the same file

  6. Ahmed Avatar
    Ahmed

    Can You Share the source code on github

  7. Arumugam Avatar
    Arumugam

    an you please send me the .Net 4.0 build of ExporterObjects file.

  8. Nader Michael Avatar
    Nader Michael

    Can you please send me the .Net 4.0 build of ExporterObjects file.

  9. sarath Avatar
    sarath

    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

  10. Andrew Avatar
    Andrew

    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

  11. Sven Leuschner Avatar
    Sven Leuschner

    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 ?

    1. Andrei Ignat Avatar
      Andrei Ignat

      Modify the Current Thread Culture / UICulture to German 😉

      1. Sven Leuschner Avatar
        Sven Leuschner

        Hey Andrei,
        after twiddling with your hint – and finding the “correct place” to implement it .. it works wonderfully

        thank you so much

Leave a Reply

Your email address will not be published. Required fields are marked *