Showing posts with label ReportViewer. Show all posts
Showing posts with label ReportViewer. Show all posts

Friday, April 13, 2012

Export to excel/word saves blank document or problems with the ReportViewer 2010 in the SharePoint 2010. Again.

Initial data
The disposition is the same like in the previous post: SharePoint 2010 -> Visual Web Part -> UpdatePanel -> Microsoft Report Viewer 2010.


Situation
MRV 2010 generates correct report in the  own report section. BUT when we click "Export to Excel/Word" and try to open generated  document -  we have a following warning:   "The file you are trying to open '<FileName.xls>', is in a different format than specified by the file extension. Verify that the file is not corrupted and is from a trusted source before opening the file. Do  you want to open the file now?". If we click yes - we have blank excel/word document.
 
Investigation
If we login as  web-server's admin user and   click "Export to Excel/Word" - we have correct documents without any warnings. If we login as" not admin" user  - we have problem. So the reason is somewhere in the permissions. By "Procees Monitor" I found that "Network Service" had write error in one directory when it was trying to create excel document. It was a signal.


Solution
This directory was "C:\Windows\ServiceProfiles\NetworkService\AppData\Local\Temp".  So to solve this problem - I just added "Authenticated Users" to this directory with "Full Control " permissions.

BUT! This path is not fully correct answer. This path  just a special case... The correct answer is following - to add  "Authenticated Users" with "Full Control " permissions to the temporary directory of  your Web Application pool  account.  I had my pool that worked as "Network Service". So I used  path as above. But ,for example, if your pool has identity = "Administrator.Office", your path could be following: C:\Users\Administrator.OFFICE\AppData\Local\Temp. And don't forget to do it on the server, not  on your local PC.



It  solved this problem for me.  Hope it will help you.

Wednesday, February 22, 2012

The Safari’s and Chrome’s problems with Report Viewer 2010 + UpdatePanel + SharePoint 2010 or Uncaught Sys.ScriptLoadFailedException: Sys.ScriptLoadFailedException: The script '.....' could not be loaded. Uncaught TypeError: Cannot read property '_notified' of null.

Initial data
We have one WebPart for the  SharePoint 2010. In this WebPart we have one UpdatePanel. In this UpdatePanel  -  Microsoft Report Viewer 2010 is placed.

Situation
MS Report Viewer  works correct in the IE9.0 and in the Firefox. Report’s data being displayed correctly… But in the Chrome and in the Safari we have nothing.  Well, we see NOT active Report Viewer, without any content.  But if we remove UpadtePanel – all works  good in all browsers. I was trying to reproduce this issue by base website created in the VS2010 (UpdatePanel + Report Viewer) – and again all was good. There was not any problems.  But in the SharePoint2010 – no data in the ReportViewer.

Investigation
By the Chrome Dev Tool (F12) I found that the page had two JavaScript’s errors :
  1. Uncaught Sys.ScriptLoadFailedException: Sys.ScriptLoadFailedException: The script '....' could not be loaded. 
  2. Uncaught TypeError: Cannot read property '_notified' of null
And it was in the MicrosoftAjaxWebForms.js...

Solution
After internet’s revision I found that the same errors often occur in these browsers ( Safary and Chrome) if you use UpdatePanel/AjaxToolkit – all that uses  ScriptManager. MicrosoftAjax in one word… it looks like the problem is in the following - MicrosoftAjaxWebForms.js don't define WebKit browsers correctly
If you add following code on the page - all works correctly :

Sys.Browser.WebKit = {};
if (navigator.userAgent.indexOf('WebKit/') > -1) {
    Sys.Browser.agent = Sys.Browser.WebKit;
    Sys.Browser.version = parseFloat(navigator.userAgent.match(/WebKit\/(\d+(\.\d+)?)/)[1]);
    Sys.Browser.name = 'WebKit';
}

It looks like that correct JavaScript is present for these browsers, but definer is not present.  In any case these rows were solving my problems. But one question still present - why it was in the SharePoint2010 and was not present in the simple website created by VS2010… only one suggestion - different versions of the scripts for these products.

Hope it will help you.