作者:mayz 来源:慧都控件网 浏览:Loading... 日期:2012-10-22
问题描述:
在StimulReports.Net报表条形码中使用国家标志
问题解答:
直接用8-bit编码.NET不是很方便,所以我们使用以下方法发送数据到条形码中,输入的条形码是一个Unicode字符串,这个字符串包含已经准备好的数据,然后条形码字符串被转换成一个字节数组,每个字符用(字节)st[index]命令 。
因此,我们有以下选项:
- Latin: pass string as is.
- bytes: convert to string, convert each byte of the command (char) byteArray [index].
- national characters: convert to the desired 8-bit code page, and then as a bytes array.
一个函数例子是将数据转换到需要的代码页面(您可以在报表设计器代码标签中插入一个报表):
[C#]
public string ToCodePage1251(string st)
{
byte[] bt = System.Text.Encoding.GetEncoding(1251).GetBytes(st);
System.Text.StringBuilder sb = new System.Text.StringBuilder();
for (int index = 0; index < bt.Length; index++)
{
sb.Append((char)bt[index]);
}
return sb.ToString();
}
Tag标签:.Net报表 Stimulsoft Reports.Net