我的应用程序中有一个rdlc
报告,我想用一个表达式来显示波斯语日期,但问题是我找不到任何表达式,有没有办法在我的应用程序中显示波斯语日期在rdlc
文件中报告?
答案 0 :(得分:3)
在rdlc报告的“报告”菜单中选择“报告属性”,然后转到“代码”选项卡并开始编写自定义方法,以便在VB中将格鲁吉亚日期转换为波斯语(Jalali)日历。 (请记住,在自定义代码中,您只能在VB中编写代码!)之后在报表中添加一个文本框并编写如下表达式:= Code.GetPersianDate(Fields!Date.Value)
哪个日期是数据集中的一列,显然GetPersianDate是方法的名称。
感谢http://ilood.com/?i=ObwcXTETQTY=
它确实有帮助。
答案 1 :(得分:2)
在报告属性/代码选项卡
中复制此代码Public Function GetPersianDate(dtGeorgian as DateTime) as string
dim strPersianDate as string
dim strYear as string
dim strMonth as string
dim strDay as string
dim objPersiancal as System.Globalization.PersianCalendar
objPersiancal = new System.Globalization.PersianCalendar()
if(dtGeorgian =Nothing) then
return string.empty
end if
strYear = objPersiancal.GetYear(dtGeorgian).ToString()
strMonth = objPersiancal.GetMonth(dtGeorgian).ToString()
strDay = objPersiancal.GetDayOfMonth(dtGeorgian).ToString()
if (strDay.Length < 2) then strDay = "0" + strDay
if (strMonth.Length < 2) then strMonth = "0" + strMonth
strPersianDate = strYear + "/" + strMonth + "/" + strDay
return strPersianDate
End Function
现在在任何要右键单击的文本框上,选择表达式并在该表达式前面添加此代码。
=Code.GetPersianDate()
注意:您之前的表达式应位于括号内。
答案 2 :(得分:1)
小时,分钟和秒 您可以在以前的答案中添加一些行
Public Function GetPersianDateAndTime(dtGeorgian as DateTime) as string
dim strPersianDate as string
dim strPersianTime as string
dim strYear as string
dim strMonth as string
dim strDay as string
dim strHour as string
dim strMinute as string
dim strSeconds as string
dim objPersiancal as System.Globalization.PersianCalendar
objPersiancal = new System.Globalization.PersianCalendar()
if(dtGeorgian =Nothing) then
return string.empty
end if
strYear = objPersiancal.GetYear(dtGeorgian).ToString()
strMonth = objPersiancal.GetMonth(dtGeorgian).ToString()
strDay = objPersiancal.GetDayOfMonth(dtGeorgian).ToString()
strHour = objPersiancal.GetHour(dtGeorgian).ToString()
strMinute = objPersiancal.GetMinute(dtGeorgian).ToString()
strSeconds = objPersiancal.GetDayOfMonth(dtGeorgian).ToString()
if (strDay.Length< 2) then strDay = "0" + strDay
if (strMonth.Length< 2) then strMonth = "0" + strMonth
strPersianDate = strYear + "/" + strMonth + "/" + strDay
strPersianTime = strHour + ":" + strMinute + ":" + strSeconds
return strPersianDate+"_"+strPersianTime
End Function