Exemplo n.º 1
0
        private static void PrintViaLink(RichEditDocumentServer srv)
        {
            if (!srv.IsPrintingAvailable)
            {
                return;
            }
            using (PrintingSystemBase ps = new PrintingSystemBase())
                using (PrintableComponentLinkBase link = new PrintableComponentLinkBase(ps)) {
                    link.Component = srv;
                    // Disable warnings.
                    ps.ShowMarginsWarning    = false;
                    ps.ShowPrintStatusDialog = false;
                    // Find a printer containing 'Canon' in its name.
                    string printerName = String.Empty;
                    for (int i = 0; i < PrinterSettings.InstalledPrinters.Count; i++)
                    {
                        string pName = PrinterSettings.InstalledPrinters[i];
                        if (pName.Contains("PDF"))
                        {
                            printerName = pName;
                            break;
                        }
                    }

                    //Run document creaion
                    link.CreateDocument();

                    // Print to the specified printer.
                    PrintToolBase tool = new PrintToolBase(ps);
                    tool.Print(printerName);
                }
        }
        private void sbExport_Click(object sender, EventArgs e)
        {
            var sfd = new SaveFileDialog();

            sfd.Filter = "Excel File (*.xlsx)|*.xlsx";
            if (sfd.ShowDialog(this) == DialogResult.OK)
            {
                var printingSystem = new PrintingSystemBase();
                var compositeLink  = new CompositeLinkBase();
                compositeLink.PrintingSystemBase = printingSystem;

                var link = new PrintableComponentLinkBase();
                link.Component = gcRawData;
                compositeLink.Links.Add(link);

                link           = new PrintableComponentLinkBase();
                link.Component = gcSummary;
                compositeLink.Links.Add(link);

                var options = new XlsxExportOptions();
                options.ExportMode = XlsxExportMode.SingleFilePageByPage;

                compositeLink.CreatePageForEachLink();
                compositeLink.ExportToXlsx(sfd.FileName, options);

                System.Diagnostics.Process.Start(sfd.FileName);
            }
        }
        public ActionResult ExportTo()
        {
            var ps = new PrintingSystemBase();

            var headerImageLink = new LinkBase(ps);

            headerImageLink.CreateDetailArea += headerImageLink_CreateDetailArea;

            var link1 = new PrintableComponentLinkBase(ps);
            GridViewSettings categoriesGridSettings = new GridViewSettings();

            categoriesGridSettings.Name         = "gvCategories";
            categoriesGridSettings.KeyFieldName = "CategoryID";
            categoriesGridSettings.Columns.Add("CategoryID");
            categoriesGridSettings.Columns.Add("CategoryName");
            categoriesGridSettings.Columns.Add("Description");
            link1.Component = GridViewExtension.CreatePrintableObject(categoriesGridSettings, MyModel.GetCategories());

            var compositeLink = new CompositeLinkBase(ps);

            compositeLink.Links.AddRange(new object[] { headerImageLink, link1 });
            compositeLink.CreateDocument();

            FileStreamResult result = CreateExcelExportResult(compositeLink);

            ps.Dispose();

            return(result);
        }
