用reportViewer 实现直接打印的功能

ad9329 2008-03-05 09:25:47
我想在用户看到报表的 同时 自动就把报表打印出来。
但查了下 reportViewer. 没有打印功能。
问问高手们。。。。。。如何实现。
...全文
3109 16 打赏 收藏 转发到动态 举报
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
kkk444dsfsa 2011-02-10
  • 打赏
  • 举报
回复
如果是server中的rdl呢 要怎么做?
w_p_ 2011-01-21
  • 打赏
  • 举报
回复
很好,支持一下~
lppcoding 2010-09-21
  • 打赏
  • 举报
回复

很好很强大,就是不知道怎么改那个字体的大小.
lppcoding 2010-09-21
  • 打赏
  • 举报
回复
多谢啊,这个问题也搞我半天,从来不留言的,特此感谢。
ch5201314zt 2009-08-21
  • 打赏
  • 举报
回复
谢谢楼主 解决一个大问题啊
lyl222 2009-02-03
  • 打赏
  • 举报
回复
不错~学习
shinaterry 2008-03-10
  • 打赏
  • 举报
回复
恭喜
ad9329 2008-03-10
  • 打赏
  • 举报
回复
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
System.Drawing.Imaging.Metafile pageImage = new System.Drawing.Imaging.Metafile(m_streams[m_currentPageIndex]);

e.Graphics.DrawImage(pageImage, 0,0);

m_currentPageIndex++;
e.HasMorePages = (m_currentPageIndex < m_streams.Count);
}
ad9329 2008-03-10
  • 打赏
  • 举报
回复
问题 解决 。。


Export(reportViewer1.LocalReport);
m_currentPageIndex = 0;


printDocument1.Print();
/// <summary>
/// 自动打印
/// </summary>
/// <param name="report"></param>
private void Export(LocalReport report)
{
string deviceInfo =
"<DeviceInfo>" +
" <OutputFormat>EMF</OutputFormat>" +
" <PageWidth>8.5in</PageWidth>" +
" <PageHeight>11in</PageHeight>" +
" <MarginTop>0.15in</MarginTop>" +
" <MarginLeft>0.1in</MarginLeft>" +
" <MarginRight>0.1in</MarginRight>" +
" <MarginBottom>0.1in</MarginBottom>" +
"</DeviceInfo>";
Warning[] warnings;
m_streams = new List<Stream>();
report.Render("Image", deviceInfo, CreateStream, out warnings);

foreach (Stream stream in m_streams)
stream.Position = 0;
}

private Stream CreateStream(string name, string fileNameExtension, Encoding encoding, string mimeType, bool willSeek)
{
Stream stream = new FileStream(name + "." + fileNameExtension,
FileMode.Create);
m_streams.Add(stream);
return stream;
}
ad9329 2008-03-07
  • 打赏
  • 举报
回复
或者 有什么报表控件 可以实现 自动打印
shinaterry 2008-03-06
  • 打赏
  • 举报
回复
-_-!!! 我在4楼说的已经是最好的建议, 要么你就改用其它...
ad9329 2008-03-06
  • 打赏
  • 举报
回复
就没人能给我个好的建议???????
shinaterry 2008-03-05
  • 打赏
  • 举报
回复
那你可以使用Reflector反编译ReportViewer查看打印(按钮)调用了什么方法, 然后再利用反射动态调用即可...
ad9329 2008-03-05
  • 打赏
  • 举报
回复
我现在 就是想把 点那一下的动作 用编程实现。
shinaterry 2008-03-05
  • 打赏
  • 举报
回复
^ō^ ReportViewer 不支持直接打印的! 改用其他报表控件...
yifuzhiming 2008-03-05
  • 打赏
  • 举报
回复
看到报表时,还要点一下打印才能行啊

110,571

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

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