private void SetParametersPanelWidth(object sender) { PrintPreviewRibbonFormEx previewForm = sender as PrintPreviewRibbonFormEx; ((XtraReport)previewForm.PrintControl.DocumentSource).CreateDocument(); DevExpress.XtraBars.Docking.DockPanel parametersPanel = GetParametersPanel(previewForm); parametersPanel.Width = 700; }
/// <summary> /// Visualizar ou salvar o relatório selecionado do spool /// </summary> /// <param name="idSpool">Id do spool</param> /// <param name="typeGeracaoSpool">Informar o tipo: Visualizar, ExpPdf ou ExpExcel</param> public void GerarRelatorioFromSpool(Int32 idSpool, TypeGeracaoSpool typeGeracaoSpool) { using (var ctx = new ReportContext()) { try { var sv = new SaveFileDialog(); //relatorio selecionado var relat = ctx.ReportSpoolDao.Find(idSpool); //caminho temporario var path = Application.StartupPath + "\\temp.prnx"; //escreve os bytes do relatorio selecionado no arquivo var reportImageUnzip = ZipUtil.UnzipFromBytes(relat.ReportSpoolImage); FileManagerIts.WriteBytesToFile(path, reportImageUnzip); // Create a PrintingSystem instance. PrintingSystem ps = new PrintingSystem(); // Load the document from a file. ps.LoadDocument(path); // Create an instance of the preview dialog. PrintPreviewRibbonFormEx preview = new PrintPreviewRibbonFormEx(); PrintPreviewFormEx prev = new PrintPreviewFormEx(); prev.PrintingSystem = ps; // Load the report document into it. //preview.PrintingSystem = ps; if (typeGeracaoSpool == TypeGeracaoSpool.PreVisualizar) { // Show the preview dialog. //preview.ShowDialog(); //ribbon //não ribbon prev.Show(); } else if (typeGeracaoSpool == TypeGeracaoSpool.ExportarParaPdf) { sv.Filter = "Arquivo PDF | *.pdf"; sv.ShowDialog(); if (sv.FileName != "") { ps.ExportToPdf(sv.FileName); } } else if (typeGeracaoSpool == TypeGeracaoSpool.ExportarParaExcel) { sv.Filter = "Arquivo XLSX | *.xlsx"; sv.ShowDialog(); if (sv.FileName != "") { ps.ExportToXlsx(sv.FileName); } } //Remova o relatorio temporario FileManagerIts.DeleteFile(path); } catch (Exception ex) { LoggerUtilIts.ShowExceptionLogs(ex); } } }
private void PriviewReportFormat() { var report = GetCurrentReportFormat(); if (report != null) { PrintPreviewRibbonFormEx PreviewRibbonForm = new PrintPreviewRibbonFormEx(); PreviewRibbonForm.Text = report.DisplayName + " - 预览"; PreviewRibbonForm.PrintingSystem = report.PrintingSystem; PreviewRibbonForm.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.Save, DevExpress.XtraPrinting.CommandVisibility.None); PreviewRibbonForm.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.Open, DevExpress.XtraPrinting.CommandVisibility.None); var pageGroup = PreviewRibbonForm.RibbonControl.GetGroupByName("Close"); if (pageGroup != null) { pageGroup.Visible = false; pageGroup.Enabled = false; } pageGroup = PreviewRibbonForm.RibbonControl.GetGroupByName("Document"); if (pageGroup != null) { pageGroup.Visible = false; pageGroup.Enabled = false; } report.CreateDocument(true); PreviewRibbonForm.ShowDialog(); } else { MessageService.ShowError("选中的报表格式为空,无法预览!"); } }