Exemplo n.º 4
0
    void GenerateThumbnailCore(Item item)
    {
        IPrintable component = DocumentService.CreatePrintableComponent(item);

        if (component == null)
        {
            return;
        }

        PrintableComponentLinkBase pcl = new PrintableComponentLinkBase(new PrintingSystemBase());

        pcl.Component = component;
        pcl.CreateDocument();
        ImageExportOptions imgOptions = new ImageExportOptions();

        imgOptions.ExportMode      = ImageExportMode.SingleFilePageByPage;
        imgOptions.Format          = System.Drawing.Imaging.ImageFormat.Png;
        imgOptions.PageRange       = "1";
        imgOptions.PageBorderWidth = 0;
        MemoryStream stream = new MemoryStream();

        pcl.ExportToImage(stream, imgOptions);

        stream.Position = 0;
        string thumbPath = GetThumbnailPath(item);

        GenerateThumbnailInternal(stream, thumbPath, ThumbnailWidth, ThumbnailHeight);

        IDisposable disposableComponent = component as IDisposable;

        if (disposableComponent != null)
        {
            disposableComponent.Dispose();
        }
    }
    protected void ExportButton_Click(object sender, EventArgs e)
    {
        PrintingSystemBase ps = new PrintingSystemBase();

        PrintableComponentLinkBase link1 = new PrintableComponentLinkBase(ps);

        link1.Component = GridExporter;

        PrintableComponentLinkBase link2 = new PrintableComponentLinkBase(ps);

        Chart.DataBind();
        link2.Component = ((IChartContainer)Chart).Chart;

        CompositeLinkBase compositeLink = new CompositeLinkBase(ps);

        compositeLink.Links.AddRange(new object[] { link1, link2 });

        compositeLink.CreateDocument();
        using (MemoryStream stream = new MemoryStream()) {
            compositeLink.PrintingSystemBase.ExportToXls(stream);
            Response.Clear();
            Response.Buffer = false;
            Response.AppendHeader("Content-Type", "application/xls");
            Response.AppendHeader("Content-Transfer-Encoding", "binary");
            Response.AppendHeader("Content-Disposition", "attachment; filename=test.xls");
            Response.BinaryWrite(stream.ToArray());
            Response.End();
        }
        ps.Dispose();
    }
        protected void Button1_Click(object sender, EventArgs e)
        {
            PrintingSystemBase ps = new PrintingSystemBase();

            ps.ExportOptions.Pdf.DocumentOptions.Author = "Test";

            PrintableComponentLinkBase link1 = new PrintableComponentLinkBase(ps);

            link1.Component = ASPxPivotGridExporter1;

            PrintableComponentLinkBase link2 = new PrintableComponentLinkBase(ps);

            WebChartControl1.DataBind();
            link2.Component = ((IChartContainer)WebChartControl1).Chart;

            CompositeLinkBase compositeLink = new CompositeLinkBase(ps);

            compositeLink.Links.AddRange(new object[] { link1, link2 });

            using (MemoryStream stream = new MemoryStream()) {
                compositeLink.ExportToPdf(stream);
                Response.Clear();
                Response.Buffer = false;
                Response.AppendHeader("Content-Type", "application/pdf");
                Response.AppendHeader("Content-Transfer-Encoding", "binary");
                Response.AppendHeader("Content-Disposition", "attachment; filename=test.pdf");
                Response.BinaryWrite(stream.ToArray());
                Response.End();
            }

            ps.Dispose();
        }
Exemplo n.º 7
0
        private void toExcel()
        {
            XlsxExportOptions opt = new XlsxExportOptions();

            opt.ExportMode = XlsxExportMode.SingleFilePageByPage;
            string FileName = "C:\\CORRECT\\XLS\\" + Reportenombre + ".xlsx";

            opt.SheetName = "NEW";


            //gridView1.ExportToXlsx(FileName);
            gridView1.OptionsPrint.ExpandAllDetails = true;
            gridView1.OptionsPrint.PrintDetails     = true;
            gridView1.OptionsPrint.ExpandAllGroups  = true;

            //gridView2.OptionsPrint.ExpandAllDetails = true;
            //gridView2.OptionsPrint.PrintDetails = true;
            gridView1.ZoomView();
            //CompositeLink conp = new CompositeLink();

            var printingSystem = new PrintingSystemBase();
            var compositeLink  = new CompositeLinkBase();

            compositeLink.PrintingSystemBase = printingSystem;

            var link1 = new PrintableComponentLinkBase();

            link1.Component = gridControl1;
            //var link2 = new PrintableComponentLinkBase();
            //link2.Component = grid2;

            compositeLink.Links.Add(link1);
            // compositeLink.Links.Add(link2);

            var options = new XlsxExportOptions();

            options.ExportMode = XlsxExportMode.SingleFilePageByPage;

            compositeLink.CreatePageForEachLink();
            compositeLink.ExportToXlsx(FileName, options);



            //conp.ExportToXlsx(FileName, opt);

            //gridView1.ExportToXlsx(FileName,opt);
            //gridControl1.DefaultView
            Microsoft.Office.Interop.Excel.Application excell;
            Microsoft.Office.Interop.Excel.Workbook    workbook;
            excell         = new Excel.Application();
            excell.Visible = true;
            workbook       = excell.Workbooks.Open(FileName);
        }
 protected void ASPxButton1_Click(object sender, EventArgs e)
 {
     using (MemoryStream ms = new MemoryStream()){
         PrintableComponentLinkBase pcl = new PrintableComponentLinkBase(new PrintingSystemBase());
         pcl.Component    = ASPxGridViewExporter1;
         pcl.Margins.Left = pcl.Margins.Right = 50;
         pcl.Landscape    = true;
         pcl.CreateDocument(false);
         pcl.PrintingSystemBase.Document.AutoFitToPagesWidth = 1;
         pcl.ExportToPdf(ms);
         WriteResponse(this.Response, ms.ToArray(), System.Net.Mime.DispositionTypeNames.Inline.ToString());
     }
 }
