using FastReport.Export.Csv;
using FastReport.Export.Dbf;
using FastReport.Export.Html;
using FastReport.Export.Mht;
using FastReport.Export.Odf;
using FastReport.Export.OoXML;
using FastReport.Export.Pdf;
using FastReport.Export.RichText;
using FastReport.Export.Text;
using FastReport.Export.Xml;
using System;
using System.ComponentModel;
using System.IO;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace FastReport.Web
{
public partial class WebReport : WebControl, INamingContainer
{
#region RTF format
///
/// Switches a visibility of RTF export in toolbar.
///
[DefaultValue(true)]
[Category("Toolbar")]
[Browsable(true)]
public bool ShowRtfExport
{
get { return Prop.ShowRtfExport; }
set { Prop.ShowRtfExport = value; }
}
///
/// Gets or sets the quality of Jpeg images in RTF file.
///
///
/// Default value is 90. This property will be used if you select Jpeg
/// in the property.
///
[DefaultValue(90)]
[Category("Rtf Format")]
[Browsable(true)]
public int RtfJpegQuality
{
get { return Prop.RtfJpegQuality; }
set { Prop.RtfJpegQuality = value; }
}
///
/// Gets or sets the image format that will be used to save pictures in RTF file.
///
///
/// Default value is Metafile. This format is better for exporting such objects as
/// MSChartObject and ShapeObject.
///
[DefaultValue(RTFImageFormat.Metafile)]
[Category("Rtf Format")]
[Browsable(true)]
public RTFImageFormat RtfImageFormat
{
get { return Prop.RtfImageFormat; }
set { Prop.RtfImageFormat = value; }
}
///
/// Gets or sets a value indicating that pictures are enabled.
///
[DefaultValue(true)]
[Category("Rtf Format")]
[Browsable(true)]
public bool RtfPictures
{
get { return Prop.RtfPictures; }
set { Prop.RtfPictures = value; }
}
///
/// Gets or sets a value indicating that page breaks are enabled.
///
[DefaultValue(true)]
[Category("Rtf Format")]
[Browsable(true)]
public bool RtfPageBreaks
{
get { return Prop.RtfPageBreaks; }
set { Prop.RtfPageBreaks = value; }
}
///
/// Gets or sets a value that determines whether the wysiwyg mode should be used
/// for better results.
///
[DefaultValue(true)]
[Category("Rtf Format")]
[Browsable(true)]
public bool RtfWysiwyg
{
get { return Prop.RtfWysiwyg; }
set { Prop.RtfWysiwyg = value; }
}
///
/// Gets or sets the creator of the document.
///
[DefaultValue("FastReport")]
[Category("Rtf Format")]
[Browsable(true)]
public string RtfCreator
{
get { return Prop.RtfCreator; }
set { Prop.RtfCreator = value; }
}
///
/// Gets or sets a value that determines whether the rows in the resulting table
/// should calculate its height automatically.
///
[DefaultValue(false)]
[Category("Rtf Format")]
[Browsable(true)]
public bool RtfAutoSize
{
get { return Prop.RtfAutoSize; }
set { Prop.RtfAutoSize = value; }
}
#endregion RTF format
#region MHT format
///
/// Switches a visibility of MHT (web-archive) export in toolbar.
///
[DefaultValue(true)]
[Category("Toolbar")]
[Browsable(true)]
public bool ShowMhtExport
{
get { return Prop.ShowMhtExport; }
set { Prop.ShowMhtExport = value; }
}
///
/// Gets or sets a value indicating that pictures are enabled.
///
[DefaultValue(true)]
[Category("Mht Format")]
[Browsable(true)]
public bool MhtPictures
{
get { return Prop.MhtPictures; }
set { Prop.MhtPictures = value; }
}
///
/// Gets or sets a value that determines whether the wysiwyg mode should be used
/// for better results.
///
[DefaultValue(true)]
[Category("Mht Format")]
[Browsable(true)]
public bool MhtWysiwyg
{
get { return Prop.MhtWysiwyg; }
set { Prop.MhtWysiwyg = value; }
}
#endregion MHT format
#region ODS format
///
/// Switches a visibility of Open Office Spreadsheet (ODS) export in toolbar.
///
[DefaultValue(true)]
[Category("Toolbar")]
[Browsable(true)]
public bool ShowOdsExport
{
get { return Prop.ShowOdsExport; }
set { Prop.ShowOdsExport = value; }
}
///
/// Gets or sets a value indicating that page breaks are enabled.
///
[DefaultValue(true)]
[Category("Ods Format")]
[Browsable(true)]
public bool OdsPageBreaks
{
get { return Prop.OdsPageBreaks; }
set { Prop.OdsPageBreaks = value; }
}
///
/// Gets or sets a value that determines whether the wysiwyg mode should be used
/// for better results.
///
[DefaultValue(true)]
[Category("Ods Format")]
[Browsable(true)]
public bool OdsWysiwyg
{
get { return Prop.OdsWysiwyg; }
set { Prop.OdsWysiwyg = value; }
}
///
/// Gets or sets the creator of the document.
///
[DefaultValue("FastReport")]
[Category("Ods Format")]
[Browsable(true)]
public string OdsCreator
{
get { return Prop.OdsCreator; }
set { Prop.OdsCreator = value; }
}
#endregion ODS format
#region ODT format
///
/// Switches a visibility of Open Office Text (ODT) export in toolbar
///
[DefaultValue(true)]
[Category("Toolbar")]
[Browsable(true)]
public bool ShowOdtExport
{
get { return Prop.ShowOdtExport; }
set { Prop.ShowOdtExport = value; }
}
///
/// Gets or sets a value indicating that page breaks are enabled.
///
[DefaultValue(true)]
[Category("Odt Format")]
[Browsable(true)]
public bool OdtPageBreaks
{
get { return Prop.OdtPageBreaks; }
set { Prop.OdtPageBreaks = value; }
}
///
/// Gets or sets a value that determines whether the wysiwyg mode should be used
/// for better results.
///
[DefaultValue(true)]
[Category("Odt Format")]
[Browsable(true)]
public bool OdtWysiwyg
{
get { return Prop.OdtWysiwyg; }
set { Prop.OdtWysiwyg = value; }
}
///
/// Gets or sets the creator of the document.
///
[DefaultValue("FastReport")]
[Category("Odt Format")]
[Browsable(true)]
public string OdtCreator
{
get { return Prop.OdtCreator; }
set { Prop.OdtCreator = value; }
}
#endregion ODT format
#region XPS format
///
/// Switches a visibility of XPS export in toolbar.
///
[DefaultValue(true)]
[Category("Toolbar")]
[Browsable(true)]
public bool ShowXpsExport
{
get { return Prop.ShowXpsExport; }
set { Prop.ShowXpsExport = value; }
}
#endregion XPS format
#region DBF format
///
/// Switches a visibility of DBF export in toolbar.
///
[DefaultValue(true)]
[Category("Toolbar")]
[Browsable(true)]
public bool ShowDbfExport
{
get { return Prop.ShowDbfExport; }
set { Prop.ShowDbfExport = value; }
}
#endregion DBF format
#region Word2007 format
///
/// Switches a visibility of Word 2007 export in toolbar.
///
[DefaultValue(true)]
[Category("Toolbar")]
[Browsable(true)]
public bool ShowWord2007Export
{
get { return Prop.ShowWord2007Export; }
set { Prop.ShowWord2007Export = value; }
}
///
/// Enable or disable a matrix view of Word 2007 document.
///
[DefaultValue(true)]
[Category("Word 2007 Format")]
[Browsable(true)]
public bool DocxMatrixBased
{
get { return Prop.DocxMatrixBased; }
set { Prop.DocxMatrixBased = value; }
}
///
/// Enable or disable the WYSIWYG for Word 2007 document.
///
[DefaultValue(true)]
[Category("Word 2007 Format")]
[Browsable(true)]
public bool DocxWysiwyg
{
get { return Prop.DocxWysiwyg; }
set { Prop.DocxWysiwyg = value; }
}
///
/// Enable or disable a paragraph view of Word 2007 document.
///
[DefaultValue(false)]
[Category("Word 2007 Format")]
[Browsable(true)]
public bool DocxParagraphBased
{
get { return Prop.DocxParagraphBased; }
set { Prop.DocxParagraphBased = value; }
}
///
/// Enable or disable the print optimized images in Word 2007 document.
///
[DefaultValue(false)]
[Category("Word 2007 Format")]
[Browsable(true)]
public bool DocxPrintOptimized
{
get { return Prop.DocxPrintOptimized; }
set { Prop.DocxPrintOptimized = value; }
}
///
/// Gets or sets a value of RowHeightIs Word 2007 document.
///
[DefaultValue("")]
[Category("Word 2007 Format")]
[Browsable(true)]
public string DocxRowHeightIs
{
get { return Prop.DocxRowHeightIs; }
set { Prop.DocxRowHeightIs = value; }
}
#endregion Word2007 format
#region Excel2007 format
///
/// Switches a visibility of Excel 2007 export in toolbar.
///
[DefaultValue(true)]
[Category("Toolbar")]
[Browsable(true)]
public bool ShowExcel2007Export
{
get { return Prop.ShowExcel2007Export; }
set { Prop.ShowExcel2007Export = value; }
}
///
/// Gets or sets a value indicating that page breaks are enabled.
///
[DefaultValue(false)]
[Category("Excel 2007 Format")]
[Browsable(true)]
public bool XlsxPageBreaks
{
get { return Prop.XlsxPageBreaks; }
set { Prop.XlsxPageBreaks = value; }
}
///
/// Gets or sets a value indicating that table without breaks are enabled.
///
[DefaultValue(false)]
[Category("Excel 2007 Format")]
[Browsable(true)]
public bool XlsxSeamless
{
get { return Prop.XlsxSeamless; }
set { Prop.XlsxSeamless = value; }
}
///
/// Enable or disable the print optimized images in Excel 2007 document.
///
[DefaultValue(false)]
[Category("Excel 2007 Format")]
[Browsable(true)]
public bool XlsxPrintOptimized
{
get { return Prop.XlsxPrintOptimized; }
set { Prop.XlsxPrintOptimized = value; }
}
///
/// Enable or disable the Print Fit in Excel 2007 document.
///
[DefaultValue(false)]
[Category("Excel 2007 Format")]
[Browsable(true)]
public bool XlsxPrintFitPage
{
get { return Prop.XlsxPrintFitPage; }
set { Prop.XlsxPrintFitPage = value; }
}
///
/// Gets or sets a value that determines whether the wysiwyg mode should be used
/// for better results.
///
[DefaultValue(true)]
[Category("Excel 2007 Format")]
[Browsable(true)]
public bool XlsxWysiwyg
{
get { return Prop.XlsxWysiwyg; }
set { Prop.XlsxWysiwyg = value; }
}
///
/// Enable or disable an exporting data without any header/group bands.
///
[DefaultValue(true)]
[Category("Excel 2007 Format")]
[Browsable(true)]
public bool XlsxDataOnly
{
get { return Prop.XlsxDataOnly; }
set { Prop.XlsxDataOnly = value; }
}
///
/// Enable or disable the Print Fit in Excel 2007 document.
///
[DefaultValue(false)]
[Category("Excel 2007 Format")]
[Browsable(true)]
public bool XlsxGroupOnSeparateSheet
{
get { return Prop.XlsxGroupOnSeparateSheet; }
set { Prop.XlsxGroupOnSeparateSheet = value; }
}
#endregion Excel2007 format
#region PowerPoint2007 format
///
/// Switches a visibility of PowerPoint 2007 export in toolbar.
///
[DefaultValue(true)]
[Category("Toolbar")]
[Browsable(true)]
public bool ShowPowerPoint2007Export
{
get { return Prop.ShowPowerPoint2007Export; }
set { Prop.ShowPowerPoint2007Export = value; }
}
///
/// Gets or sets an image format that will be used to save pictures in PowerPoint file.
///
[DefaultValue(PptImageFormat.Png)]
[Category("PowerPoint 2007 Format")]
[Browsable(true)]
public PptImageFormat PptxImageFormat
{
get { return Prop.PptxImageFormat; }
set { Prop.PptxImageFormat = value; }
}
#endregion PowerPoint2007 format
#region XML format
///
/// Switches a visibility of XML (Excel) export in toolbar.
///
[DefaultValue(true)]
[Category("Toolbar")]
[Browsable(true)]
public bool ShowXmlExcelExport
{
get { return Prop.ShowXmlExcelExport; }
set { Prop.ShowXmlExcelExport = value; }
}
///
/// Gets or sets a value indicating that page breaks are enabled.
///
[DefaultValue(true)]
[Category("Xml Excel Format")]
[Browsable(true)]
public bool XmlExcelPageBreaks
{
get { return Prop.XmlExcelPageBreaks; }
set { Prop.XmlExcelPageBreaks = value; }
}
///
/// Gets or sets a value that determines whether the wysiwyg mode should be used
/// for better results.
///
[DefaultValue(true)]
[Category("Xml Excel Format")]
[Browsable(true)]
public bool XmlExcelWysiwyg
{
get { return Prop.XmlExcelWysiwyg; }
set { Prop.XmlExcelWysiwyg = value; }
}
///
/// Enable or disable an exporting data without any header/group bands.
///
[DefaultValue(false)]
[Category("Xml Excel Format")]
[Browsable(true)]
public bool XmlExcelDataOnly
{
get { return Prop.XmlExcelDataOnly; }
set { Prop.XmlExcelDataOnly = value; }
}
#endregion XML format
#region PDF format
///
/// Switches a visibility of PDF (Adobe Acrobat) export in toolbar.
///
[DefaultValue(true)]
[Category("Toolbar")]
[Browsable(true)]
public bool ShowPdfExport
{
get { return Prop.ShowPdfExport; }
set { Prop.ShowPdfExport = value; }
}
///
/// Enable or disable an embedding the TrueType fonts.
///
[DefaultValue(true)]
[Category("Pdf Format")]
[Browsable(true)]
public bool PdfEmbeddingFonts
{
get { return Prop.PdfEmbeddingFonts; }
set { Prop.PdfEmbeddingFonts = value; }
}
///
/// Enable or disable an export text in curves.
///
[DefaultValue(false)]
[Category("Pdf Format")]
[Browsable(true)]
public bool PdfTextInCurves
{
get { return Prop.PdfTextInCurves; }
set { Prop.PdfTextInCurves = value; }
}
///
/// Enable or disable an exporting of the background in PDF.
///
[DefaultValue(true)]
[Category("Pdf Format")]
[Browsable(true)]
public bool PdfBackground
{
get { return Prop.PdfBackground; }
set { Prop.PdfBackground = value; }
}
///
/// Enable or disable the Intercative Forms inside PDF.
///
[DefaultValue(false)]
[Category("Pdf Format")]
[Browsable(true)]
public bool PdfInteractiveForms
{
get { return Prop.PdfInteractiveForms; }
set { Prop.PdfInteractiveForms = value; }
}
///
/// Enable or disable an optimization the images for printing.
///
[DefaultValue(true)]
[Category("Pdf Format")]
[Browsable(true)]
public bool PdfPrintOptimized
{
get { return Prop.PdfPrintOptimized; }
set { Prop.PdfPrintOptimized = value; }
}
///
/// Enable or disable a document's Outline.
///
[DefaultValue(true)]
[Category("Pdf Format")]
[Browsable(true)]
public bool PdfOutline
{
get { return Prop.PdfOutline; }
set { Prop.PdfOutline = value; }
}
///
/// Enable or disable a displaying document's title.
///
[DefaultValue(true)]
[Category("Pdf Format")]
[Browsable(true)]
public bool PdfDisplayDocTitle
{
get { return Prop.PdfDisplayDocTitle; }
set { Prop.PdfDisplayDocTitle = value; }
}
///
/// Enable or disable a hiding the toolbar.
///
[DefaultValue(false)]
[Category("Pdf Format")]
[Browsable(true)]
public bool PdfHideToolbar
{
get { return Prop.PdfHideToolbar; }
set { Prop.PdfHideToolbar = value; }
}
///
/// Enable or disable a hiding the menu's bar.
///
[DefaultValue(false)]
[Category("Pdf Format")]
[Browsable(true)]
public bool PdfHideMenubar
{
get { return Prop.PdfHideMenubar; }
set { Prop.PdfHideMenubar = value; }
}
///
/// Enable or disable a hiding the Windows UI.
///
[DefaultValue(false)]
[Category("Pdf Format")]
[Browsable(true)]
public bool PdfHideWindowUI
{
get { return Prop.PdfHideWindowUI; }
set { Prop.PdfHideWindowUI = value; }
}
///
/// Enable or disable a fitting the window.
///
[DefaultValue(false)]
[Category("Pdf Format")]
[Browsable(true)]
public bool PdfFitWindow
{
get { return Prop.PdfFitWindow; }
set { Prop.PdfFitWindow = value; }
}
///
/// Enable or disable a centering the window.
///
[DefaultValue(false)]
[Category("Pdf Format")]
[Browsable(true)]
public bool PdfCenterWindow
{
get { return Prop.PdfCenterWindow; }
set { Prop.PdfCenterWindow = value; }
}
///
/// Enable or disable a scaling the page for shrink to printable area.
///
[DefaultValue(true)]
[Category("Pdf Format")]
[Browsable(true)]
public bool PdfPrintScaling
{
get { return Prop.PdfPrintScaling; }
set { Prop.PdfPrintScaling = value; }
}
///
/// Sets the Title of the document.
///
[DefaultValue("")]
[Category("Pdf Format")]
[Browsable(true)]
public string PdfTitle
{
get { return Prop.PdfTitle; }
set { Prop.PdfTitle = value; }
}
///
/// Sets the Author of the document.
///
[DefaultValue("")]
[Category("Pdf Format")]
[Browsable(true)]
public string PdfAuthor
{
get { return Prop.PdfAuthor; }
set { Prop.PdfAuthor = value; }
}
///
/// Sets the Subject of the document.
///
[DefaultValue("")]
[Category("Pdf Format")]
[Browsable(true)]
public string PdfSubject
{
get { return Prop.PdfSubject; }
set { Prop.PdfSubject = value; }
}
///
/// Sets the Keywords of the document.
///
[DefaultValue("")]
[Category("Pdf Format")]
[Browsable(true)]
public string PdfKeywords
{
get { return Prop.PdfKeywords; }
set { Prop.PdfKeywords = value; }
}
///
/// Sets the Creator of the document.
///
[DefaultValue("FastReport")]
[Category("Pdf Format")]
[Browsable(true)]
public string PdfCreator
{
get { return Prop.PdfCreator; }
set { Prop.PdfCreator = value; }
}
///
/// Sets the Producer of the document.
///
[DefaultValue("FastReport.NET")]
[Category("Pdf Format")]
[Browsable(true)]
public string PdfProducer
{
get { return Prop.PdfProducer; }
set { Prop.PdfProducer = value; }
}
///
/// Sets the users password.
///
[DefaultValue("")]
[Category("Pdf Format")]
[Browsable(true)]
public string PdfUserPassword
{
get { return Prop.PdfUserPassword; }
set { Prop.PdfUserPassword = value; }
}
///
/// Sets the owners password.
///
[DefaultValue("")]
[Category("Pdf Format")]
[Browsable(true)]
public string PdfOwnerPassword
{
get { return Prop.PdfOwnerPassword; }
set { Prop.PdfOwnerPassword = value; }
}
///
/// Enable or disable a printing in protected document.
///
[DefaultValue(true)]
[Category("Pdf Format")]
[Browsable(true)]
public bool PdfAllowPrint
{
get { return Prop.PdfAllowPrint; }
set { Prop.PdfAllowPrint = value; }
}
///
/// Enable or disable a modifying in protected document.
///
[DefaultValue(true)]
[Category("Pdf Format")]
[Browsable(true)]
public bool PdfAllowModify
{
get { return Prop.PdfAllowModify; }
set { Prop.PdfAllowModify = value; }
}
///
/// Enable or disable a copying in protected document.
///
[DefaultValue(true)]
[Category("Pdf Format")]
[Browsable(true)]
public bool PdfAllowCopy
{
get { return Prop.PdfAllowCopy; }
set { Prop.PdfAllowCopy = value; }
}
///
/// Enable or disable an annotating in protected document.
///
[DefaultValue(true)]
[Category("Pdf Format")]
[Browsable(true)]
public bool PdfAllowAnnotate
{
get { return Prop.PdfAllowAnnotate; }
set { Prop.PdfAllowAnnotate = value; }
}
///
/// Enable or disable the PDF/A document.
///
[DefaultValue(false)]
[Category("Pdf Format")]
[Browsable(true)]
public bool PdfA
{
get { return Prop.PdfA; }
set { Prop.PdfA = value; }
}
///
/// Enable or disable a showing of Print Dialog.
///
[DefaultValue(false)]
[Category("Pdf Format")]
[Browsable(true)]
public bool PdfShowPrintDialog
{
get { return Prop.PdfShowPrintDialog; }
set { Prop.PdfShowPrintDialog = value; }
}
///
/// Enable or disable the Images Original Resolution.
///
[DefaultValue(false)]
[Category("Pdf Format")]
[Browsable(true)]
public bool PdfImagesOriginalResolution
{
get { return Prop.PdfImagesOriginalResolution; }
set { Prop.PdfImagesOriginalResolution = value; }
}
///
/// Enable or disable the Jpeg Compression.
///
[DefaultValue(false)]
[Category("Pdf Format")]
[Browsable(true)]
public bool PdfJpegCompression
{
get { return Prop.PdfJpegCompression; }
set { Prop.PdfJpegCompression = value; }
}
///
/// Select a color space (RGB or CMYK)
///
[DefaultValue(typeof(PDFExport.PdfColorSpace), "RGB")]
[Category("Pdf Format")]
[Browsable(true)]
public PDFExport.PdfColorSpace PdfColorSpace
{
get { return Prop.PdfColorSpace; }
set { Prop.PdfColorSpace = value; }
}
#endregion PDF format
#region CSV format
///
/// Switch visibility the CSV (comma separated values) export in toolbar.
///
[DefaultValue(true)]
[Category("Toolbar")]
[Browsable(true)]
public bool ShowCsvExport
{
get { return Prop.ShowCsvExport; }
set { Prop.ShowCsvExport = value; }
}
///
/// Gets or sets the cells separator.
///
[DefaultValue(";")]
[Category("Csv Format")]
[Browsable(true)]
public string CsvSeparator
{
get { return Prop.CsvSeparator; }
set { Prop.CsvSeparator = value; }
}
///
/// Enable or disable an exporting data without any header/group bands.
///
[DefaultValue(false)]
[Category("Csv Format")]
[Browsable(true)]
public bool CsvDataOnly
{
get { return Prop.CsvDataOnly; }
set { Prop.CsvDataOnly = value; }
}
#endregion CSV format
#region Prepared report
///
/// Switch a visibility of prepared report export in toolbar
///
[DefaultValue(true)]
[Category("Toolbar")]
[Browsable(true)]
public bool ShowPreparedReport
{
get { return Prop.ShowPreparedReport; }
set { Prop.ShowPreparedReport = value; }
}
#endregion Prepared report
#region Text format
///
/// Switch a visibility of text (plain text) export in toolbar
///
[DefaultValue(true)]
[Category("Toolbar")]
[Browsable(true)]
public bool ShowTextExport
{
get { return Prop.ShowTextExport; }
set { Prop.ShowTextExport = value; }
}
///
/// Enable or disable an exporting data without any header/group bands.
///
[DefaultValue(false)]
[Category("Text Format")]
[Browsable(true)]
public bool TextDataOnly
{
get { return Prop.TextDataOnly; }
set { Prop.TextDataOnly = value; }
}
///
/// Gets or sets a value indicating that page breaks are enabled.
///
[DefaultValue(true)]
[Category("Text Format")]
[Browsable(true)]
public bool TextPageBreaks
{
get { return Prop.TextPageBreaks; }
set { Prop.TextPageBreaks = value; }
}
///
/// Enable or disable the frames in text file.
///
[DefaultValue(true)]
[Category("Text Format")]
[Browsable(true)]
public bool TextAllowFrames
{
get { return Prop.TextAllowFrames; }
set { Prop.TextAllowFrames = value; }
}
///
/// Enable or disable the simple (non graphic) frames in text file.
///
[DefaultValue(true)]
[Category("Text Format")]
[Browsable(true)]
public bool TextSimpleFrames
{
get { return Prop.TextSimpleFrames; }
set { Prop.TextSimpleFrames = value; }
}
///
/// Enable or disable an empty lines in text file.
///
[DefaultValue(false)]
[Category("Text Format")]
[Browsable(true)]
public bool TextEmptyLines
{
get { return Prop.TextEmptyLines; }
set { Prop.TextEmptyLines = value; }
}
#endregion Text format
#region All exports
private void DoProcessReport()
{
StringBuilder sb = new StringBuilder();
ReportProcess(sb, this.Context);
}
private string GetExportFileName(string format)
{
string s = String.Concat(
Path.GetFileNameWithoutExtension(
Report.FileName.Length == 0 ? WebUtils.ReportPrefix : Report.FileName),
".",
format);
return s;
}
private void ResponseExport(WebExportItem exportItem, bool displayInline, HttpContext context)
{
WebReport webReport = new WebReport();
WebReportCache exportcache = new WebReportCache(context);
object webReportObject = exportcache.GetObject(exportItem.ReportID, webReport);
if (webReportObject != null)
{
webReport = webReportObject as WebReport;
if (WebUtils.SetupResponse(webReport, context))
{
exportItem.FileName = GetExportFileName(exportItem.Format);
string guid = WebUtils.GetGUID();
exportcache.PutObject(guid, exportItem);
string url = string.Format("~/{0}?{1}={2}&displayinline={3}", WebUtils.HandlerFileName, WebUtils.ConstID, guid, displayInline);
context.Response.Redirect(url, false);
}
}
else
{
// 500
}
}
private void ResponseExport(WebExportItem ExportItem, HttpContext context)
{
ResponseExport(ExportItem, false, context);
}
///
/// Exports in CSV format.
///
public void ExportCsv()
{
ExportCsv(this.Context);
}
///
/// Exports in CSV format.
///
public void ExportCsv(HttpContext context)
{
if (State != ReportState.Done)
DoProcessReport();
if (State == ReportState.Done && TotalPages > 0)
{
WebExportItem exportItem = new WebExportItem();
exportItem.ReportID = ReportGuid;
CSVExport csvExport = new CSVExport();
csvExport.OpenAfterExport = false;
// set csv export properties
csvExport.Separator = CsvSeparator;
csvExport.DataOnly = CsvDataOnly;
using (MemoryStream ms = new MemoryStream())
{
csvExport.Export(Report, ms);
exportItem.File = ms.ToArray();
}
exportItem.Format = "csv";
exportItem.ContentType = "text/x-csv";
ResponseExport(exportItem, context);
}
}
///
/// Exports in Text format.
///
public void ExportText()
{
ExportText(this.Context);
}
///
/// Exports in Text format.
///
public void ExportText(HttpContext context)
{
if (State != ReportState.Done)
DoProcessReport();
if (State == ReportState.Done && TotalPages > 0)
{
WebExportItem exportItem = new WebExportItem();
exportItem.ReportID = ReportGuid;
TextExport textExport = new TextExport();
textExport.OpenAfterExport = false;
// set text export properties
textExport.AvoidDataLoss = true;
textExport.DataOnly = TextDataOnly;
textExport.PageBreaks = TextPageBreaks;
textExport.Frames = TextAllowFrames;
textExport.TextFrames = TextSimpleFrames;
textExport.EmptyLines = TextEmptyLines;
using (MemoryStream ms = new MemoryStream())
{
textExport.Export(Report, ms);
exportItem.File = ms.ToArray();
}
exportItem.Format = "txt";
exportItem.ContentType = "text/plain";
ResponseExport(exportItem, context);
}
}
///
/// Exports in DBF format.
///
public void ExportDbf()
{
ExportDbf(this.Context);
}
///
/// Exports in DBF format.
///
public void ExportDbf(HttpContext context)
{
if (State != ReportState.Done)
DoProcessReport();
if (State == ReportState.Done && TotalPages > 0)
{
WebExportItem exportItem = new WebExportItem();
exportItem.ReportID = ReportGuid;
DBFExport dbfExport = new DBFExport();
dbfExport.OpenAfterExport = false;
// set text export properties
dbfExport.DataOnly = true;
using (MemoryStream ms = new MemoryStream())
{
dbfExport.Export(Report, ms);
exportItem.File = ms.ToArray();
}
exportItem.Format = "dbf";
exportItem.ContentType = "application/dbf";
ResponseExport(exportItem, context);
}
}
///
/// Exports in PDF format.
///
public void ExportPdf()
{
ExportPdf(this.Context, false, PdfShowPrintDialog, false);
}
///
/// Exports in PDF format.
///
public void ExportPdf(bool displayInline)
{
ExportPdf(this.Context, displayInline, PdfShowPrintDialog, false);
}
///
/// Exports in PDF format.
///
public void ExportPdf(HttpContext context)
{
ExportPdf(context, false, PdfShowPrintDialog, false);
}
///
/// Exports in PDF format inline.
///
public void ExportPdf(HttpContext context, bool displayInline, bool showPrintDialog, bool print)
{
if (State != ReportState.Done)
DoProcessReport();
if (State == ReportState.Done)
{
WebExportItem exportItem = new WebExportItem();
exportItem.ReportID = this.ReportGuid;
PDFExport pdfExport = new PDFExport();
pdfExport.OpenAfterExport = false;
// set pdf export properties
pdfExport.EmbeddingFonts = PdfEmbeddingFonts;
pdfExport.TextInCurves = PdfTextInCurves;
pdfExport.Background = PdfBackground;
pdfExport.PrintOptimized = PdfPrintOptimized;
pdfExport.Title = PdfTitle;
pdfExport.Author = PdfAuthor;
pdfExport.Subject = PdfSubject;
pdfExport.Keywords = PdfKeywords;
pdfExport.Creator = PdfCreator;
pdfExport.Producer = PdfProducer;
pdfExport.Outline = PdfOutline;
pdfExport.DisplayDocTitle = PdfDisplayDocTitle;
pdfExport.HideToolbar = PdfHideToolbar;
pdfExport.HideMenubar = PdfHideMenubar;
pdfExport.HideWindowUI = PdfHideWindowUI;
pdfExport.FitWindow = PdfFitWindow;
pdfExport.CenterWindow = PdfCenterWindow;
pdfExport.PrintScaling = PdfPrintScaling;
pdfExport.UserPassword = PdfUserPassword;
pdfExport.OwnerPassword = PdfOwnerPassword;
pdfExport.AllowPrint = PdfAllowPrint;
pdfExport.AllowCopy = PdfAllowCopy;
pdfExport.AllowModify = PdfAllowModify;
pdfExport.AllowAnnotate = PdfAllowAnnotate;
pdfExport.PdfCompliance = PdfA ? PDFExport.PdfStandard.PdfA_2a : PDFExport.PdfStandard.None;
pdfExport.ShowPrintDialog = showPrintDialog;
pdfExport.InteractiveForms = PdfInteractiveForms;
pdfExport.ExportMode = print ? PDFExport.ExportType.WebPrint : PDFExport.ExportType.Export;
pdfExport.ImagesOriginalResolution = PdfImagesOriginalResolution;
pdfExport.JpegCompression = PdfJpegCompression;
pdfExport.ColorSpace = PdfColorSpace;
using (MemoryStream ms = new MemoryStream())
{
pdfExport.Export(Report, ms);
exportItem.File = ms.ToArray();
}
exportItem.Format = "pdf";
exportItem.ContentType = "application/pdf";
ResponseExport(exportItem, displayInline, context);
}
}
///
/// Exports in HTML format inline.
///
public void ExportHtml(HttpContext context, bool displayInline, bool print)
{
if (State != ReportState.Done)
DoProcessReport();
if (State == ReportState.Done)
{
WebExportItem exportItem = new WebExportItem();
exportItem.ReportID = ReportGuid;
HTMLExport htmlExport = new HTMLExport();
htmlExport.CustomDraw += CustomDraw;
htmlExport.OpenAfterExport = false;
// set html export properties
htmlExport.Navigator = false;
htmlExport.Layers = Layers;
htmlExport.SinglePage = true;
htmlExport.Pictures = Pictures;
htmlExport.Print = print;
htmlExport.Preview = true;
htmlExport.SubFolder = false;
htmlExport.EmbedPictures = EmbedPictures;
htmlExport.EnableVectorObjects = !WebUtils.IsIE8(context); // don't draw svg barcodes for IE8
htmlExport.WebImagePrefix = String.Concat(WebUtils.GetAppRoot(context, WebUtils.HandlerFileName), "?", WebUtils.PicsPrefix);
htmlExport.ExportMode = htmlExport.Print ? HTMLExport.ExportType.WebPrint : HTMLExport.ExportType.Export;
using (MemoryStream ms = new MemoryStream())
{
htmlExport.Export(Report, ms);
exportItem.File = ms.ToArray();
}
if (htmlExport.PrintPageData != null)
{
WebReportCache cache = new WebReportCache(this.Context);
// add all pictures in cache
for (int i = 0; i < htmlExport.PrintPageData.Pictures.Count; i++)
{
Stream stream = htmlExport.PrintPageData.Pictures[i];
byte[] image = new byte[stream.Length];
stream.Position = 0;
int n = stream.Read(image, 0, (int)stream.Length);
string picGuid = htmlExport.PrintPageData.Guids[i];
cache.PutObject(picGuid, image);
}
// cleanup
for (int i = 0; i < htmlExport.PrintPageData.Pictures.Count; i++)
{
Stream stream = htmlExport.PrintPageData.Pictures[i];
stream.Dispose();
stream = null;
}
htmlExport.PrintPageData.Pictures.Clear();
htmlExport.PrintPageData.Guids.Clear();
}
exportItem.Format = "html";
exportItem.ContentType = "text/html";
ResponseExport(exportItem, displayInline, context);
}
}
///
/// Exports in RTF format.
///
public void ExportRtf()
{
ExportRtf(this.Context);
}
///
/// Exports in RTF format.
///
public void ExportRtf(HttpContext context)
{
if (State != ReportState.Done)
DoProcessReport();
if (State == ReportState.Done && TotalPages > 0)
{
WebExportItem exportItem = new WebExportItem();
exportItem.ReportID = ReportGuid;
RTFExport rtfExport = new RTFExport();
rtfExport.OpenAfterExport = false;
// set Rtf export properties
rtfExport.JpegQuality = RtfJpegQuality;
rtfExport.ImageFormat = RtfImageFormat;
rtfExport.Pictures = RtfPictures;
rtfExport.PageBreaks = RtfPageBreaks;
rtfExport.Wysiwyg = RtfWysiwyg;
rtfExport.Creator = RtfCreator;
rtfExport.AutoSize = RtfAutoSize;
using (MemoryStream ms = new MemoryStream())
{
rtfExport.Export(Report, ms);
exportItem.File = ms.ToArray();
}
exportItem.Format = "rtf";
exportItem.ContentType = "application/rtf";
ResponseExport(exportItem, context);
}
}
///
/// Exports in MHT format.
///
public void ExportMht()
{
ExportMht(this.Context);
}
///
/// Exports in MHT format.
///
public void ExportMht(HttpContext context)
{
if (State != ReportState.Done)
DoProcessReport();
if (State == ReportState.Done && TotalPages > 0)
{
WebExportItem exportItem = new WebExportItem();
exportItem.ReportID = ReportGuid;
MHTExport mhtExport = new MHTExport();
mhtExport.OpenAfterExport = false;
// set MHT export properties
mhtExport.Pictures = MhtPictures;
mhtExport.Wysiwyg = MhtWysiwyg;
using (MemoryStream ms = new MemoryStream())
{
mhtExport.Export(Report, ms);
exportItem.File = ms.ToArray();
}
exportItem.Format = "mht";
exportItem.ContentType = "message/rfc822";
ResponseExport(exportItem, context);
}
}
///
/// Exports in XML (Excel 2003) format.
///
public void ExportXmlExcel()
{
ExportXmlExcel(this.Context);
}
///
/// Exports in XML (Excel 2003) format.
///
public void ExportXmlExcel(HttpContext context)
{
if (State != ReportState.Done)
DoProcessReport();
if (State == ReportState.Done && TotalPages > 0)
{
WebExportItem exportItem = new WebExportItem();
exportItem.ReportID = ReportGuid;
XMLExport xmlExport = new XMLExport();
xmlExport.OpenAfterExport = false;
// set xml export properties
xmlExport.PageBreaks = XmlExcelPageBreaks;
xmlExport.Wysiwyg = XmlExcelWysiwyg;
xmlExport.DataOnly = XmlExcelDataOnly;
using (MemoryStream ms = new MemoryStream())
{
xmlExport.Export(Report, ms);
exportItem.File = ms.ToArray();
}
exportItem.Format = "xls";
exportItem.ContentType = "application/vnd.ms-excel";
ResponseExport(exportItem, context);
}
}
///
/// Exports in Open Office Spreadsheet format.
///
public void ExportOds()
{
ExportOds(this.Context);
}
///
/// Exports in Open Office Spreadsheet format.
///
public void ExportOds(HttpContext context)
{
if (State != ReportState.Done)
DoProcessReport();
if (State == ReportState.Done && TotalPages > 0)
{
WebExportItem exportItem = new WebExportItem();
exportItem.ReportID = ReportGuid;
ODSExport odsExport = new ODSExport();
odsExport.OpenAfterExport = false;
// set ODS export properties
odsExport.Creator = OdsCreator;
odsExport.Wysiwyg = OdsWysiwyg;
odsExport.PageBreaks = OdsPageBreaks;
using (MemoryStream ms = new MemoryStream())
{
odsExport.Export(Report, ms);
exportItem.File = ms.ToArray();
}
exportItem.Format = "ods";
exportItem.ContentType = "application/x-oleobject";
ResponseExport(exportItem, context);
}
}
///
/// Exports in Open Office Text format.
///
public void ExportOdt()
{
ExportOdt(this.Context);
}
///
/// Exports in Open Office Text format.
///
public void ExportOdt(HttpContext context)
{
if (State != ReportState.Done)
DoProcessReport();
if (State == ReportState.Done && TotalPages > 0)
{
WebExportItem exportItem = new WebExportItem();
exportItem.ReportID = ReportGuid;
ODTExport odtExport = new ODTExport();
odtExport.OpenAfterExport = false;
// set ODT export properties
odtExport.Creator = OdtCreator;
odtExport.Wysiwyg = OdtWysiwyg;
odtExport.PageBreaks = OdtPageBreaks;
using (MemoryStream ms = new MemoryStream())
{
odtExport.Export(Report, ms);
exportItem.File = ms.ToArray();
}
exportItem.Format = "odt";
exportItem.ContentType = "application/x-oleobject";
ResponseExport(exportItem, context);
}
}
///
/// Exports in XPS format.
///
public void ExportXps()
{
ExportXps(this.Context);
}
///
/// Exports in XPS format.
///
public void ExportXps(HttpContext context)
{
if (State != ReportState.Done)
DoProcessReport();
if (State == ReportState.Done && TotalPages > 0)
{
WebExportItem exportItem = new WebExportItem();
exportItem.ReportID = ReportGuid;
XPSExport xpsExport = new XPSExport();
xpsExport.OpenAfterExport = false;
using (MemoryStream ms = new MemoryStream())
{
xpsExport.Export(Report, ms);
exportItem.File = ms.ToArray();
}
exportItem.Format = "xps";
exportItem.ContentType = "application/vnd.ms-xpsdocument";
ResponseExport(exportItem, context);
}
}
///
/// Exports in Excel 2007 format.
///
public void ExportExcel2007()
{
ExportExcel2007(this.Context);
}
///
/// Exports in Excel 2007 format.
///
public void ExportExcel2007(HttpContext context)
{
if (State != ReportState.Done)
DoProcessReport();
if (State == ReportState.Done && TotalPages > 0)
{
WebExportItem exportItem = new WebExportItem();
exportItem.ReportID = ReportGuid;
Excel2007Export xlsxExport = new Excel2007Export();
xlsxExport.OpenAfterExport = false;
// set Excel 2007 export properties
xlsxExport.PageBreaks = XlsxPageBreaks;
xlsxExport.Seamless = XlsxSeamless;
xlsxExport.DataOnly = XlsxDataOnly;
xlsxExport.GroupOnSeparateSheet = XlsxGroupOnSeparateSheet;
xlsxExport.PrintOptimized = XlsxPrintOptimized;
xlsxExport.PrintFit = XlsxPrintFitPage ?
Excel2007Export.PrintFitMode.FitSheetOnOnePage : Excel2007Export.PrintFitMode.NoScaling;
xlsxExport.Wysiwyg = XlsxWysiwyg;
using (MemoryStream ms = new MemoryStream())
{
xlsxExport.Export(Report, ms);
exportItem.File = ms.ToArray();
}
exportItem.Format = "xlsx";
exportItem.ContentType = "application/vnd.ms-excel";
ResponseExport(exportItem, context);
}
}
///
/// Exports in Word 2007 format.
///
public void ExportWord2007()
{
ExportWord2007(this.Context);
}
///
/// Exports in Word 2007 format.
///
public void ExportWord2007(HttpContext context)
{
if (State != ReportState.Done)
DoProcessReport();
if (State == ReportState.Done && TotalPages > 0)
{
WebExportItem exportItem = new WebExportItem();
exportItem.ReportID = ReportGuid;
Word2007Export docxExport = new Word2007Export();
docxExport.OpenAfterExport = false;
docxExport.Wysiwyg = DocxWysiwyg;
// set Word 2007 export properties
docxExport.MatrixBased = DocxMatrixBased;
docxExport.ParagraphBased = DocxParagraphBased;
docxExport.PrintOptimized = DocxPrintOptimized;
if (!String.IsNullOrEmpty(DocxRowHeightIs) && DocxRowHeightIs.ToLower() == "min")
docxExport.RowHeight = Word2007Export.RowHeightType.Minimum;
else
docxExport.RowHeight = Word2007Export.RowHeightType.Exactly;
using (MemoryStream ms = new MemoryStream())
{
docxExport.Export(Report, ms);
exportItem.File = ms.ToArray();
}
exportItem.Format = "docx";
exportItem.ContentType = "application/vnd.ms-word";
ResponseExport(exportItem, context);
}
}
///
/// Exports in PowerPoint 2007 format.
///
public void ExportPowerPoint2007()
{
ExportPowerPoint2007(this.Context);
}
///
/// Exports in PowerPoint 2007 format.
///
public void ExportPowerPoint2007(HttpContext context)
{
if (State != ReportState.Done)
DoProcessReport();
if (State == ReportState.Done && TotalPages > 0)
{
WebExportItem exportItem = new WebExportItem();
exportItem.ReportID = ReportGuid;
PowerPoint2007Export pptxExport = new PowerPoint2007Export();
pptxExport.OpenAfterExport = false;
// set Power Point 2007 properties
pptxExport.ImageFormat = PptxImageFormat;
using (MemoryStream ms = new MemoryStream())
{
pptxExport.Export(Report, ms);
exportItem.File = ms.ToArray();
}
exportItem.Format = "pptx";
exportItem.ContentType = "application/vnd.ms-powerpoint ";
ResponseExport(exportItem, context);
}
}
///
/// Exports in prepared report.
///
public void ExportPrepared()
{
ExportPrepared(this.Context);
}
///
/// Exports in prepared report.
///
public void ExportPrepared(HttpContext context)
{
if (State != ReportState.Done)
DoProcessReport();
if (State == ReportState.Done && TotalPages > 0)
{
WebExportItem exportItem = new WebExportItem();
exportItem.ReportID = ReportGuid;
using (MemoryStream ms = new MemoryStream())
{
Report.SavePrepared(ms);
exportItem.File = ms.ToArray();
}
exportItem.Format = "fpx";
exportItem.ContentType = "application/octet-stream";
ResponseExport(exportItem, context);
}
}
///
/// Prints in Adobe Acrobat.
///
public void PrintPdf()
{
ExportPdf(this.Context, true, true, true);
}
///
/// Prints in Adobe Acrobat.
///
public void PrintPdf(HttpContext context)
{
ExportPdf(context, true, true, true);
}
///
/// Prints in Adobe Acrobat.
///
public void PrintPdf(bool showPrintDialog)
{
ExportPdf(this.Context, true, showPrintDialog, true);
}
///
/// Prints in Adobe Acrobat.
///
public void PrintPdf(HttpContext context, bool showPrintDialog)
{
ExportPdf(context, true, showPrintDialog, true);
}
///
/// Prints in browser.
///
public void PrintHtml()
{
ExportHtml(this.Context, true, true);
}
///
/// Prints in browser.
///
public void PrintHtml(HttpContext context)
{
ExportHtml(context, true, true);
}
#endregion All exports
}
}