Solved

Excel and .net WebService issue

Posted on 2007-04-11
3
676 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 85

Expert Comment

by:Rory Archibald
ID: 18888556
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
ID: 18888644
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
ID: 18888693
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

728 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