Exemplo n.º 9
0
 public static void ExportToPDFFitToPage(ASPxGridViewExporter GridViewExporter, Page pg)
 {
     using (MemoryStream ms = new MemoryStream())
     {
         PrintableComponentLinkBase pcl = new PrintableComponentLinkBase(new DevExpress.XtraPrinting.PrintingSystemBase());
         pcl.Component    = GridViewExporter;
         pcl.Margins.Left = pcl.Margins.Right = 50;
         pcl.Landscape    = true;
         pcl.CreateDocument(false);
         pcl.PrintingSystemBase.Document.AutoFitToPagesWidth = 1;
         pcl.ExportToPdf(ms);
         WriteResponse(pg.Response, ms.ToArray(), System.Net.Mime.DispositionTypeNames.Inline.ToString());
     }
 }
 private void barButtonItem1_ItemClick(object sender, DevExpress.Xpf.Bars.ItemClickEventArgs e)
 {
     this.Cursor = System.Windows.Input.Cursors.Wait;
     #region #saveasimage
     PrintableComponentLinkBase pcl = new PrintableComponentLinkBase(new PrintingSystemBase());
     pcl.Component = ((IRichEditControl)richEditControl1).InnerControl;
     pcl.CreateDocument(false);
     ImageExportOptions imgOptions = new ImageExportOptions();
     imgOptions.ExportMode = ImageExportMode.DifferentFiles;
     imgOptions.Format     = System.Drawing.Imaging.ImageFormat.Png;
     imgOptions.Resolution = 150;
     imgOptions.PageRange  = "1,3-5";
     pcl.ExportToImage("export.png", imgOptions);
     #endregion #saveasimage
     this.Cursor = System.Windows.Input.Cursors.Arrow;
 }
Exemplo n.º 11
0
        void ExporToStream(string html, Stream stream)
        {
            using (RichEditDocumentServer server = new RichEditDocumentServer()) {
                server.HtmlText = html;
                string text = "<b>SOME SAMPLE TEXT</b>";
                AddHeaderToDocument(server.Document, text);
                AddFooterToDocument(server.Document, text);

                using (PrintingSystemBase ps = new PrintingSystemBase()) {
                    using (PrintableComponentLinkBase pcl = new PrintableComponentLinkBase(ps)) {
                        pcl.Component = server;
                        pcl.CreateDocument();
                        ps.ExportToPdf(stream);
                    }
                }
            }
        }
