1

I have a excel workbook. I need to show it as a HTML page that will be refreshed automatically(say every 2 minutes). For that i need to run the calculations on every sheet and then save as HTML. I will figure out later how to swap the new HTML file for the old one later. I already have a macro in excel that does all the calculations and then saves as HTML every 2 min. All i need to do is call that macro

The problem is that the machine on which all this is to take place is a server machine and thus MS office cannot be installed on it. Thus i cannot use Excel COM Inter-op.

One was is if i could write a .net program or a Vb Script that will run the macro. But a .net program always uses inter-op.

Another way is if i could save the book as a HTML and run the macro in the HTML itself(Dont know if the HTML has the VB A code). Here also i found that i require Visual Basic Editor which i cant install( as it comes with excel only).

I would prefer not to use third party soft wares.

Can any of the above two procedures be implemented in the given conditions? if not is there any other way?

UPDATE:

Have been looking into open XML for a solution and have finally found that open XML 2.0 cannot run excel calculations as the SDK does not have the calculation engine. Does open XML SDK 2.5 have the calculation engine??

3 Answers 3

5

In short: You cannot run a macro without Excel installed. Worse: You should not intsall Excel on a Server. It is not recommended and impossible to do this in a stable way. My best bet would be something like this: Use a :net library which can read xlsx files, like EPPLUS and "translate" this macro into net, which the EPPLUS library as its foundation. Also, this is a lot fastrer than Interop (factor 10 - 100) and fits better into a Server infrastructure with ASP.NET (for example).

3
  • I had found EPPlus earlier. But i'm a would like if there is some way without using a third party software. Is it not possible to get some excel dlls that will help me in this work? Nov 22, 2013 at 8:55
  • see my answer, may offer an alternative, use a shared box for Excel work, and use the server for server work Nov 22, 2013 at 9:59
  • 2
    @amaturcoder: I have developed a rather large Excel / Powerpoint Interop Software. While it LOOKS like it is "better" than a third party Library it is a black hole which eats your time. Yes, you could install Excle on the server to run this macro. But then you have slow response times, weird bugs and outright hangs of excel. You can try to fix some of that, but redeveloping the macro in Net eats not as much time. Nov 22, 2013 at 9:59
0

Have you considered putting the macro as a .NET Managed AddIn on a shared machine, executing the macro from the server using a shell command to open Excel on the shared machine and the macro runs on Open.

Then you can get the macro itself to export the data to HTML and copy the pages to your server.

As has been said, avoid installing Office on a server (though it has been done in the past, it's never advisable)

Most robust option would be to re-write your vba in .NET as a .NET Managed AddIn - then you have more control over processes, but as has been pointed out, NOT on a Server.

4
  • Tricky Idea :) But I would avoid that too, what happens when the excel macro hangs for any reason or two or more people try to execute the macro? Nov 22, 2013 at 10:00
  • well, yes, but if the macro was written as a .NET managed AddIn perhaps, then the work could be exected on a seperate thread maybe? Nov 22, 2013 at 10:03
  • also, hopw many people execute a macro is a matter of procedure and access controls, so that need not be a problem. Macro hanging can be handled via thread management if it's a .NET Managed AddIn can't it? Nov 22, 2013 at 10:05
  • I'm new to coding so correct me if im wrong but i think ur option requires that the code be rewritten in .net. The macro in question calls other functions inside it. It is a huge program and has taken months of development. So rewriting it is not preferable. If it really comes to that, i'm thing of using ASP.NET to directly create a webpage with embedded calculations Nov 25, 2013 at 5:49
0

Thanks for the resonses. Found a way to show the excel as HTML in the given conditions.

Just FYI, I used a project known as NPOI. It is the .net version of POI used in java. It allows me to open edit and save excel workbooks without installing excel. plus it is opensource so i customized it according to my requirements.

https://npoi.codeplex.com/

https://github.com/tonyqus/npoi

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.