Showing posts with label rendering. Show all posts
Showing posts with label rendering. Show all posts

Friday, February 24, 2012

Export To Excel

Hi Friends,
I am generating a report using sql server reporting service and
rendering it in my .aspx page in a report viewer control. Now i need
to export it to excel so that the excel file can be stored in client
pc.How do i show an save as dialoge box,so that user can either
save,open or cancel.
Please help me out.
Thanks,
RanjanOn Feb 27, 12:26 am, "Ranj" <ranjan.raghaven...@.gmail.com> wrote:
> Hi Friends,
> I am generating a report using sql server reporting service and
> rendering it in my .aspx page in a report viewer control. Now i need
> to export it to excel so that the excel file can be stored in client
> pc.How do i show an save as dialoge box,so that user can either
> save,open or cancel.
> Please help me out.
> Thanks,
> Ranjan
You should be able to use something like the following (basically,
call a header):
------
Response.Clear();
Response.AddHeader("content-disposition", "attachment;filename=" +
Session["SpecialName"].ToString() + "NameOfExcelSpreadsheet.xls");
Response.ContentType = "application/vnd.xls";
System.IO.StringWriter sw = new System.IO.StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
this.ObjectName.RenderControl(htw);
Response.Write(sw.ToString());
Response.End();
------
I'm not certain this will work in the Report Viewer itself though. You
might need to add a button/etc to accomplish this outside the report
viewer. Hope this helps.
Regards,
Enrique Martinez
Sr. ASP.NET/SQL Server Developer

Export to Excel

Hello again,
I found out, that there's a limitation in rendering reports to excel
format. The SSRS can only render reports with less than 256 columns!
Is there a work around to render reports with more than 256 columns?
In my case, it would be also possible to start a new sheet after 256
columns! May someone has any ideas how to cope with that!
Thanks,
FlorianYou can design your report in a way to only have a max of 256 columns in your
matrix and start a new matrix after.
and also it has a limitation on the number of rows I think it is in the
32000 row. so you have to put a page break after each matrix, this way you
will have a new sheet in Excel for each matrix.
Good Luck
"falbrech_www@.gmx.de" wrote:
> Hello again,
> I found out, that there's a limitation in rendering reports to excel
> format. The SSRS can only render reports with less than 256 columns!
> Is there a work around to render reports with more than 256 columns?
> In my case, it would be also possible to start a new sheet after 256
> columns! May someone has any ideas how to cope with that!
> Thanks,
> Florian
>|||Hi Paul,
> You can design your report in a way to only have a max of 256 columns in your
> matrix and start a new matrix after.
might be an idea. But I want to use the same report for HTML and in
this case all the columns should be shown as usual (column by column).
Is there a way to distinguish whether a report is rendered for HTML or
Excel within a report (see a previous post)? Then I might be able to
use more than one matrix for Excel and one matrix for HTML by hide or
unhide them.
> and also it has a limitation on the number of rows I think it is in the
> 32000 row. so you have to put a page break after each matrix, this way you
Thnaks for that hint. But this should be a problem! ;)
Florian|||Maybe you could not use the report to export to excel and use some of the
code in the example instead:-
http://www.simple-talk.com/sql/t-sql-programming/sql-server-excel-workbench/
It would work around the problem.
Dale
"falbrech" <falbrech_www@.gmx.de> wrote in message
news:1187077661.875246.296900@.57g2000hsv.googlegroups.com...
> Hi Paul,
>> You can design your report in a way to only have a max of 256 columns in
>> your
>> matrix and start a new matrix after.
> might be an idea. But I want to use the same report for HTML and in
> this case all the columns should be shown as usual (column by column).
> Is there a way to distinguish whether a report is rendered for HTML or
> Excel within a report (see a previous post)? Then I might be able to
> use more than one matrix for Excel and one matrix for HTML by hide or
> unhide them.
>> and also it has a limitation on the number of rows I think it is in the
>> 32000 row. so you have to put a page break after each matrix, this way
>> you
> Thnaks for that hint. But this should be a problem! ;)
> Florian
>|||Hi!
> Maybe you could not use the report to export to excel and use some of the
> code in the example instead:-
> http://www.simple-talk.com/sql/t-sql-programming/sql-server-excel-wor...
Thanks, but OLE Automation as it is decribed in the article is not an
option!
br,
Florian