Exemplo n.º 12
0
    MemoryStream InitializeThumbnail(IBasePrintable component)
    {
        PrintableComponentLinkBase pcl = new PrintableComponentLinkBase(new PrintingSystemBase());

        pcl.Component = component;
        pcl.CreateDocument();
        ImageExportOptions imgOptions = new ImageExportOptions();

        imgOptions.ExportMode      = ImageExportMode.SingleFilePageByPage;
        imgOptions.Format          = System.Drawing.Imaging.ImageFormat.Png;
        imgOptions.PageRange       = "1";
        imgOptions.PageBorderWidth = 0;
        MemoryStream stream = new MemoryStream();

        pcl.ExportToImage(stream, imgOptions);
        stream.Position = 0;
        return(stream);
    }
Exemplo n.º 13
0
        public void ExcelDnData()
        {
            if (gridView1.RowCount == 0)
            {
                MessageBox.Show("저장할 데이터가 없습니다. 조회 후 다운로드 가능합니다.");
                return;
            }
            else
            {
                string FileName = this.Text + "(" + DateTime.Now.ToString("yyyyMMdd") + ").xlsx";

                SaveFileDialog saveFile = new SaveFileDialog();
                saveFile.Filter           = "Excel파일(*.xlsx)|*.xlsx";
                saveFile.FileName         = FileName;
                saveFile.RestoreDirectory = true;

                if (saveFile.ShowDialog() == DialogResult.OK)
                {
                    PrintingSystemBase ps = new PrintingSystemBase();   // 프린트 형식에 각각 컨트롤을 링크로 만들어서 같은 엑셀 파일에 뿌리기
                    CompositeLinkBase  cl = new CompositeLinkBase();

                    cl.PrintingSystemBase = ps;
                    PrintableComponentLinkBase pcl1 = new PrintableComponentLinkBase(); // 첫번째 그래프 들어갈 링크
                    pcl1.Component = chartControl_Pie;
                    PrintableComponentLinkBase pcl2 = new PrintableComponentLinkBase(); // 두번째 그래프 들어갈 링크
                    pcl2.Component = chartControl_Bar;
                    PrintableComponentLinkBase pcl3 = new PrintableComponentLinkBase(); // 세번째 그리드 들어갈 링크
                    pcl3.Component = gridControl1;

                    XlsxExportOptions options = new XlsxExportOptions();
                    options.ExportMode = XlsxExportMode.DifferentFiles;

                    cl.Links.Add(pcl1);
                    cl.Links.Add(pcl2);
                    cl.Links.Add(pcl3);
                    cl.CreateDocument(); // 각각의 링크를 합쳐서 한개의 문서로 만들어줌
                    cl.ExportToXlsx(saveFile.FileName, new XlsxExportOptionsEx {
                        ExportType = ExportType.WYSIWYG
                    });                                                                                              // 데이터 있는 만큼만 그리드 그림

                    //gridView1.ExportToXlsx(saveFile.FileName, new XlsxExportOptionsEx { ExportType = ExportType.WYSIWYG });
                }
            }
        }
Exemplo n.º 14
0
        private void ConfigureExport(ASPxGridView grid)
        {
            PrintingSystemBase ps = new PrintingSystemBase();

            ps.ExportOptions.Xlsx.SheetName = "Tipos de Documentos";

            ps.XlSheetCreated += ps_XlSheetCreated;
            PrintableComponentLinkBase link1 = new PrintableComponentLinkBase(ps);

            link1.PaperName = "DatosGenerales";
            link1.Component = Exporter;

            CompositeLinkBase compositeLink = new CompositeLinkBase(ps);

            compositeLink.Links.AddRange(new object[] { link1 });
            compositeLink.CreatePageForEachLink();

            ps.Dispose();
            grid.Settings.ShowColumnHeaders = true;
        }
