




下載本文檔
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
本文格式為Word版,下載可任意編輯——WinFormVS2023下ReportViewer的自動打印原碼WinForm+VS2023下ReportViewer的自動打印原碼
usingSystem;
usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Text;
usingSystem.Windows.Forms;usingControlLib;
usingSystem.Drawing.Printing;
usingMicrosoft.Reporting.WinForms;usingSystem.IO;
usingSystem.Drawing.Imaging;
namespaceReportLib{
publicpartialclassCrystalForm:Form{
privatestring_reportname=\;privateDataSet_datasource=null;privatestring_autoprint=\;privateIListm_streams;privateintm_currentPageIndex;
publicCrystalForm(stringreportname,DataSetdatasource,stringp1){
_reportname=reportname;_datasource=datasource;_autoprint=p1;
InitializeComponent();}
privatevoidCrystalForm_Load(objectsender,EventArgse){
this.reportViewer1.LocalReport.ReportEmbeddedResource=_reportname;this.reportViewer1.LocalReport.DataSources.Clear();if(_datasource!=null){foreach(DataTabletablein_datasource.Tables){this.reportViewer1.LocalReport.DataSources.Add(newMicrosoft.Reporting.WinForms.ReportDataSource(table.TableName,table));}}
this.reportViewer1.RefreshReport();if(_autoprint==\){
PPrint();}}
#region報表自打印publicvoidPPrint(){
try{LocalReportreport=this.reportViewer1.LocalReport;Export(report);m_currentPageIndex=0;NBPrint();if(m_streams!=null){foreach(Streamstreaminm_streams)stream.Close();m_streams=null;}}
catch(Exceptionex){MessageBox.Show(\在打印過程中出現(xiàn)異常!\+ex.Message.ToString());}}
privatevoidExport(LocalReportreport){
//7.5in3.66in0000當(dāng)前設(shè)置為A4縱向stringdeviceInfo=\+
\EMF\+\20.7cm\+\28cm\+\0in\+\0in\+\0in\+\0in\+\;Warning[]warnings;
m_streams=newList();
report.Render(\,deviceInfo,CreateStream,outwarnings);
foreach(Streamstreaminm_streams){stream.Position=0;}}
privatevoidNBPrint(){
if(m_streams==null||m_streams.Count==0)return;
PrintDocumentprintDoc=newPrintDocument();
if(!printDoc.PrinterSettings.IsValid){stringmsg=String.Format(\,\默認打印機!\);MessageBox.Show(msg,\找不到默認打印機\);return;}
printDoc.PrintPage+=newPrintPageEventHandler(PrintPage);printDoc.Print();this.Close();}
privateStreamCreateStream(stringname,stringfileNameExtension,Encodingencoding,stringmimeType,boolwillSeek){
stringfilenameext=DateTime.Now.Year.ToString()+DateTime.Now.Day.ToString()+DateTime.Now.Month.ToString()+DateTime.Now.Hour.ToString()+DateTime.Now.Minute.ToString()+DateTime.Now.Second.ToString();Streamstream=newFileStream(name+\+fileNameExtension,FileMode.Create);m_streams.Add(stream);returnstream;}
privatevoidPrintPage(objectsender,PrintPageEventArgsev){
Metafilep
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 豫章師范學(xué)院《油畫靜物技法與表現(xiàn)》2023-2024學(xué)年第二學(xué)期期末試卷
- 珠海格力職業(yè)學(xué)院《藏文文法上》2023-2024學(xué)年第二學(xué)期期末試卷
- 遼寧石化職業(yè)技術(shù)學(xué)院《語文學(xué)科教育論》2023-2024學(xué)年第二學(xué)期期末試卷
- 西安歐亞學(xué)院《數(shù)據(jù)分析與可視化》2023-2024學(xué)年第二學(xué)期期末試卷
- 南京工業(yè)大學(xué)《建筑防火設(shè)計》2023-2024學(xué)年第二學(xué)期期末試卷
- 西安科技大學(xué)高新學(xué)院《汽車發(fā)展史》2023-2024學(xué)年第二學(xué)期期末試卷
- 遼寧工程技術(shù)大學(xué)《資產(chǎn)評估學(xué)》2023-2024學(xué)年第二學(xué)期期末試卷
- 四川航天職業(yè)技術(shù)學(xué)院《嵌入式系統(tǒng)設(shè)計與開發(fā)》2023-2024學(xué)年第二學(xué)期期末試卷
- 合肥信息技術(shù)職業(yè)學(xué)院《建筑類專業(yè)導(dǎo)論》2023-2024學(xué)年第二學(xué)期期末試卷
- 南華大學(xué)船山學(xué)院《素描半身帶手及全身像實踐教學(xué)》2023-2024學(xué)年第二學(xué)期期末試卷
- 美團外賣騎手服務(wù)合同(2025年度)
- 應(yīng)急預(yù)案解讀與實施
- 2025年《國有企業(yè)領(lǐng)導(dǎo)人員腐敗案例剖析》心得體會樣本(3篇)
- 廣告行業(yè)安全培訓(xùn)詳細介紹
- 2024-2029年全球及中國氨能源(綠氨)應(yīng)用可行性研究與投資戰(zhàn)略規(guī)劃分析報告
- 2025福南平市建武夷水務(wù)發(fā)展限公司招聘21人高頻重點提升(共500題)附帶答案詳解
- 2025年上半年工業(yè)和信息化部裝備工業(yè)發(fā)展中心應(yīng)屆畢業(yè)生招聘(第二批)易考易錯模擬試題(共500題)試卷后附參考答案
- 2025年中遠海運物流有限公司招聘筆試參考題庫含答案解析
- 2024年廣州市海珠區(qū)衛(wèi)生健康系統(tǒng)招聘事業(yè)單位工作人員筆試真題
- 一科一品一骨科護理
- 加氣站安全培訓(xùn)課件
評論
0/150
提交評論