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.