Exemplo n.º 15
0
        private static Bitmap ExportToImage(IBasePrintable component)
        {
            PrintableComponentLinkBase pLink = new PrintableComponentLinkBase(new PrintingSystemBase());

            pLink.Component = component;
            pLink.CreateDocument(true);

            MemoryStream       mStream = new MemoryStream();
            ImageExportOptions options = new ImageExportOptions();

            options.ExportMode = ImageExportMode.SingleFilePageByPage;
            options.PageRange  = "1";
            pLink.ExportToImage(mStream, options);
            mStream.Position = 0;
            Bitmap bm = new Bitmap(mStream);

            mStream.Close();

            return(bm);
        }
    void Export(string format)
    {
        PrintingSystemBase ps = new PrintingSystemBase();

        using (headerImage = Image.FromFile(Server.MapPath("~/Images/DevExpress-Logo-Large-Color.png"))) {
            LinkBase header = new LinkBase();
            header.CreateDetailHeaderArea += Header_CreateDetailHeaderArea;

            PrintableComponentLinkBase link1 = new PrintableComponentLinkBase();
            link1.Component = this.ASPxGridViewExporter1;
            link1.CreateReportFooterArea += Link1_CreateReportFooterArea;
            CompositeLinkBase compositeLink = new CompositeLinkBase(ps);
            compositeLink.Links.AddRange(new object[] { header, link1 });

            compositeLink.CreateDocument();
            using (MemoryStream stream = new MemoryStream()) {
                switch (format)
                {
                case "xls":
                    compositeLink.ExportToXls(stream);
                    WriteToResponse("filename", true, format, stream);
                    break;

                case "pdf":
                    compositeLink.ExportToPdf(stream);
                    WriteToResponse("filename", true, format, stream);
                    break;

                case "rtf":
                    compositeLink.ExportToRtf(stream);
                    WriteToResponse("filename", true, format, stream);
                    break;

                default:
                    break;
                }
            }
            ps.Dispose();
        }
    }
Exemplo n.º 17
0
        private void xuấtExcelToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (xuatExcelDialog.ShowDialog() == DialogResult.OK)
            {
                var compositeLink = new CompositeLinkBase();
                compositeLink.PrintingSystemBase = ps;

                var sheetTnBao = new PrintableComponentLinkBase();
                sheetTnBao.Component = gridcontrol_tinbao;
                var sheetXLK = new PrintableComponentLinkBase();
                sheetXLK.Component = gridControl_xlk;

                compositeLink.Links.Add(sheetTnBao);
                compositeLink.Links.Add(sheetXLK);

                var options = new XlsxExportOptions();
                options.ExportMode = XlsxExportMode.SingleFilePageByPage;

                compositeLink.CreatePageForEachLink();
                compositeLink.ExportToXlsx(xuatExcelDialog.FileName, options);
            }
        }
