public ActionResult Index(string writerFormat)
{
try
{
string fileName = null;
WriterFormat format;
HttpContext httpContext = System.Web.HttpContext.Current;
ReportWriter reportWriter = new ReportWriter();
reportWriter.ReportPath = Server.MapPath("~/App_Data/GroupingAgg.rdl");
reportWriter.ReportProcessingMode = ProcessingMode.Remote;
DataSourceCredentials _credential = new DataSourceCredentials();
_credential.Name = "AdventureWorks"; //Datasource name
_credential.UserId = "ssrs1";
_credential.Password = "RDLReport1";
IList<DataSourceCredentials> _credentials = new List<DataSourceCredentials>();
_credentials.Add(_credential);
reportWriter.SetDataSourceCredentials(_credentials);
if (writerFormat == "PDF")
{
fileName = "GroupingAgg.pdf";
format = WriterFormat.PDF;
}
else if (writerFormat == "Word")
{
fileName = "GroupingAgg.doc";
format = WriterFormat.Word;
}
else if (writerFormat == "Html")
{
fileName = "GroupingAgg.Html";
format = WriterFormat.HTML;
}
else if (writerFormat == "PPT")
{
fileName = "GroupingAgg.ppt";
format = WriterFormat.PPT;
}
else
{
fileName = "GroupingAgg.xls";
format = WriterFormat.Excel;
}
reportWriter.Save(fileName, format, httpContext.Response);
}
catch
{
}
return View();
}
} |
Hi,
I have followed all the sample but my generated PDF file i still unable to get the info. All the fields remain empty. Please let me know what have i missed here.
Thanks very much.
public ActionResult Index(string writerFormat)
{
try
{
string fileName = null;
WriterFormat format;
HttpContext httpContext = System.Web.HttpContext.Current;
ReportWriter reportWriter = new ReportWriter();
reportWriter.ReportPath = Server.MapPath("~/App_Data/GroupingAgg.rdl");
reportWriter.ReportProcessingMode = ProcessingMode.Remote;
DataSourceCredentials _credential = new DataSourceCredentials();
_credential.Name = "AdventureWorks"; //Datasource name
_credential.UserId = "ssrs1";
_credential.Password = "RDLReport1";
IList<DataSourceCredentials> _credentials = new List<DataSourceCredentials>();
_credentials.Add(_credential);
reportWriter.SetDataSourceCredentials(_credentials);
if (writerFormat == "PDF")
{
fileName = "GroupingAgg.pdf";
format = WriterFormat.PDF;
}
else if (writerFormat == "Word")
{
fileName = "GroupingAgg.doc";
format = WriterFormat.Word;
}
else if (writerFormat == "Html")
{
fileName = "GroupingAgg.Html";
format = WriterFormat.HTML;
}
else if (writerFormat == "PPT")
{
fileName = "GroupingAgg.ppt";
format = WriterFormat.PPT;
}
else
{
fileName = "GroupingAgg.xls";
format = WriterFormat.Excel;
}
reportWriter.Save(fileName, format, httpContext.Response);
}
catch
{
}
return View();
} |