/// <summary> /// 保存报表。 (目前把它当做,报表的导出功能来使用) /// </summary> /// <param name="pReport"></param> /// <returns></returns> public static bool Save(DIYReport.ReportModel.RptReport pReport) { System.Windows.Forms.SaveFileDialog fileDialog = new System.Windows.Forms.SaveFileDialog();; fileDialog.Filter = "报表文件 (*.rpt)|*.rpt"; fileDialog.FilterIndex = 1; fileDialog.RestoreDirectory = true; if (fileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { string filePath = fileDialog.FileName; _CurrentProcessFilePath = System.IO.Path.GetDirectoryName(filePath); if (filePath == null || filePath.Length == 0) { return(false); } bool b = System.IO.Directory.Exists(_CurrentProcessFilePath); if (!b) { System.IO.Directory.CreateDirectory(_CurrentProcessFilePath); } pReport.RptFilePath = filePath; XmlDocument doc = new XmlDocument(); try{ doc.LoadXml(ReportWriter.Instance().BuildXMLString(pReport)); doc.Save(filePath); //System.Windows.Forms.MessageBox.Show("报表导出成功!","导出报表操作提示",System.Windows.Forms.MessageBoxButtons.OK,System.Windows.Forms.MessageBoxIcon.Information); return(true); } catch (Exception e) { Debug.Assert(false, "报表存储出错!", e.Message); System.Windows.Forms.MessageBox.Show("报表导出失败!", "导出报表操作提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information); return(false); } } return(false); }
public static ReportWriter Instance() { if (_Writer == null) { _Writer = new ReportWriter(); } return(_Writer); }