Filling out a complex Excel template from ASP.NET MVC (C#) with OpenXML/ClosedXML/NPOI

3.7k views Asked by At

I am developing an application which must produce a complex well-formatted Excel report. I have previously successfully used OpenXML for filling in PowerPoint and Word templates by first reflecting code with OpenXML Productivity Tool and then passing a model into the reflected code and making the required changes.

I have noticed that some people recommend using ClosedXML and NPOI (e.g. here http://odetocode.com/blogs/scott/archive/2014/07/30/easily-generate-microsoft-office-files-from-c.aspx) for Excel. I've started researching ClosedXML and indeed it seems like a nice solution for creating new Excel files, but I would prefer to fill out the template I already have as it would take a month to write it from scratch.

  1. Is it possible to reflect Excel files into ClosedXML code similarly to like it's done with OpenXML Productivity Tool?

  2. Do you have any examples of ClosedXML code which creates complex Excel files with multiple sheets, thousands of rows, some charts and advanced formatting?

  3. It's quite time-consuming to edit OpenXML code when any significant changes needed. What do you think would be the best technology to use for my task considering also time spent on editing?

Any other tips and tricks on manipulating Excel with C# are appreciated! Thank you for your answers.

1

There are 1 answers

0
Francois Botha On

ClosedXML answers:

  1. You can't reflect code is with OpenXML, but you can load an Excel template and populate it in ClosedXML.
  2. See the ClosedXML Wiki at https://github.com/ClosedXML/ClosedXML/wiki for examples.