I looking for assistance with the following. I have a SQL Server Report which when exported to Excel is difficult to read. So, I created an Excel Template which I would like to use in place of the default Excel file Reporting Services exports to. How do modify my code so that my Excel template is used instead of the default when the user exports the report? Below is my code. Any assistance is appreciated.
test.aspx
<%@. Page Language="C#" Debug="true" AutoEventWireup="true" CodeFile="Test.aspx.cs" Inherits="Test" %><%@. Register Assembly="Microsoft.ReportViewer.WebForms, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title>Untitled Page</title></head><body> <form id="form1" runat="server"> <div> <rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana" Font-Size="8pt" Height="400px" Width="400px"> </rsweb:ReportViewer> </div> </form></body></html>
test.aspx.cs
using System;using System.Data;using System.Data.SqlClient;using System.Configuration;using System.Collections;using System.Text;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using Microsoft.Reporting.WebForms;public partialclass Test : System.Web.UI.Page{// Handles initial page loadprotected void Page_Load(object sender, EventArgs e) { ConfigureReports(); }protected void ConfigureReports() { ReportViewer1.LocalReport.ReportPath = Server.MapPath("reports/BirdsReport.rdlc"); DataSet dataSet = DataSetConfig.Birds; ReportDataSource ds =new ReportDataSource("BirdsDataSet_Birds", dataSet.Tables[0]); ReportViewer1.LocalReport.DataSources.Clear(); ReportViewer1.LocalReport.DataSources.Add(ds); ReportViewer1.LocalReport.Refresh(); } }
DataSetConfig.cs
using System;using System.Data;using System.Data.SqlClient;using System.Configuration;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;/// <summary>/// Summary description for DataSetConfig/// </summary>public class DataSetConfig{public DataSetConfig(){//// TODO: Add constructor logic here//}// Handles creating holds datasetpublic static DataSet Holds {get { DataSet dataSet =new DataSet();string query ="select * from birds"; dataSet.ReadXmlSchema(@."D:\Sites\Birds\App_Code\BirdsDataSet.xsd");// remote path SqlConnection conn =new SqlConnection(ConfigurationManager.ConnectionStrings["BirdsConnectionString"].ConnectionString); SqlDataAdapter cmd =new SqlDataAdapter(query, conn); cmd.Fill(dataSet,"Birds");return dataSet; } }}
I'm still looking for assistance with this issue. Does anyone in the community know of alternative online resources for SSRS that offer reliable assistance?
Hi,
Based on my knowledge, you can't create your own excel exporting format by your codes level. If you insist on doing that, some third-party software may involve in achieving your custom render.
As for the online resources:
http://technet.microsoft.com/en-us/sqlserver/bb331748.aspx (For SQLServer 2000)
http://technet.microsoft.com/en-us/sqlserver/bb331776.aspx (For SQLServer 2005)
Thanks.
No comments:
Post a Comment