Esempio n. 1
0
        private void Export_All_PivotGrid()
        {
            PivotGridControl[] grids = new PivotGridControl[] { pivotGridControl1 };
            DevExpress.XtraPrinting.PrintingSystem     ps            = new DevExpress.XtraPrinting.PrintingSystem();
            DevExpress.XtraPrintingLinks.CompositeLink compositeLink = new DevExpress.XtraPrintingLinks.CompositeLink(ps);

            // Show the Document Map toolbar button and menu item.
            ps.SetCommandVisibility(PrintingSystemCommand.Open, CommandVisibility.All);

            // Make the "Export to Csv" and "Export to Txt" commands visible.
            ps.SetCommandVisibility(new PrintingSystemCommand[] { PrintingSystemCommand.ExportCsv, PrintingSystemCommand.ExportTxt, PrintingSystemCommand.ExportXlsx, PrintingSystemCommand.ExportDocx, PrintingSystemCommand.ExportXls }, CommandVisibility.All);
            compositeLink.PrintingSystem = ps;
            foreach (PivotGridControl grid in grids)
            {
                PrintableComponentLink link = new PrintableComponentLink();
                link.Component = grid;
                //compositeLink.Links.Add(link);
                compositeLink.Links.AddRange(new object[] { link });
            }

            string ReportName = "Daily_Status_Report";
            string folderPath = "C:\\Temp\\";
            string Path1      = folderPath + DateTime.Now.ToString("dd-MM-yyyy-hh-mm-ss") + "-" + ReportName + ".xlsx";

            compositeLink.PrintingSystem.ExportToXlsx(Path1, new XlsxExportOptions()
            {
                ExportMode = XlsxExportMode.SingleFilePageByPage
            });
            compositeLink.ShowPreview();
            compositeLink.CreatePageForEachLink();
        }
Esempio n. 2
0
        private void excel()
        {
            GridControl[]  grids = new GridControl[] { gridControl1, gridControl2 };
            PrintingSystem ps    = new PrintingSystem();

            DevExpress.XtraPrintingLinks.CompositeLink compositeLink = new DevExpress.XtraPrintingLinks.CompositeLink();
            compositeLink.PrintingSystem = ps;
            foreach (GridControl grid in grids)
            {
                PrintableComponentLink link = new PrintableComponentLink();
                link.Component = grid;
                compositeLink.Links.Add(link);
            }
            compositeLink.CreateDocument();
            compositeLink.ShowPreview();
        }
        private void Export_All_PivotGrid()
        {
            GridControl[] grids = new GridControl[] { Grd_Dash_Emp_efficency, grd_Targetorder, Grid_Error_Details };
            DevExpress.XtraPrinting.PrintingSystem     ps            = new DevExpress.XtraPrinting.PrintingSystem();
            DevExpress.XtraPrintingLinks.CompositeLink compositeLink = new DevExpress.XtraPrintingLinks.CompositeLink(ps);

            // Show the Document Map toolbar button and menu item.
            ps.SetCommandVisibility(PrintingSystemCommand.Open, CommandVisibility.All);

            // Make the "Export to Csv" and "Export to Txt" commands visible.
            ps.SetCommandVisibility(new PrintingSystemCommand[] { PrintingSystemCommand.ExportCsv, PrintingSystemCommand.ExportTxt, PrintingSystemCommand.ExportXlsx, PrintingSystemCommand.ExportDocx, PrintingSystemCommand.ExportXls }, CommandVisibility.All);
            compositeLink.PrintingSystem = ps;
            foreach (GridControl grid in grids)
            {
                PrintableComponentLink link = new PrintableComponentLink();
                link.Component = grid;
                //compositeLink.Links.Add(link);
                compositeLink.Links.AddRange(new object[] { link });
            }


            string ReportName = "Accuracy_Deatils";
            string folderPath = "C:\\Temp\\";
            string Path1      = folderPath + DateTime.Now.ToString("dd-MM-yyyy-hh-mm-ss") + "-" + ReportName + ".xlsx";

            //Microsoft.Office.Interop.Excel.Application excelApp = new Microsoft.Office.Interop.Excel.Application();
            //string myPath = @"15-02-2019-Accuracy_Deatils.xlsx";
            //excelApp.Workbooks.Open(myPath);

            //// Get Worksheet
            //Microsoft.Office.Interop.Excel.Worksheet worksheet = excelApp.Worksheets[1];
            //int rowIndex = 2; int colIndex = 2;
            //for (int i = 0; i < 10; i++)
            //{
            //    excelApp.Cells[rowIndex, colIndex] = "\r123";
            //}

            //excelApp.Visible = false;


            compositeLink.PrintingSystem.ExportToXlsx(Path1, new XlsxExportOptions()
            {
                ExportMode = XlsxExportMode.SingleFilePageByPage
            });
            compositeLink.ShowPreview();
            compositeLink.CreatePageForEachLink();
        }
