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:
excelApp = new Excel.ApplicationClass();
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