水晶报表动态加载磁盘图片
来源:互联网 发布:vb6.0编程实例 编辑:程序博客网 时间:2024/05/01 00:14
1、首先,我们先创建一个DataSet.xsd文件,如下图所示,这是一个表
2、查看此表的代码,注意字段LIMG的数据类型为base64Binary。
<?xml version="1.0" encoding="utf-8"?><xs:schema id="DataSet8" targetNamespace="http://tempuri.org/DataSet8.xsd" xmlns:mstns="http://tempuri.org/DataSet8.xsd" xmlns="http://tempuri.org/DataSet8.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:msprop="urn:schemas-microsoft-com:xml-msprop" attributeFormDefault="qualified" elementFormDefault="qualified"> <xs:annotation> <xs:appinfo source="urn:schemas-microsoft-com:xml-msdatasource"> <DataSource DefaultConnectionIndex="0" FunctionsComponentName="QueriesTableAdapter" Modifier="AutoLayout, AnsiClass, Class, Public" SchemaSerializationMode="IncludeSchema" xmlns="urn:schemas-microsoft-com:xml-msdatasource"> <Connections> </Connections> <Tables> </Tables> <Sources> </Sources> </DataSource> </xs:appinfo> </xs:annotation> <xs:element name="DataSet8" msdata:IsDataSet="true" msdata:UseCurrentLocale="true" msprop:Generator_UserDSName="DataSet8" msprop:Generator_DataSetName="DataSet8"> <xs:complexType> <xs:choice minOccurs="0" maxOccurs="unbounded"> <xs:element name="BoxLabelTable" msprop:Generator_UserTableName="BoxLabelTable" msprop:Generator_RowDeletedName="BoxLabelTableRowDeleted" msprop:Generator_RowChangedName="BoxLabelTableRowChanged" msprop:Generator_RowClassName="BoxLabelTableRow" msprop:Generator_RowChangingName="BoxLabelTableRowChanging" msprop:Generator_RowEvArgName="BoxLabelTableRowChangeEvent" msprop:Generator_RowEvHandlerName="BoxLabelTableRowChangeEventHandler" msprop:Generator_TableClassName="BoxLabelTableDataTable" msprop:Generator_TableVarName="tableBoxLabelTable" msprop:Generator_RowDeletingName="BoxLabelTableRowDeleting" msprop:Generator_TablePropName="BoxLabelTable"> <xs:complexType> <xs:sequence> <xs:element name="LIMG" msprop:Generator_UserColumnName="LIMG" msprop:Generator_ColumnPropNameInRow="LIMG" msprop:Generator_ColumnVarNameInTable="columnLIMG" msprop:Generator_ColumnPropNameInTable="LIMGColumn" type="xs:base64Binary" minOccurs="0" /> <xs:element name="SCIMG" msprop:Generator_UserColumnName="SCIMG" msprop:Generator_ColumnVarNameInTable="columnSCIMG" msprop:Generator_ColumnPropNameInRow="SCIMG" msprop:Generator_ColumnPropNameInTable="SCIMGColumn" type="xs:string" minOccurs="0" /> <xs:element name="PO" msprop:Generator_UserColumnName="PO" msprop:Generator_ColumnVarNameInTable="columnPO" msprop:Generator_ColumnPropNameInRow="PO" msprop:Generator_ColumnPropNameInTable="POColumn" type="xs:string" minOccurs="0" /> <xs:element name="ITEMNO" msprop:Generator_UserColumnName="ITEMNO" msprop:Generator_ColumnVarNameInTable="columnITEMNO" msprop:Generator_ColumnPropNameInRow="ITEMNO" msprop:Generator_ColumnPropNameInTable="ITEMNOColumn" type="xs:string" minOccurs="0" /> <xs:element name="QTY" msprop:Generator_UserColumnName="QTY" msprop:Generator_ColumnVarNameInTable="columnQTY" msprop:Generator_ColumnPropNameInRow="QTY" msprop:Generator_ColumnPropNameInTable="QTYColumn" type="xs:decimal" minOccurs="0" /> <xs:element name="NW" msprop:Generator_UserColumnName="NW" msprop:Generator_ColumnVarNameInTable="columnNW" msprop:Generator_ColumnPropNameInRow="NW" msprop:Generator_ColumnPropNameInTable="NWColumn" type="xs:decimal" minOccurs="0" /> <xs:element name="GW" msprop:Generator_UserColumnName="GW" msprop:Generator_ColumnVarNameInTable="columnGW" msprop:Generator_ColumnPropNameInRow="GW" msprop:Generator_ColumnPropNameInTable="GWColumn" type="xs:decimal" minOccurs="0" /> <xs:element name="MEAS" msprop:Generator_UserColumnName="MEAS" msprop:Generator_ColumnVarNameInTable="columnMEAS" msprop:Generator_ColumnPropNameInRow="MEAS" msprop:Generator_ColumnPropNameInTable="MEASColumn" type="xs:string" minOccurs="0" /> <xs:element name="CARTONNO" msprop:Generator_UserColumnName="CARTONNO" msprop:Generator_ColumnVarNameInTable="columnCARTONNO" msprop:Generator_ColumnPropNameInRow="CARTONNO" msprop:Generator_ColumnPropNameInTable="CARTONNOColumn" type="xs:string" minOccurs="0" /> </xs:sequence> </xs:complexType> </xs:element> </xs:choice> </xs:complexType> </xs:element></xs:schema>
3、填充DataSet.xsd数据,关键代码如下:注意本案例中的DataSet.xsd的文件名为DataSet8
DataSet8 ds8 = new DataSet8();object[] objs ={ReadImages(), Request.QueryString["SCIMG"],Request.QueryString["PO"],Request.QueryString["ITEMNO"], Request.QueryString["QTY"],Request.QueryString["NW"],Request.QueryString["GW"],Request.QueryString["MEAS"]}; ds8.Tables["BoxLabelTable"].Rows.Add(objs);//注意此名字必须是本例步骤1中DataSet的表名
4、读取磁盘中的图片
private byte[] ReadImages() { string[] dir = Directory.GetFiles(Server.MapPath(@"~/Upload/BoxLabel/")); byte[] photo = null; foreach (string img in dir) { string imgPath = Path.GetFileName(img); if (imgPath.IndexOf(Request.QueryString["SCIMG"]) > -1) { FileStream fs = new FileStream(img, FileMode.Open, FileAccess.Read); BinaryReader br = new BinaryReader(fs); photo = br.ReadBytes((int)fs.Length); br.Close(); fs.Close(); } } return photo; }
5、我们转到水晶报表中的设置,如图所示:
6、大功告成,让我们看看显示的效果
注意:本报表使用的是CrystalReport10,即VS2005自带的水晶报表
本文参考:http://www.cnblogs.com/babyt/archive/2005/04/21/142789.html
1 0
- 水晶报表动态加载磁盘图片
- 水晶报表中如何动态加载图片
- [水晶报表]动态加载图片(签名)
- 水晶报表图片动态加载的另一种简单方案
- 水晶报表动态加载字段
- 水晶报表中动态加载报表字段
- 解决水晶报表中动态加载的图片或利用水晶报表创建的图表不显示图片的方法
- 【水晶报表之图片篇-a】 动态加载图片(图片文件版本及数据库版本)
- 【水晶报表之图片篇-a】 动态加载图片(图片文件版本及数据库版本)
- 水晶报表中如何动态加载图片时显示不了图片的可能原因之一
- 水晶报表中如何动态加载图片(图片文件版本及数据库版本)
- 水晶报表中加载本地图片
- 水晶报表加载本地图片 【BY阿泰】
- 水晶报表中显示动态图片
- 水晶报表 动态批量打印本地图片
- 【水晶报表之图片篇-c】 CR 11版本动态加载的另一种简单方案
- 水晶报表加载失败
- 水晶报表加载失败
- hibernate缓存机制详细分析
- 再谈表格的处理,附加人工,运费,辅材一并乘以一个系数
- Apache Geode/GemFire 数据分区和路由机制浅析
- 宏定义字符串处理
- 13.Roman to Integer
- 水晶报表动态加载磁盘图片
- PHP判断post或get的值是否为小数或者整数
- Nginx区分PC或手机访问不同网站
- Swift03-变量的声明及使用
- Android之给控件添加标签(类似右上角消息提醒数字)
- java多线程内存可见性分析
- 管道的数据结构及容量验证
- GemFire 异步写和同步读
- 存在“网站“被拖库””风险,安全性降低40% [高危] MongoDB未授权访问 -- 360网站安全漏洞