Thursday, March 29, 2012

Error exporting a subreport to Excel!?

Hi All,

I have a report sonsisting of two subreports. When I export it to Excel I get an Error!! I played around with it and I found out that if I use ReportItems in my page header it will cause this error! Does anyone have any idea why? Is this a bug or there is some work around it! Thanks.We have talked to our Microsoft rep and they have told us that it is a "feature" and that is how is was designed. It is true that a subreport within a table or matrix will not export to excel. The only workaround is to have the subreport outside of the table or matrix, have the report export to pdf instead, or export the first page of the report (if there are no subreports on the first page) and run the report through excel.

Our rep is seeing if she can get the development team to change it, but I think our chances are slim.|||Thanks for the reply. My case is different! I don't have a table or matrix with subreport in it! I just have a plain page with subreports. Exporting to Excel works only if there is NO reference to any item on the report from Page Header! When I have a "ReportItems!MyText.Value" any where in the Page Header, then exporting to Excel fails!|||

What version of RS are you using? Could you send us the report files, please?

Thank you,

Nico

|||

I'm using RS 2000

Try this Main Report. You need "Company Sales" sample report as your sub-report.

<?xml version="1.0" encoding="utf-8"?>
<Report xmlns="http://schemas.microsoft.com/sqlserver/reporting/2003/10/reportdefinition" xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">
<PageHeader>
<ReportItems>
<Textbox Name="textbox1">
<Style>
<PaddingLeft>2pt</PaddingLeft>
<PaddingBottom>2pt</PaddingBottom>
<PaddingTop>2pt</PaddingTop>
<PaddingRight>2pt</PaddingRight>
</Style>
<rd:DefaultName>textbox1</rd:DefaultName>
<Width>2in</Width>
<Top>0.125in</Top>
<CanGrow>true</CanGrow>
<Value>=ReportItems!MyTextBox.Value</Value>
<Left>4.125in</Left>
</Textbox>
</ReportItems>
<PrintOnLastPage>true</PrintOnLastPage>
<PrintOnFirstPage>true</PrintOnFirstPage>
<Style />
<Height>0.375in</Height>
</PageHeader>
<RightMargin>0.5in</RightMargin>
<Body>
<ReportItems>
<Textbox Name="MyTextBox">
<Style>
<PaddingLeft>2pt</PaddingLeft>
<PaddingBottom>2pt</PaddingBottom>
<PaddingTop>2pt</PaddingTop>
<PaddingRight>2pt</PaddingRight>
</Style>
<ZIndex>1</ZIndex>
<Height>0.25in</Height>
<Width>2.625in</Width>
<Top>5.125in</Top>
<CanGrow>true</CanGrow>
<Value>=Fields!Name.Value</Value>
<Left>2in</Left>
</Textbox>
<Subreport Name="subreport1">
<Style />
<ReportName>Company Sales</ReportName>
<Height>4.5in</Height>
<Width>5.875in</Width>
<Top>0.125in</Top>
<Left>0.25in</Left>
</Subreport>
</ReportItems>
<Style />
<Height>6in</Height>
</Body>
<TopMargin>0.5in</TopMargin>
<DataSources>
<DataSource Name="AdventureWorks2000">
<rd:DataSourceID>75e82b3d-05fd-468b-920e-b793f54e666c</rd:DataSourceID>
<DataSourceReference>AdventureWorks2000</DataSourceReference>
</DataSource>
</DataSources>
<Code />
<Width>6.5in</Width>
<DataSets>
<DataSet Name="DataSet1">
<Fields>
<Field Name="ProductCategoryID">
<DataField>ProductCategoryID</DataField>
<rd:TypeName>System.Byte</rd:TypeName>
</Field>
<Field Name="Name">
<DataField>Name</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
</Fields>
<Query>
<DataSourceName>AdventureWorks2000</DataSourceName>
<CommandText>SELECT DISTINCT ProductCategoryID, Name
FROM ProductCategory
ORDER BY Name</CommandText>
</Query>
</DataSet>
</DataSets>
<LeftMargin>0.5in</LeftMargin>
<rd:SnapToGrid>true</rd:SnapToGrid>
<rd:DrawGrid>true</rd:DrawGrid>
<rd:ReportID>55a44d5c-37c0-4b84-b326-e2e6aa50fb35</rd:ReportID>
<BottomMargin>0.5in</BottomMargin>
<Language>en-US</Language>
</Report>

|||

Hi,

Did anybody from Microsoft found out about this bug? I'm still waiting for a solution! Please help! Thanks.

|||

hi,

this has been cracked already....

hehe

microsoft did not bother to provide anything on this.

but we discovered a work around.

and it works awesome ...i guess this is what we do at www.snktheone. to provide solution to all the challenges faced in Reporting services development and Web development.

use the list control and then drop all the table in your subreport into this list control.

make sure List control uses the same dataregion as your subreports.

this made wonders for us..

hope i would have solved your query..

Regards,

www.snktheone.com

|||Didn't work!! I put my sub-report inside a List control and now my report is repeated multiple times! How do you make it to repeat it only once? I still get an error when exporting to Excel! Any other solutions? Thanks.|||

hi mike,

i came across a situation in which i had a table and then i needed 3 subreports to be embedded inside the table. i used the subreports as not the control subreport, butinstead i used the table which i created for these sub reports and then dropped these tables in a single list control

also i made sure that all the 3 tables called the same stored procedure, which was called from the list control.

i hope it does make a diff for u.

regards

www.snktheone.com

|||In my situation there is no table! Just a simple sub-report. Anyhow, I ended up removing the header and any reference to the ReportItems from my report Footer to make it work! I believe this is the only solution to this MS bug! But, still love to see if someone come up with a solution for this glitch. Thanks.

No comments:

Post a Comment