Exporting SSRS report to Excel 2007 - Excel found unreadable content in file xlsx
We recently upgraded from SSRS 2008 R2 to SSRS 2012 and we've encountered an issue with exporting the report to xlsx format. When the user opens the report, a prompt appears saying, "Excel found unreadable content in file.xlsx. Do you want to recover the contents of this workbook." We didn't have this issue when we were on SSRS 2008.

I looked a little into it and it appears to be related to a value having a large number of decimals for the value of 0. The SSRS exported file contains 0.00000000000000.

One way I've duplicated it is to create a blank report with this dataset below. Put it in a table and export.
SELECT cast(0 AS DECIMAL(20,14)) AS field1
Can someone confirm if they get this error too? Is there a workaround? We have a calculation like
case when condition = true then 0 else (field2 / field3) end

where field2 and field3 are decimal values like (13,0) and (38,0). The 0 ends up with many decimal places and causes that dialog message upon opening opening the exported Excel file.

SSRS 2012


  • Edited by GabeMSDN Monday, October 01, 2012 8:38 PM
October 1st, 2012 7:15pm

Hi There

Thanks for your posting. I did try your code but I could not reproduce the error inside my test environment. I dont really know what is your requirement in terms of how many places do you need in your report. Please try to convert the division to 4 decimal places this  might help you

declare @condition as bit

declare @field2 as decimal(10,4)

declare @field1 as decimal(10,4)

set @condition =0

set @field2=400000.5

set @field1=4056.45

select

case when @condition = 0 then convert(decimal(10,4),0 )else convert(decimal(10,4),(@field2 / @field1)) end as field1

 set @condition =1

select case when @condition = 0 then convert(decimal(10,2),0 )else convert(decimal(10,4),(@field2 / @field1)) end as field1

declare @condition as bit
declare @field2 as decimal(10,4)
declare @field1 as decimal(10,4)
set @condition =0
set @field2=400000.5
set @field1=4056.45
select 
case when @condition = 0 then convert(decimal(10,4),0 )else convert(decimal(10,4),(@field2 / @field1)) end as field1
 set @condition =1
select case when @condition = 0 then convert(decimal(10,2),0 )else convert(decimal(10,4),(@field2 / @field1)) end as field1

Many Thanks

Syed Qazafi Anjum

Please click "Mark as Answer" if this resolves your problem or "Vote as Helpful" if you find it helpful

Free Windows Admin Tool Kit Click here and download it now
October 1st, 2012 8:31pm

Thank you for the reply, Syed. It's odd that you could not replicate the issue. We've tested it on a few machines using SSRS 2012. We did find that if we cast the output value to decimal(20,8), it worked. But we'd like to maintain as much precision as possible, ideally 16 decimal points to the right. Is this a limitation?

Below is an example of our resultset in SSMS. Putting that into a table and exporting causes the issue.


I did find this Microsoft Connect Item which may be related. http://connect.microsoft.com/SQLServer/feedback/details/751606/sql-server-2012-reporting-services-export-to-excel-xlsx-zero-to-15-decimals-places




  • Edited by GabeMSDN Monday, October 01, 2012 9:40 PM
October 1st, 2012 9:38pm

Did you find any fix for this? I'm also on the same boat as you.

Thanks

Free Windows Admin Tool Kit Click here and download it now
July 16th, 2015 2:20am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics