您好,欢迎来到爱go旅游网。
搜索
您的当前位置:首页RDLC报表格式设置

RDLC报表格式设置

来源:爱go旅游网
RDLC报表格式设置

设置数字格式

下表列出了常用的 .NET 数字格式设置字符串。 格式字符串 名称

C 或 c 货币

D 或 d 小数

E 或 e 科学记数法

F 或 f 固定点

G 或 g 常规

N 或 n 数量

P 或 p 百分比

R 或 r 往返

X 或 x 十六进制

您可以将许多格式字符串修改为包含精度说明符,该说明符用于定义小数点后的位数。例如,格式设置字符串 D0 将数字格式设置为小数点后没有数字。您还可以使用自定义的格式设置字符串,例如 #,###。

设置日期格式

下表列出了常用的 .NET Framework 日期格式设置字符串。 格式字符串 名称

d 短日期[2008.08.08]

D 长日期[2008年08月08日]

t 短时间

T 长时间

f 完整日期/时间(短时间)

F 完整日期/时间(长时间)

g 常规日期/时间(短时间)[2008.08.08 8:8]

G 常规日期/时间(长时间)

M 或 m 月日

R 或 r RFC1123 模式

Y 或 y 年月

您还可以使用自定义的格式设置字符串,例如 dd/MM/yy。有关 .NET Framework 格式设置字符串的详细信息,请参阅Formatting Types。

例:

说明:如果参考进价>=100000,则保留1位小数,否则保留2位小数. =IIF(Fields!参考进价.Value>=100000,\"F1\" , \"F2\")

Public Sub Main()

' Display string representations of numbers for en-us culture Dim ci As New CultureInfo(\"en-us\")

' Output floating point values

Dim floating As Double = 10761.9375 Console.WriteLine(\"C: {0}\", _

floating.ToString(\"C\ci)) ' Displays \"C: $10,761.94\" Console.WriteLine(\"E: {0}\", _

floating.ToString(\"E03\ci)) ' Displays \"E: 1.076E+004\" Console.WriteLine(\"F: {0}\", _

floating.ToString(\"F04\ci)) ' Displays \"F:

10761.9376\"

Console.WriteLine(\"G: {0}\", _ 10761.9375\"

Console.WriteLine(\"N: {0}\", _

floating.ToString(\"N03\ci)) ' Displays \"N: 10,761.938\" Console.WriteLine(\"P: {0}\", _

(floating/10000).ToString(\"P02\ Console.WriteLine(\"R: {0}\", _

floating.ToString(\"R\

ci))

'

Displays

\"R:

floating.ToString(\"G\

ci))

'

Displays

\"G:

10761.9375\" Console.WriteLine()

' Output integral values Dim integral As Integer = 8395 Console.WriteLine(\"C: {0}\", _

integral.ToString(\"C\ Console.WriteLine(\"D: {0}\", _

integral.ToString(\"D6\")) ' Displays D: 008395\"\" Console.WriteLine(\"E: {0}\", _

integral.ToString(\"E03\ci)) ' Displays \"E: 8.395E+003\" Console.WriteLine(\"F: {0}\", _

integral.ToString(\"F01\ Console.WriteLine(\"G: {0}\", _

integral.ToString(\"G\ Console.WriteLine(\"N: {0}\", _

integral.ToString(\"N01\ Console.WriteLine(\"P: {0}\", _

(integral/10000).ToString(\"P02\ Console.WriteLine(\"X: 0x{0}\", _

integral.ToString(\"X\ Console.WriteLine() End Sub

Public Shared Sub Main()

Dim msgShortDate As String = \"(d) Short date: . . . . . . . \" Dim msgLongDate As String = \"(D) Long date:. . . . . . . . \" Dim msgShortTime As String = \"(t) Short time: . . . . . . . \" Dim msgLongTime As String = \"(T) Long time:. . . . . . . . \" Dim msgFullDateShortTime As String = _

\"(f) Full date/short time: . . \" Dim msgFullDateLongTime As String = _

\"(F) Full date/long time:. . . \" Dim msgGeneralDateShortTime As String = _

\"(g) General date/short time:. \" Dim msgGeneralDateLongTime As String = _

\"(G) General date/long time (default):\" & vbCrLf & _

\" . . . . . . . . . . . . . \" Dim msgMonth As String = \"(M) Month:. . . . . . . . . . \" Dim msgRFC1123 As String = \"(R) RFC1123:. . . . . . . . . \" Dim msgSortable As String = \"(s) Sortable: . . . . . . . . \" Dim msgUniSortInvariant As String = _

\"(u) Universal sortable (invariant):\" & vbCrLf & _

\" . . . . . . . . . . . . . \" Dim msgUniFull As String = \"(U) Universal full date/time: \" Dim msgYear As String = \"(Y) Year: . . . . . . . . . . \"

Dim msgRoundtripLocal As String = \"(o) Roundtrip (local):. . . . \"

Dim msgRoundtripUTC As String = \"(o) Roundtrip (UTC):. . . . . \"

Dim msgRoundtripUnspecified As String = \"(o) Roundtrip (Unspecified):. \"

Dim msg1 As String = \"Use ToString(String) and the current thread culture.\" & vbCrLf

Dim msg2 As String = \"Use ToString(String, IFormatProvider) and a specified culture.\" & vbCrLf

Dim msgCulture As String = \"Culture:\"

Dim msgThisDate As String = \"This date and time: {0}\" & vbCrLf

Dim thisDate As DateTime = DateTime.Now

Dim utcDate As DateTime = thisDate.ToUniversalTime()

Dim unspecifiedDate As DateTime = new DateTime(2000, 3, 20, 13, 2, 3, 0, DateTimeKind.Unspecified) Dim ci As CultureInfo

' Format the current date and time in various ways. Console.Clear()

Console.WriteLine(\"Standard DateTime Format Specifiers:\" & vbCrLf) Console.WriteLine(msgThisDate, thisDate) Console.WriteLine(msg1)

' Display the thread current culture, which is used to format the values. ci = Thread.CurrentThread.CurrentCulture

Console.WriteLine(\"{0,-30}{1}\" & vbCrLf, msgCulture, ci.DisplayName)

Console.WriteLine(msgShortDate & thisDate.ToString(\"d\"))

Console.WriteLine(msgLongDate & thisDate.ToString(\"D\"))

Console.WriteLine(msgShortTime & thisDate.ToString(\"t\"))

Console.WriteLine(msgLongTime & thisDate.ToString(\"T\"))

Console.WriteLine(msgFullDateShortTime & thisDate.ToString(\"f\"))

Console.WriteLine(msgFullDateLongTime & thisDate.ToString(\"F\"))

& thisDate.ToString(\"g\"))

Console.WriteLine(msgGeneralDateLongTime & thisDate.ToString(\"G\"))

Console.WriteLine(msgMonth & thisDate.ToString(\"M\"))

Console.WriteLine(msgRFC1123 & utcDate.ToString(\"R\"))

Console.WriteLine(msgSortable & thisDate.ToString(\"s\"))

Console.WriteLine(msgUniSortInvariant & utcDate.ToString(\"u\"))

Console.WriteLine(msgUniFull & thisDate.ToString(\"U\"))

Console.WriteLine(msgYear & thisDate.ToString(\"Y\"))

Console.WriteLine(msgRoundtripLocal & thisDate.ToString(\"o\"))

Console.WriteLine(msgRoundtripUTC & utcDate.ToString(\"o\"))

Console.WriteLine(msgRoundtripUnspecified

&

Console.WriteLine(msgGeneralDateShortTime

unspecifiedDate.ToString(\"o\"))

Console.WriteLine()

' Display the same values using a CultureInfo object. The CultureInfo class ' implements IFormatProvider. Console.WriteLine(msg2)

' Display the culture used to format the values. ci = New CultureInfo(\"de-DE\")

Console.WriteLine(\"{0,-30}{1}\" & vbCrLf, msgCulture, ci.DisplayName)

Console.WriteLine(msgShortDate & thisDate.ToString(\"d\", ci))

Console.WriteLine(msgLongDate & thisDate.ToString(\"D\", ci))

Console.WriteLine(msgShortTime & thisDate.ToString(\"t\", ci))

Console.WriteLine(msgLongTime & thisDate.ToString(\"T\", ci))

Console.WriteLine(msgFullDateShortTime & thisDate.ToString(\"f\", ci))

Console.WriteLine(msgFullDateLongTime & thisDate.ToString(\"F\", ci))

Console.WriteLine(msgGeneralDateShortTime

& thisDate.ToString(\"g\", ci))

Console.WriteLine(msgGeneralDateLongTime & thisDate.ToString(\"G\", ci))

Console.WriteLine(msgMonth & thisDate.ToString(\"M\", ci))

Console.WriteLine(msgRFC1123 & utcDate.ToString(\"R\", ci))

Console.WriteLine(msgSortable & thisDate.ToString(\"s\", ci))

Console.WriteLine(msgUniSortInvariant & utcDate.ToString(\"u\", ci))

Console.WriteLine(msgUniFull & thisDate.ToString(\"U\", ci))

Console.WriteLine(msgYear & thisDate.ToString(\"Y\", ci))

Console.WriteLine(msgRoundtripLocal & thisDate.ToString(\"o\"), ci)

Console.WriteLine(msgRoundtripUTC & utcDate.ToString(\"o\"), ci)

Console.WriteLine(msgRoundtripUnspecified

&

unspecifiedDate.ToString(\"o\"), ci)

Console.WriteLine()

End Sub 'Main End Class 'Sample '

'This code example produces the following results: '

'Standard DateTime Format Specifiers: '

'This date and time: 4/17/2006 2:29:09 PM '

'Use ToString(String) and the current thread culture. '

'Culture: English (United States) '

'(d) Short date: . . . . . . . 4/17/2006

'(D) Long date:. . . . . . . . Monday, April 17, 2006 '(t) Short time: . . . . . . . 2:29 PM '(T) Long time:. . . . . . . . 2:29:09 PM

'(f) Full date/short time: . . Monday, April 17, 2006 2:29 PM '(F) Full date/long time:. . . Monday, April 17, 2006 2:29:09 PM

'(g) General date/short time:. 4/17/2006 2:29 PM '(G) General date/long time (default):

' . . . . . . . . . . . . . 4/17/2006 2:29:09 PM '(M) Month:. . . . . . . . . . April 17

'(R) RFC1123:. . . . . . . . . Mon, 17 Apr 2006 21:29:09 GMT '(s) Sortable: . . . . . . . . 2006-04-17T14:29:09 '(u) Universal sortable (invariant):

' . . . . . . . . . . . . . 2006-04-17 21:29:09Z

'(U) Universal full date/time: Monday, April 17, 2006 9:29:09 PM '(Y) Year: . . . . . . . . . . April, 2006

'(o) Roundtrip (local):. . . . 2006-04-17T14:29:09.3011250-07:00 '(o) Roundtrip (UTC):. . . . . 2006-04-17T21:29:09.3011250Z '(o) Roundtrip (Unspecified):. 2000-03-20T13:02:03.0000000 '

'Use ToString(String, IFormatProvider) and a specified culture. '

'Culture: German (Germany) '

'(d) Short date: . . . . . . . 17.04.2006

'(D) Long date:. . . . . . . . Montag, 17. April 2006 '(t) Short time: . . . . . . . 14:29 '(T) Long time:. . . . . . . . 14:29:09

'(f) Full date/short time: . . Montag, 17. April 2006 14:29 '(F) Full date/long time:. . . Montag, 17. April 2006 14:29:09 '(g) General date/short time:. 17.04.2006 14:29 '(G) General date/long time (default):

' . . . . . . . . . . . . . 17.04.2006 14:29:09 '(M) Month:. . . . . . . . . . 17 April

'(R) RFC1123:. . . . . . . . . Mon, 17 Apr 2006 21:29:09 GMT '(s) Sortable: . . . . . . . . 2006-04-17T14:29:09

'(u) Universal sortable (invariant):

' . . . . . . . . . . . . . 2006-04-17 21:29:09Z

'(U) Universal full date/time: Montag, 17. April 2006 21:29:09 '(Y) Year: . . . . . . . . . . April 2006

'(o) Roundtrip (local):. . . . 2006-04-17T14:29:09.3011250-07:00 '(o) Roundtrip (UTC):. . . . . 2006-04-17T21:29:09.3011250Z '(o) Roundtrip (Unspecified):. 2000-03-20T13:02:03.0000000

rdlc报表的时间格式 关键字

FormatDateTime 类型

函数——日期和时间 示例表达式

=FormatDateTime(Fields!字段名.Value, DateFormat.ShortDate) =FormatDateTime(Fields!字段名.Value, vbShortDate) 备注

该函数用于返回表示日期/时间值的字符串表达式。 第二个参数为一个DateFormat枚举,枚举值列举如下—— 成员名称 说明

GeneralDate

对于实数,显示一个日期和时间。如果数字没有小数部分,则仅显示日期。如果数字没有整数部分,则仅显示时间。日期和时间显示由计算机的区域设置确定。该成员等效于 Visual Basic 常数 vbGeneralDate。 LongDate

使用在计算机的区域设置中指定的长日期格式显示日期。该成员等效于 Visual Basic 常数 vbLongDate。 LongTime

使用在计算机的区域设置中指定的长时间格式显示时间。该成员等效于 Visual Basic 常数 vbLongTime。 ShortDate

使用在计算机的区域设置中指定的短日期格式显示日期。该成员等效于 Visual Basic 常数 vbShortDate。 ShortTime

使用在计算机的区域设置中指定的短时间格式显示时间。该成员等效于 Visual Basic 常数 vbShortTime。

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- igat.cn 版权所有 赣ICP备2024042791号-1

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务