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.

7 comments:

  1. Awe-inspiring bequest! Your blog is attention-grabbing. I feel affection for it.

    ReplyDelete
  2. Good solution! I just intensify my knowledge about excel settings

    ReplyDelete
  3. great post, the "BUT!" helped me a lot. Thanks!

    ReplyDelete
  4. Thanks a lot! This really helped me out!

    ReplyDelete
  5. Thank you...:) you saved my time :)

    ReplyDelete
  6. There could be legal consequences for professionals who do not adequately store patient files so the wise professional will use a professional storage service.Self Storage

    ReplyDelete