Exemplo n.º 18
0
    protected void ExportButton_Click(object sender, EventArgs e)
    {
        PrintingSystemBase ps = new PrintingSystemBase();

        PrintableComponentLinkBase link1 = new PrintableComponentLinkBase(ps);

        link1.Component = GridExporter1;

        PrintableComponentLinkBase link2 = new PrintableComponentLinkBase(ps);

        link2.Component = GridExporter2;

        CompositeLinkBase compositeLink = new CompositeLinkBase(ps);

        compositeLink.Links.AddRange(new object[] { link1, link2 });

        compositeLink.CreateDocument();
        using (MemoryStream stream = new MemoryStream()) {
            compositeLink.ExportToXls(stream);
            WriteToResponse("filename", true, "xls", stream);
        }
        ps.Dispose();
    }
    protected void ExportButton_Click(object sender, EventArgs e)
    {
        PrintingSystemBase ps = new PrintingSystemBase();

        PrintableComponentLinkBase link1 = new PrintableComponentLinkBase(ps);

        link1.Component = GridExporter;

        PrintableComponentLinkBase link2 = new PrintableComponentLinkBase(ps);

        link2.Component = TreeListExporter;

        PrintableComponentLinkBase link3 = new PrintableComponentLinkBase(ps);

        Chart.DataBind();
        link3.Component = ((IChartContainer)Chart).Chart;

        CompositeLinkBase compositeLink = new CompositeLinkBase(ps);

        compositeLink.Links.AddRange(new object[] { link1, link2, link3 });

        compositeLink.CreatePageForEachLink();

        using (MemoryStream stream = new MemoryStream()) {
            XlsxExportOptions options = new XlsxExportOptions();
            options.ExportMode = XlsxExportMode.SingleFilePageByPage;
            compositeLink.PrintingSystemBase.ExportToXlsx(stream, options);
            Response.Clear();
            Response.Buffer = false;
            Response.AppendHeader("Content-Type", "application/xlsx");
            Response.AppendHeader("Content-Transfer-Encoding", "binary");
            Response.AppendHeader("Content-Disposition", "attachment; filename=test.xlsx");
            Response.BinaryWrite(stream.ToArray());
            Response.End();
        }
        ps.Dispose();
    }
    protected void bnExport_Click(object sender, EventArgs e)
    {
        ASPxButton btn = sender as ASPxButton;

        PrintingSystemBase         ps  = new PrintingSystemBase();
        PrintableComponentLinkBase lnk = new PrintableComponentLinkBase(ps);

        lnk.Component = gridExporter;

        CompositeLinkBase compositeLink = new CompositeLinkBase(ps);

        compositeLink.Links.AddRange(new object[] { lnk });
        compositeLink.CreateDocument();

        MemoryStream stream = new MemoryStream();
        string       type   = string.Empty;

        switch (btn.ID)
        {
        case "bnExportPDF":
            compositeLink.PrintingSystemBase.ExportToPdf(stream);
            type = "pdf";
            break;

        case "bnExportXLS":
            compositeLink.PrintingSystemBase.ExportToXls(stream);
            type = "xls";
            break;

        case "bnExportRRF":
            compositeLink.PrintingSystemBase.ExportToRtf(stream);
            type = "rtf";
            break;
        }
        Session["ExportStream"] = stream;
        Session["type"]         = type;
    }
Exemplo n.º 21
0
        public ActionResult ExportTo(int MasterRowKey)
        {
            var ps = new PrintingSystemBase();

            var link1 = new PrintableComponentLinkBase(ps);
            GridViewSettings categoriesGridSettings = new GridViewSettings();

            categoriesGridSettings.Name         = "gvCategories";
            categoriesGridSettings.KeyFieldName = "CategoryID";
            categoriesGridSettings.Columns.Add("CategoryID");
            categoriesGridSettings.Columns.Add("CategoryName");
            categoriesGridSettings.Columns.Add("Description");
            link1.Component = GridViewExtension.CreatePrintableObject(categoriesGridSettings, MyModel.GetCategories());

            var link2 = new PrintableComponentLinkBase(ps);
            GridViewSettings productsGridSettings = new GridViewSettings();

            productsGridSettings.Name         = "gvProducts";
            productsGridSettings.KeyFieldName = "ProductID";
            productsGridSettings.Columns.Add("ProductID");
            productsGridSettings.Columns.Add("ProductName");
            productsGridSettings.Columns.Add("CategoryID");
            productsGridSettings.Columns.Add("UnitPrice");
            link2.Component = GridViewExtension.CreatePrintableObject(productsGridSettings, MyModel.GetProducts(MasterRowKey));

            var compositeLink = new CompositeLinkBase(ps);

            compositeLink.Links.AddRange(new object[] { link1, link2 });
            compositeLink.CreateDocument();

            FileStreamResult result = CreateExcelExportResult(compositeLink);

            ps.Dispose();

            return(result);
        }
