⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 treereportexportfrm.cs

📁 树形逻辑报表程序源码,能根居元数据定义拖拉开发新的报表.
💻 CS
📖 第 1 页 / 共 2 页
字号:
			// lblHTMLTitle
			// 
			this.lblHTMLTitle.Location = new System.Drawing.Point(0, 0);
			this.lblHTMLTitle.Name = "lblHTMLTitle";
			this.lblHTMLTitle.TabIndex = 0;
			// 
			// btnHTMLFolder
			// 
			this.btnHTMLFolder.Location = new System.Drawing.Point(0, 0);
			this.btnHTMLFolder.Name = "btnHTMLFolder";
			this.btnHTMLFolder.TabIndex = 0;
			// 
			// lblHTMLFolder
			// 
			this.lblHTMLFolder.Location = new System.Drawing.Point(0, 0);
			this.lblHTMLFolder.Name = "lblHTMLFolder";
			this.lblHTMLFolder.TabIndex = 0;
			// 
			// txtHTMLFolder
			// 
			this.txtHTMLFolder.Location = new System.Drawing.Point(0, 0);
			this.txtHTMLFolder.Name = "txtHTMLFolder";
			this.txtHTMLFolder.TabIndex = 0;
			this.txtHTMLFolder.Text = "";
			// 
			// pictureBox1
			// 
			this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
			this.pictureBox1.Location = new System.Drawing.Point(88, 3);
			this.pictureBox1.Name = "pictureBox1";
			this.pictureBox1.Size = new System.Drawing.Size(80, 64);
			this.pictureBox1.TabIndex = 1;
			this.pictureBox1.TabStop = false;
			// 
			// pictureBox2
			// 
			this.pictureBox2.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox2.Image")));
			this.pictureBox2.Location = new System.Drawing.Point(183, 4);
			this.pictureBox2.Name = "pictureBox2";
			this.pictureBox2.Size = new System.Drawing.Size(64, 64);
			this.pictureBox2.TabIndex = 2;
			this.pictureBox2.TabStop = false;
			// 
			// pictureBox3
			// 
			this.pictureBox3.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox3.Image")));
			this.pictureBox3.Location = new System.Drawing.Point(272, 3);
			this.pictureBox3.Name = "pictureBox3";
			this.pictureBox3.Size = new System.Drawing.Size(40, 58);
			this.pictureBox3.TabIndex = 3;
			this.pictureBox3.TabStop = false;
			// 
			// groupBox1
			// 
			this.groupBox1.Controls.Add(this.pgExport);
			this.groupBox1.Location = new System.Drawing.Point(5, 104);
			this.groupBox1.Name = "groupBox1";
			this.groupBox1.Size = new System.Drawing.Size(432, 264);
			this.groupBox1.TabIndex = 13;
			this.groupBox1.TabStop = false;
			this.groupBox1.Text = "属性设置";
			// 
			// pgExport
			// 
			this.pgExport.CommandsVisibleIfAvailable = true;
			this.pgExport.Dock = System.Windows.Forms.DockStyle.Fill;
			this.pgExport.LargeButtons = false;
			this.pgExport.LineColor = System.Drawing.SystemColors.ScrollBar;
			this.pgExport.Location = new System.Drawing.Point(3, 17);
			this.pgExport.Name = "pgExport";
			this.pgExport.Size = new System.Drawing.Size(426, 244);
			this.pgExport.TabIndex = 13;
			this.pgExport.Text = "pg";
			this.pgExport.ToolbarVisible = false;
			this.pgExport.ViewBackColor = System.Drawing.SystemColors.Window;
			this.pgExport.ViewForeColor = System.Drawing.SystemColors.WindowText;
			// 
			// pictureBox4
			// 
			this.pictureBox4.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox4.Image")));
			this.pictureBox4.Location = new System.Drawing.Point(20, -4);
			this.pictureBox4.Name = "pictureBox4";
			this.pictureBox4.Size = new System.Drawing.Size(56, 68);
			this.pictureBox4.TabIndex = 4;
			this.pictureBox4.TabStop = false;
			// 
			// ExportForm
			// 
			this.AcceptButton = this.btnOK;
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.CancelButton = this.btnCancel;
			this.ClientSize = new System.Drawing.Size(442, 412);
			this.Controls.Add(this.groupBox1);
			this.Controls.Add(this.btnCancel);
			this.Controls.Add(this.btnOK);
			this.Controls.Add(this.lblExportFormat);
			this.Controls.Add(this.cboExportFormat);
			this.Controls.Add(this.pBanner);
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
			this.MaximizeBox = false;
			this.MinimizeBox = false;
			this.Name = "ExportForm";
			this.ShowInTaskbar = false;
			this.Text = "Tree报表输出";
			this.Load += new System.EventHandler(this.ExportForm_Load);
			this.pBanner.ResumeLayout(false);
			this.groupBox1.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion


		/// <summary>
		/// Show - 设置父窗体并显示
		/// </summary>
		/// <param name="parent"></param>
		public void Show(TreeReportDesignFrm parent)
		{
			this._Parent = parent;
			this.Show();
		}

		/// <summary>
		/// btnOK_Click - 基于用户设置输出
		/// </summary>
		private void btnOK_Click(object sender, System.EventArgs e)
		{
			try
			{
				this.Cursor = Cursors.WaitCursor;

				//选择了输出到Html
				if (this._exportComponent is ArExports.Html.HtmlExport)
				{
					string _filePath = this.PromptSaveFile("HTML Files", ".html");
					ArExports.Html.HtmlExport _html = this._exportComponent as ArExports.Html.HtmlExport;
					_html.Export(this.reportdocument, _filePath);
				}
				//选择了输出到PDF
				else if (this._exportComponent is ArExports.Pdf.PdfExport)
				{
					string _filePath = this.PromptSaveFile("Portable Document Format", ".pdf");
					ArExports.Pdf.PdfExport _pdf = this._exportComponent as ArExports.Pdf.PdfExport;
					_pdf.Export(this.reportdocument, _filePath);
				}
				//选择了输出到RTF 
				else if (this._exportComponent is ArExports.Rtf.RtfExport)
				{
					string _filePath = this.PromptSaveFile("Rich Text Format", ".rtf");
					ArExports.Rtf.RtfExport _rtf = this._exportComponent as ArExports.Rtf.RtfExport;
					_rtf.Export(this.reportdocument, _filePath);
				}
				//选择了输出到Text
				else if (this._exportComponent is ArExports.Text.TextExport)
				{
					string _filePath = this.PromptSaveFile("Plain Text Format", ".txt");
					ArExports.Text.TextExport _txt = this._exportComponent as ArExports.Text.TextExport;
					_txt.Export(this.reportdocument, _filePath);
				}
				//选择了输出到TIFF
				else if (this._exportComponent is ArExports.Tiff.TiffExport)
				{
					string _filePath = this.PromptSaveFile("TIFF Format", ".tiff");
					ArExports.Tiff.TiffExport _tiff = this._exportComponent as ArExports.Tiff.TiffExport;
					_tiff.Export(this.reportdocument, _filePath);
				}
				//选择了输出到Excel
				else if (this._exportComponent is ArExports.Xls.XlsExport)
				{
					string _filePath = this.PromptSaveFile("Excel File Format", ".xls");
					ArExports.Xls.XlsExport _xl = this._exportComponent as ArExports.Xls.XlsExport;
					_xl.Export(this.reportdocument, _filePath);
				}
				//选择了输出到RDF
				else if (this._exportComponent is RdfDocumentSettings)
				{
					string _filePath = this.PromptSaveFile("ActiveReports Document", ".rdf");
					DataDynamics.ActiveReports.Document.Document _doc = this.reportdocument;
					if (_doc == null)
						return;
					_doc.Save(_filePath, ((RdfDocumentSettings)this._exportComponent).RdfVersion);
				}
			}
			catch (UserCanceledDialogException )
			{
				return;
			}
			catch (System.IO.IOException eExport)
			{
				System.Diagnostics.Debug.WriteLine(eExport.ToString());

				MessageBox.Show(this, "在输出过程中发生了一个错误,窗口将关闭.", "输出错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
				//MessageBox.Show(this, "An Error occured during the export.  This window will be closed.", "Export Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
				this.Close();
			}
			catch (DataDynamics.ActiveReports.ReportException exExport)
			{
				System.Diagnostics.Debug.WriteLine(exExport.ToString());

				MessageBox.Show(this, "在输出过程中发生了一个错误,窗口将关闭.", "输出错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
				//MessageBox.Show(this, "An Error occured during the export.  This window will be closed.", "Export Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
				this.Close();
			}
			finally
			{
				this.Cursor = Cursors.Default;
				this.Close();
			}
		}


		/// <summary>
		/// UserCanceledDialogException - 如果保存文件窗体被取消,抛出此exception
		/// </summary>
		class UserCanceledDialogException:System.ApplicationException
		{
			public UserCanceledDialogException()
			{
			}
		}

		/// <summary>
		/// PropertSaveFile - 显示保存文档的对话框
		/// </summary>
		/// <param name="caption">Caption:对话框标题</param>
		/// <param name="fileExtension">文件扩展名</param>
		/// <returns>文件全名称</returns>
		private string PromptSaveFile(string caption, string fileExtension)
		{
			// 例如: "Portable Document Format (PDF) (*.pdf)|*.pdf";
			string filterTemplate = "{0} (*{1})|*{1}";

			this.dlgSaveFile.Filter = string.Format(System.Globalization.CultureInfo.CurrentCulture, filterTemplate, caption, fileExtension);
			this.dlgSaveFile.FileName = "Report" + fileExtension;
			this.dlgSaveFile.FilterIndex = 0;
			this.dlgSaveFile.RestoreDirectory = true ;
			this.dlgSaveFile.DefaultExt = fileExtension;
			
			if(dlgSaveFile.ShowDialog() == DialogResult.OK)
			{
				return this.dlgSaveFile.FileName;
			}
			else
				throw new UserCanceledDialogException();
		}

		/// <summary>
		/// cboExportFormat_SelectedIndexChanged - 选择输出的格式
		/// </summary>
		private void cboExportFormat_SelectedIndexChanged(object sender, System.EventArgs e)
		{
			switch(this.cboExportFormat.SelectedItem.ToString())
			{
				case "Text":  
				{
					this._exportComponent = new DataDynamics.ActiveReports.Export.Text.TextExport();
					break;
				}
				case "Portable Document Format (PDF)": 
				{
					this._exportComponent = new DataDynamics.ActiveReports.Export.Pdf.PdfExport();
					break;
				}
				case "Rich Text Format (RTF)":  
				{
					this._exportComponent = new DataDynamics.ActiveReports.Export.Rtf.RtfExport();
                    break;
				}
				case "Microsoft Excel WorkSheet (XLS)":  
				{
					this._exportComponent = new DataDynamics.ActiveReports.Export.Xls.XlsExport();
					break;
				}
				case "HTML":  
				{
					this._exportComponent = new DataDynamics.ActiveReports.Export.Html.HtmlExport();
					break;
				}
				case "Tagged Image File Format (TIFF)":  
				{
					this._exportComponent = new DataDynamics.ActiveReports.Export.Tiff.TiffExport();
					break;
				}
				case "ActiveReport Document Format (RDF)": 
				{
					this._exportComponent = new RdfDocumentSettings();
					break;
				}
			}

			this.pgExport.SelectedObject = this._exportComponent;
		}

		/// <summary>
		/// 当保存到RDF时,需要此函数
		/// </summary>
		class RdfDocumentSettings
		{
			private RdfFormat rdfVersion;
			
			/// <summary>
			/// RdfDocumentSettings - 设置版本
			/// </summary>
			public RdfDocumentSettings()
			{
				rdfVersion = RdfFormat.ARNet;
			}

			
			public DataDynamics.ActiveReports.Document.RdfFormat RdfVersion
			{
				get
				{
					return this.rdfVersion;
				}
				set
				{
					this.rdfVersion = value;
				}
			}
		}

		/// <summary>
		/// btnCancel_Click - 取消退出对话框
		/// </summary>
		private void btnCancel_Click(object sender, System.EventArgs e)
		{
			this.Close();
		}

		private void ExportForm_Load(object sender, System.EventArgs e)
		{
			this.cboExportFormat.SelectedIndex = 0;
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -