?
Solved

Excel and .net WebService issue

Posted on 2007-04-11
3
Medium Priority
?
677 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 2000 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

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
This article describes a serious pitfall that can happen when deleting shapes using VBA.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

762 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