Solved

Excel and .net WebService issue

Posted on 2007-04-11
3
671 Views
Last Modified: 2013-12-17
I have written a Web Service in C# using visual studio 2005. One of the functions is to generate reports using MS excel. The problem I have is the following.

While I am debugging the web service (running it directly from VS), the report generation works properly. If I publish the web service and run the report generation it fails with the following error.
"Unable to set the PrintTitleRows property of the PageSetup class".
I have made sure all of the Interop DLL's (e.g. Interop.Excel.dll etc) are copied to the remote web server as well as the same version of MS office being installed as on the development machine (2003 professional).

I have even installed VS2005 and debugged the application on the remote server. The report generation works when the Web Service is run from VS but failed when published.

As anyone got any idea as to what is going on here?


Sample of the code:
    Excel.ApplicationClass excelApp;
    Excel.Workbook newWorkbook;
    excelApp = new Excel.ApplicationClass();

    Excel._Worksheet oSheet;
    Excel.Range oRng;
    excelApp.Visible = false;
    newWorkbook = excelApp.Application.Workbooks.Add(Type.Missing);
    oSheet = (Excel._Worksheet)newWorkbook.ActiveSheet;
    oSheet.Name = RepFormat.ReportReference;
    oSheet.PageSetup.PrintTitleRows = "$1:$3";    // This line fails





0
Comment
Question by:WallaceAdrian
  • 2
3 Comments
 
LVL 85

Expert Comment

by:Rory Archibald
Comment Utility
I suspect that the problem is that the account your service is running under does not have printers installed. As a result you cannot access anything to do with PageSetup.
Regards,
Rory
0
 
LVL 2

Author Comment

by:WallaceAdrian
Comment Utility
Hi Rory,
Your suggestion makes sense but I have just tried that but I get the same result.

I went in to the printer properties for the default printer. On the security tab, I added the NETWORK SERVICE account and gave all priveledges (Print, Manage printers & documents ...).
I also stopped and restarted the service.

Is this what you had in mind?

Thanks
0
 
LVL 85

Accepted Solution

by:
Rory Archibald earned 500 total points
Comment Utility
No - Office apps work on the basis that they are being run interactively with the desktop - i.e. you are logged in as the account they are running as. If the *profile* for the account that is running the service does not have an installed printer, then you cannot access the PageSetup properties. If your service is running as a network/system account, then it does not have a profile or any installed printers. Can you run it as a user account?
Regards,
Rory
PS You may wish to review this article: http://support.microsoft.com/?id=257757
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
Introduction This Article is a follow-up to my Mappit! Addin Article (http://www.experts-exchange.com/A_2613.html), it was inspired by an email posting I made to EUSPRIG (http://www.eusprig.org/index.htm), I will briefly cover: 1) An overvie…
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now