Esempio n. 4
0
        private void barButton_File_ItemClick(object sender, ItemClickEventArgs e)
        {
            //打开
            if (e.Item.Name == nameof(barButton_Open) || e.Item.Name == nameof(ToolButton_Open))
            {
                CETCManagerApp.Instance.OnFileOpen();
            }
            //保存
            else if (e.Item.Name == nameof(barButton_Save) || e.Item.Name == nameof(ToolButton_Save))
            {
                CETCManagerApp.Instance.OnFileSave();
            }
            //另存为
            else if (e.Item.Name == nameof(barButton_SaveAs) || e.Item.Name == nameof(ToolButton_SaveAs))
            {
                CETCManagerApp.Instance.OnFileSaveAs();
            }
            //打印
            else if (e.Item.Name == nameof(barButton_Print) || e.Item.Name == nameof(ToolButton_Print))
            {
                IDD_PAGE_PRINT iDD_PAGE_PRINT = new IDD_PAGE_PRINT();
                MultiLanguage.LoadLanguage(iDD_PAGE_PRINT, typeof(IDD_PAGE_PRINT));
                iDD_PAGE_PRINT.ShowDialog();
            }
            //打印预览
            else if (e.Item.Name == nameof(barButton_PrintPreView) || e.Item.Name == nameof(ToolButton_PrintPreView))
            {
                IDD_PAGE_PRINT iDD_PAGE_PRINT = new IDD_PAGE_PRINT();
                MultiLanguage.LoadLanguage(iDD_PAGE_PRINT, typeof(IDD_PAGE_PRINT));
                iDD_PAGE_PRINT.ShowDialog();
            }
            //报表设置
            else if (e.Item.Name == nameof(barButton_ReportSetup))
            {
            }
            //导出PDF
            else if (e.Item.Name == nameof(barButton_ExportPDF) || e.Item.Name == nameof(ToolButton_ExportPDF))
            {
            }
            //导出WORD
            else if (e.Item.Name == nameof(barButton_ExportWORD) || e.Item.Name == nameof(ToolButton_ExportWORD))
            {
                PrintingSystem ps = new PrintingSystem();
                DevExpress.XtraPrintingLinks.CompositeLink compositeLink = new DevExpress.XtraPrintingLinks.CompositeLink();
                compositeLink.PrintingSystem = ps;


                PrintableComponentLink link = new PrintableComponentLink();
                var c = main_TempChart.GetChart();
                //Size size = c.Size;
                //c.Dock = DockStyle.None;
                //c.Size = new Size(400, 278);
                MemoryStream ms = new MemoryStream();
                c.ExportToImage(ms, ImageFormat.Bmp);
                PictureEdit pe = new PictureEdit();
                link.Images.Add(Image.FromStream(ms));
                link.Component = c;
                compositeLink.Links.Add(link);
                link           = new PrintableComponentLink();
                link.Component = main_DataAnasis.GetGridControl(0);
                compositeLink.Links.Add(link);
                compositeLink.CreateDocument();
                compositeLink.ShowPreview();
            }
            //发送EMAIL
            else if (e.Item.Name == nameof(barButton_SendEMail) || e.Item.Name == nameof(ToolButton_SendEMail))
            {
            }
            //离开
            else if (e.Item.Name == nameof(barButton_Exit))
            {
                Close();
            }
        }