Reputation: 436
we are looking to perform following operations (in order) on an Excel template file through C# .NET.
Given below are the options considered: 1. Microsoft.Office.Interop.Excel – The driver achieves all the functionalities mentioned above, however, the driver requires Excel client tool to be installed on the server which is not the preferred option as we cannot request for Excel to be installed on all the environments. 2. Third party offerings - A free driver called Excel Package Plus seemed to fit almost all our requirements. We were able to pretty much do everything in the above list of operations except refreshing the pivot table. 3. Writing a macro on the existing excel file to refresh the pivot table - The refresh will occur when the file is opened by the user causing a delay and also, the requirement is to download the file with the pivot table refreshed .
So, clearly with all the above options, we have hit a roadblock. I was wondering if it is possible to place the excel template in one server that has excel installed and access it from the web server. This way I can use Interop.Excel without having to install the driver on my web server. I'm not really sure if this will work as expected.
Upvotes: 1
Views: 706
Reputation: 10969
Do not use Interop on a server. I have done it, and it is a nightmare - you will have frozes processes, memory leaks and dog slow performance.
What I would recommend is use EPPLUS for all the stuff where you can use it, and use the Open XML SDK to open the excel file and set the named ranges.
Open XML SDK is the low level API to edit Offixe XML documents, including Excel. You can do all the things you can do in Office with it. It is rather complicated so I would recommend using epplus whereever you can, since that avoids many of the pitfalls of manual excel editing.
I remember a tool who could build you the C# code to build the document you pass into it - so you could pass in an excel doc with the named range and see how the tool builds the named range in code. I think the tool was included in the sdk
Upvotes: 2