TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Adhikar Patil
NA
481
128.4k
How can I change the title of rdlc report in MVC
Mar 4 2020 2:41 AM
Hello,
I have an NBISIAReport.rdlc file in MVC and i want to change the title of the report like 'Bridge NBI SIA Report' but title comes like 'NBISIAReport' when i downloaded the report.
Here is my code,
[HttpPost]
public
ActionResult GenerateMultipleNBISIAReport(List<NBISIAReportViewModel> structures)
{
try
{
//var dirName = User.Identity.Name.Replace(" ", "");
DateTime currDate = DateTime.Now;
string
dirName =
"NBI-SIA_Reports"
+
"_"
+ currDate.ToString(
"MM"
) +
"_"
+ currDate.ToString(
"dd"
) +
"_"
+ currDate.ToString(
"yy"
) +
"_"
+ currDate.ToString(
"HH"
) +
"_"
+ currDate.ToString(
"mm"
);
var reportFolderPath = Request.MapPath(Request.ApplicationPath) +
"Downloads/"
+ dirName;
const
string
fileExtension =
"PDF"
;
var zipFolderPath = reportFolderPath +
"/"
+ dirName +
".zip"
;
var exists = Directory.Exists(reportFolderPath);
if
(!exists)
{
Directory.CreateDirectory(reportFolderPath);
}
else
{
Directory.Delete(reportFolderPath,
true
);
Directory.CreateDirectory(reportFolderPath);
}
foreach
(var structure
in
structures)
{
if
(structure.Id ==
null
)
continue
;
string
reportName;
string
reportPath;
string
reportTitle;
switch
(structure.StrKindCode)
{
case
"1"
:
reportPath = Request.MapPath(Request.ApplicationPath) + @
"Reports\NBISIAReport.rdlc"
;
reportName = structure.StrNumber +
"-Bridge.pdf"
;
break
;
case
"2"
:
reportPath = Request.MapPath(Request.ApplicationPath) + @
"Reports\NBISIAReport.rdlc"
;
reportName = structure.StrNumber +
"-Culvert.pdf"
;
break
;
case
"3"
:
reportPath = Request.MapPath(Request.ApplicationPath) + @
"Reports\NBISIAReport.rdlc"
;
reportName = structure.StrNumber +
"-Tunnel.pdf"
;
break
;
case
"4"
:
reportPath = Request.MapPath(Request.ApplicationPath) + @
"Reports\NBISIAReport.rdlc"
;
reportName = structure.StrNumber +
"-Trail.pdf"
;
break
;
default
:
reportPath = Request.MapPath(Request.ApplicationPath) + @
"Reports\NBISIAReport.rdlc"
;
reportName = structure.StrNumber +
"-Other.pdf"
;
break
;
}
var localReport =
new
LocalReport {
ReportPath = reportPath };
var obj =
new
InspectionReportData();
var ds = obj.GetNBISIAReportData(Convert.ToInt32(structure.Id), AgencyCode);
localReport.DataSources.Add(
new
ReportDataSource(
"NBISIAReportDataSet"
, ds.Tables[0]));
localReport.DataSources.Add(
new
ReportDataSource(
"NBISIABIPReportDataSet"
, ds.Tables[1]));
localReport.EnableExternalImages =
true
;
localReport.DisplayName = reportTitle;
var renderByte = localReport.Render(fileExtension,
""
);
localReport.DisplayName=
'Bridge NBI SIA Report'
;
using
(var fileStream =
new
FileStream(reportFolderPath +
"/"
+ reportName, FileMode.Create))
{
fileStream.Write(renderByte, 0, renderByte.Length);
}
}
using
(var zip =
new
ZipFile())
{
zip.AddDirectory(reportFolderPath);
zip.Save(zipFolderPath);
}
dirName =
string
.Empty;
return
Json(
new
{ success =
true
, filePath = zipFolderPath }, JsonRequestBehavior.AllowGet);
}
catch
(Exception ex)
{
return
Json(
new
{ success =
false
, message = ex.Message }, JsonRequestBehavior.AllowGet);
}
}
Reply
Answers (
2
)
Import blog to C# Corner via URL option
How To Remove Special Characters In rdlc report