#region
|
|
using System;
|
using System.IO;
|
using CSFrameworkV5.Core;
|
using FastReport;
|
using FastReport.Export;
|
using FastReport.Export.Html;
|
using FastReport.Export.Image;
|
using FastReport.Export.Pdf;
|
using FastReport.Export.Xml;
|
|
#endregion
|
|
namespace CSFrameworkV5.Library
|
{
|
public enum ReportType
|
{
|
PrintDocument = 0,
|
PrintCheckList = 1
|
} //
|
|
public class ExportReportItem
|
{
|
public enum ExportType
|
{
|
IMG,
|
PDF,
|
XLS,
|
HTML
|
}
|
|
private ExportType _exportType;
|
|
private string _ItemCaption;
|
|
public ExportReportItem(string itemCaption, ExportType exportType)
|
{
|
_ItemCaption = itemCaption;
|
_exportType = exportType;
|
}
|
|
public string ExportToFile(Report report)
|
{
|
ExportBase export = null;
|
var fileName = Path.GetTempPath() + @"\_rpt" +
|
DateTime.Now.ToString("yyyyMMddhhmmss") + "_" +
|
Loginer.CurrentUser.Account;
|
|
if (ExportType.IMG == _exportType)
|
{
|
fileName = fileName + ".png";
|
export = new ImageExport();
|
(export as ImageExport).ImageFormat = ImageExportFormat.Png;
|
}
|
else if (ExportType.PDF == _exportType)
|
{
|
fileName = fileName + ".pdf";
|
export = new PDFExport();
|
}
|
else if (ExportType.XLS == _exportType)
|
{
|
fileName = fileName + ".xls";
|
export = new XMLExport();
|
}
|
else if (ExportType.HTML == _exportType)
|
{
|
fileName = fileName + ".html";
|
export = new HTMLExport();
|
}
|
|
if (export != null)
|
{
|
export.AllowOpenAfter = false;
|
report.Export(export, fileName);
|
}
|
|
return fileName;
|
}
|
|
public override string ToString()
|
{
|
return _ItemCaption;
|
}
|
}
|
|
public class ReportLib
|
{
|
public static void DesignReport(string file, bool isCreateNew)
|
{
|
var rpt = new Report();
|
if (isCreateNew)
|
{
|
rpt.Design(true);
|
}
|
else
|
{
|
rpt.Load(file);
|
rpt.Design(true);
|
}
|
}
|
}
|
}
|