Server 2008 / Excel 2003 automation

somedude

Senior Member
Joined
May 6, 2008
Messages
724
Reaction score
3
Location
GP
Has anybody done Excel automation from C# on Win Server 2008 64bit?

Have run into an interesting issue with code that works flawlesly on XP and Server 2003.

I'm using MS's PIA for Office 11. The application fails with generic error message : Exception from HRESULT: 0x800A03EC

I have traced this to the saving of the Excel workbook. First, some code ;) :

//create new Excel app
Microsoft.Office.Interop.Excel.Application EXL = new Microsoft.Office.Interop.Excel.ApplicationClass();
//new workbook
Workbook workbook = EXL.Workbooks.Add(XlWBATemplate.xlWBATWorksheet);
//new worksheet
Sheets sheets = workbook.Sheets;
Worksheet worksheet = (Worksheet)sheets.get_Item(1);
worksheet.Name = "data";

then follows some code to populate the worksheet, and finally, save and close:

workbook.Close(true, fileName, Type.Missing);
EXL.Quit();

The point of failure has been traced to the saving of the workbook. Editing and saving an existing workbook results in the same error.

The web is full of reports of this same issue (which seems to be permission based), with no working solution.

What I have tried without success:
1. Impersonation with administrator credentials
2. DCOM permissions
3. Filesystem permissions
4. IIS permissions

The weird thing is that the code works when stepping through it with the VS debugger. Again, it is worth noting that this problem only occurs on Server 2008 - eveywhere else is happy.

Can anybody offer some advise/insight?
 
Why not Generate Excel 2007 workbooks? If you generate Excel 2007 workbooks, you are not dependent on Office being installed on the server. There are alot of libraries out there helping with this and you can also use the Office Open XML SDK 2.0.
 
That was the obvious choice, untill we were asked to cater for clients that don't (won't) run Office 2007, and to include formulas in cells and lock cell ranges.
 
That was the obvious choice, untill we were asked to cater for clients that don't (won't) run Office 2007

The Office 2007 Compatibility Pack from Microsoft works extremely well. We all installed it here at work after clients kept sending us .docx all the time.
 
The Office 2007 Compatibility Pack from Microsoft works extremely well. We all installed it here at work after clients kept sending us .docx all the time.

This may have been a solution - if the coding weren't complete...

We're kinda up the creek without a paddle on this one, as the only options seem to be a) re-write, or b) forget about server 2008
 
This may have been a solution - if the coding weren't complete...

We're kinda up the creek without a paddle on this one, as the only options seem to be a) re-write, or b) forget about server 2008

Feel your pain! I think errors like this need to be checked off in the column where M$ is "breaking" backwards compatibility, I'm a little worried about problems like this in Windows 7...
 
To be honest, we went into this knowing that automation is not supported on server products. It was a quick and dirty solution, and it worked, untill we tried a modern OS... I think it's also more a case of improved OS security (which is welcome) that broke a working solution (which is NOT welcome) :)
 
I once wrote my own Assembly to export any DataTable object to Excel 2007. It utilizes the OpenXML framework - after all, Excel 2007 documents are only a bunch of XML files linked by relationship files!

Office Interop is horribly slow and dependent on Office being installed on the server, which is in production environments about 1% of the time.
 
Office Interop is horribly slow and dependent on Office being installed on the server, which is in production environments about 1% of the time.

Interop is not that slow if you do it right - we generate a 2,000 row spreadsheet with 18 columns containing formulas and cell formatting in under 1 second.

Due to the time-constraint we're facing, we will most likely deploy on Server 2003 in the interim, and then rewrite when time and resources allow.
 
I really don't think there's a way to do Interop "wrong", mind you... Oh wait, there is: USING it is wrong! :p
 
Right, wrong, its all the same to me ;)
Rather call it "slow" ways and "fast" ways then.
 
real men use notepad ;)

my last excel adventure had me made it as a html page first, add data, save as xls, open as work book do formatting and then save again.

This has cut down on the time spent -all-of-sudeen-layout-changes- which normall isn't that wiii fun when you had the whole thing generated at runtime via code.
 
Last edited:
Nope, does the same in debug and release mode.
It only works on Server 2008 if you step through it in VS in debug mode.
 
Top
Sign up to the MyBroadband newsletter
X