100分求c#.net下水晶报表打印DataGrid的例子

abayo 2005-05-20 06:39:46
在线等...
...全文
169 2 打赏 收藏 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
newredhat 2005-05-29
  • 打赏
  • 举报
回复
晕,自己搞定
cnming 2005-05-24
  • 打赏
  • 举报
回复
水晶报表打印DataGrid?直接打印还是想打印dataGrid中的内容,如果是后者,我提供点代码你参考一下

DS = null;
DS = new System.Data.DataSet();

m_strSQL = "";
m_strSQL = m_strSQL + "SELECT CustomerID as CustomerID, CustomerName, Sex, CustomerSpell, Trademark, BalanceIntegral, CardNo, SortName, Address, Phone, IdentityID, Email AS Email, CardID as CardID";
m_strSQL = m_strSQL + " FROM T_Customer";
m_strSQL = m_strSQL + " WHERE (((IsUse)>=0))";
if(this.txtCustomerName.Text.Trim().Length > 0)
{
m_strSQL = m_strSQL + " And CustomerName like '%" + this.txtCustomerName.Text.Trim() + "%'";
}
if(this.txtTrademark.Text.Trim().Length > 0)
{
m_strSQL = m_strSQL + " And Trademark like '%" + this.txtTrademark.Text.Trim() + "%'";
}
if(this.txtCardNumber.Text.Trim().Length > 0)
{
m_strSQL = m_strSQL + " And CardNo like '%" + this.txtCardNumber.Text.Trim() + "%'";
}
m_strSQL = m_strSQL + " ORDER BY CustomerSpell";

ClassGlobe.conn.Open();
System.Data.OleDb.OleDbDataAdapter adapter = new System.Data.OleDb.OleDbDataAdapter(m_strSQL, ClassGlobe.conn);
adapter.Fill(DS, "T_Customer");
ClassGlobe.conn.Close();

//DS.WriteXml(@"d:\AutoClubCustomer.xml", System.Data.XmlWriteMode.WriteSchema);

rpt = null;
rpt = new rptQueryCustomer();
rpt.SetDataSource(DS);

this.crvQueryCustomer.ReportSource = rpt;



首先,把//DS.WriteXml(@"d:\AutoClubCustomer.xml", System.Data.XmlWriteMode.WriteSchema);
的注释去掉。
同时把
rpt = null;
rpt = new rptQueryCustomer();
rpt.SetDataSource(DS);

this.crvQueryCustomer.ReportSource = rpt;

注释起来,
然后运行一遍这些代码,你就会获得一个XML文件“d:\AutoClubCustomer.xml”

现在就可以新建一个空白报表了。假如取名为“rptQueryCustomer”
然后,添加/删除数据库,然后选择“更多数据源”--〉ADO.NET(XML),然后选择d:\AutoClubCustomer.xml,然后就有字段了,直接在报表上排列即可。


4,818

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 图表区
社区管理员
  • 图表区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