Hi friends,
I am using C#, asp.net, framework 2, crystal report.
I put an image on crystal report viewer.
When clicking on that image, the crystal report is exported to excel .
My problem is that the crystal report layout is different when exporting to excel.
The column width is very large for some column in the excel.
I put the following code to export to excel in the click event of image .
DataSet rptDS = new DataSet();
myReport.Load(Server.MapPath("~/Reports/rptCompOperationalResultsMonthlyFYCY.rpt"));
if (Session["YearType"].ToString() == "0")
{
this.FillDSWithTable("select * from tmpCalOperationalResultMonthly WHERE CompCode=" + Session["intCompCode"] + " AND mthCode=" + Session["intCurrentMonth"] + " AND torType='COMPANYWISECY'", "tmpOperationalResultMonthly", ref rptDS, con);
}
else
{
this.FillDSWithTable("select * from tmpCalOperationalResultMonthly WHERE CompCode=" + Session["intCompCode"] + " AND mthCode=" + Session["intCurrentMonth"] + " AND torType='COMPANYWISEFY'", "tmpOperationalResultMonthly", ref rptDS, con);
}
myReport.Database.Tables[0].SetDataSource(rptDS.Tables[myReport.Database.Tables[0].Name]);
myReport.DataDefinition.FormulaFields["Company"].Text = "'" + Session["strCompName"].ToString() + "'";
Response.Buffer = false;
Response.ClearContent();
Response.ClearHeaders();
myReport.ExportToHttpResponse(ExportFormatType.Excel, Response, false, "OperationalResult6Months");
thanks in advance
George
[Edited]Code is Wrapped in "pre" tag[/Edited]