Exemplo n.º 22
0
        public void exportToExcel( )
        {
            using (var saveDialog = new SaveFileDialog())
            {
                DialogResult dialogResult = default(DialogResult);
                var          _with1       = saveDialog;

                _with1.Filter           = "Microsoft Excel|*.xls";
                _with1.Title            = "Save as Excel";
                _with1.FileName         = string.Format("{0}_{1}", this.Text, DateTime.Today.ToString("yyyyMMdd"));
                _with1.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);

                if (_with1.ShowDialog() == DialogResult.OK)
                {
                    try
                    {
                        var printingSystem = new PrintingSystemBase();
                        var compositeLink  = new CompositeLinkBase();
                        compositeLink.PrintingSystemBase = printingSystem;

                        var link1 = new PrintableComponentLinkBase();
                        link1.Component = gcTotal;
                        //link1.PaperName = gcTotal.Tag.ToString();
                        var link2 = new PrintableComponentLinkBase();
                        link2.Component = gcDetail;
                        //link2.PaperName = gcDetail.Tag.ToString();
                        var link3 = new PrintableComponentLinkBase();
                        link3.Component = gcCandidate;
                        //link3.PaperName = gcCandidate.Tag.ToString();

                        compositeLink.Links.Add(link1);
                        compositeLink.Links.Add(link2);
                        compositeLink.Links.Add(link3);


                        var options = new XlsxExportOptions();
                        options.ExportMode = XlsxExportMode.SingleFilePageByPage;

                        compositeLink.CreatePageForEachLink();
                        compositeLink.ExportToXlsx(_with1.FileName, options);

                        string strexcelversion = Functions.GetOfficeVersion();
                        if (int.Parse(strexcelversion) >= 2007)
                        {
                            Microsoft.Office.Interop.Excel.Application exc      = new Microsoft.Office.Interop.Excel.Application();
                            Microsoft.Office.Interop.Excel.Workbook    workbook = exc.Workbooks.Open(_with1.FileName, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);

                            Microsoft.Office.Interop.Excel.Sheets sheets = workbook.Worksheets;

                            Microsoft.Office.Interop.Excel.Worksheet sheet1 = (Microsoft.Office.Interop.Excel.Worksheet)(sheets[1]);
                            Microsoft.Office.Interop.Excel.Worksheet sheet2 = (Microsoft.Office.Interop.Excel.Worksheet)(sheets[2]);
                            Microsoft.Office.Interop.Excel.Worksheet sheet3 = (Microsoft.Office.Interop.Excel.Worksheet)(sheets[3]);

                            sheet1.Name = gcTotal.Tag.ToString();
                            sheet2.Name = gcDetail.Tag.ToString();
                            sheet3.Name = gcCandidate.Tag.ToString();

                            workbook.Close(true, Type.Missing, Type.Missing);
                            exc.Quit();
                        }

                        //System.Diagnostics.Process.Start(_with1.FileName);

                        DialogResult = XtraMessageBox.Show("Do you want to open this file?", "Information", MessageBoxButtons.YesNo, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
                        if (DialogResult == DialogResult.Yes)
                        {
                            System.Diagnostics.Process.Start(_with1.FileName);
                        }
                        else
                        {
                            XtraMessageBox.Show("Export Succeeded!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                    catch (Exception ex)
                    {
                        XtraMessageBox.Show("Could not export to excel file." + Environment.NewLine + ex.Message.ToString(), "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }
Exemplo n.º 23
0
        void GenerateThumbnailCore(Item item)
        {
            IPrintable component = DocumentService.CreatePrintableComponent(item);
                if (component == null)
                     return;

                PrintableComponentLinkBase pcl = new PrintableComponentLinkBase(new PrintingSystemBase());
                pcl.Component = component;
                pcl.CreateDocument();
                ImageExportOptions imgOptions = new ImageExportOptions();
                imgOptions.ExportMode = ImageExportMode.SingleFilePageByPage;
                imgOptions.Format = System.Drawing.Imaging.ImageFormat.Png;
                imgOptions.PageRange = "1";
                imgOptions.PageBorderWidth = 0;
                MemoryStream stream = new MemoryStream();
                pcl.ExportToImage(stream, imgOptions);

                stream.Position = 0;
                string thumbPath = GetThumbnailPath(item);
                GenerateThumbnailInternal(stream, thumbPath, ThumbnailWidth, ThumbnailHeight);

                IDisposable disposableComponent = component as IDisposable;
                if (disposableComponent != null)
                     disposableComponent.Dispose();
        }