Create Excel files from C# without office

I am writing a program that creates stand out reports, currently using the Microsoft.Interop.Excel reference. My dev computer has Excel on it, but the end user might or may not have Office installed. Will this tool stop working if Office isn’t really installed on the end users computer system, or is this interop service different from the actual application?

Unless you have actually Excel installed on the Server/PC or utilize an external tool (which is possible without utilizing Excel Interop, see Create Excel (. XLS and.XLSX) file from C#, it will fail. Using the interop needs Excel to be set up.

If you have an interest in making.xlsx (Office 2007 and beyond) files, you’re in luck. Office 2007+ utilizes OpenXML which for lack of a more apt description is XML files within a zip named.xlsx

Take a stand out file (2007+) and rename it, you can open it up and take a look. If you’re using.NET 3.5 you can utilize the System.IO.Packaging library to manipulate the relationships & zipfile itself, and linq to xml to have fun with the xml (or just DOM if you’re more comfy).

Otherwise id reccomend DotNetZip, a powerfull library for control of zipfiles.

OpenXMLDeveloper has great deals of resources about OpenXML and you can discover more there.

If you want.xls (2003 and listed below) you’re going to need to check out 3rd celebration libraries or possibly learn the file format yourself to attain this without stand out set up

An interop calls something else, it’s an interoperability assembly, so you’re inter-operating with something … in this case Excel, the actual installed Excel.

In this case yes, it will fail to run because it depends upon excel, you’re just calling excel functions. , if they do not have it installed.


Utilizing the Interop will need that the Excel be set up on the maker from which it is running. In a server side solution, this will be dreadful. Rather, you should utilize a tool like the ones above that lets you construct an Excel file without Excel being installed.

If the user does not have Excel but has a tool that will check out Excel (like Open Office), then clearly they will be able to open it. Microsoft has a complimentary Excel audience available for those users that do not have Excel.

Then you must have office installed in the deployed PC which is a needless dependence + if you forget to get rid of then you’ll bleed memory, if you prepare on utilizing office.interop.excel. There are other libraries out there where you PUT ON”T need Office installed, and are much easier to use: NPOI, ClosedXml and EPPlus being some popular alternatives. I will leave the reader to choose which is the finest according to their specific needs, however I would totally advise the worst of those three over the office.interop dll.

Great for brand-new data, however downside here is ClosedXML’s absence of intelligence to update or change data in an existing worksheet. If it has anything significant like a chart, a common use case is to start with a design template and use information to it; ClosedXML will likely break the design template.

Leave a Reply

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