| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2136 人关注过本帖
标题:c#打印报表可自定义表格样式,可分页打印
只看楼主 加入收藏
lukebc
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:3
帖 子:74
专家分:32
注 册:2009-8-18
结帖率:71.43%
收藏
 问题点数:0 回复次数:1 
c#打印报表可自定义表格样式,可分页打印
我是这么打印的,但是没有标题,也不能自定义表格样式
 private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {

            SqlConnection conn = new SqlConnection();
            conn.ConnectionString = "server=LUKE\\SQLEXPRESS;uid=sa;pwd=sa;database=luke";
            conn.Open();
            DataTable dt = new DataTable("resouce");
            dt.Clear();
            string sql = "";
            if (textBox1.Text == "" && textBox2.Text == "")
            {
                sql = "select * from text1";
                label1.Text = sql;
            }
            else
            {
                sql = "select * from text1 where bh like '%" + textBox1.Text + "%'";
                label1.Text = sql;
            }
            SqlDataAdapter adp = new SqlDataAdapter(sql, conn);
            adp.Fill(dt);
            dataGridView1.DataSource = dt.DefaultView;

            int r = 0;
            int c = 20;
            for (int i = 0; i < dt.Rows.Count; i++)
            {

                for (int j = 0; j < dt.Columns.Count; j++)
                {

                    e.Graphics.DrawString(dt.Rows[i][j].ToString(), new Font("宋体", 72, FontStyle.Regular), Brushes.Black, r, c);
                    r = r + 160;

                }
                r = 0;
                c += 200;

            }

谁能帮帮我
搜索更多相关主题的帖子: database private server 
2016-09-12 16:01
yhlvht
Rank: 13Rank: 13Rank: 13Rank: 13
等 级:贵宾
威 望:36
帖 子:707
专家分:4405
注 册:2011-9-30
收藏
得分:0 
都使用Graphics绘图了,绘数据之前自己绘制标题啊,样式也可以随意绘制啊,只是使用者不能自己定义,你可以预设几种样式让用户选择嘛
2016-09-12 20:26
快速回复:c#打印报表可自定义表格样式,可分页打印
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017231 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved