Esempio n. 1
0
 private void barButtonItem4_ItemClick(object sender, ItemClickEventArgs e)
 {
     try
     {
         CompositeLink          complink   = new CompositeLink(new PrintingSystem());
         PrintableComponentLink linkTable1 = new PrintableComponentLink();
         PrintableComponentLink linkTable2 = new PrintableComponentLink();
         PrintableComponentLink linkDiff   = new PrintableComponentLink();
         linkTable1.Component = gcWeight;
         complink.Links.Add(linkTable1);
         linkTable2.Component = gcFuel;
         complink.Links.Add(linkTable2);
         linkDiff.Component = gcType;
         complink.Links.Add(linkDiff);
         complink.CreatePageForEachLink();
         if (this.saveFileDialog.ShowDialog() == DialogResult.OK)
         {
             XlsxExportOptions option = new XlsxExportOptions()
             {
                 ExportMode = XlsxExportMode.SingleFilePageByPage
             };
             complink.ExportToXlsx(saveFileDialog.FileName, option);
             if (MessageBox.Show("保存成功,是否打开文件?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
             {
                 System.Diagnostics.Process.Start(saveFileDialog.FileName);
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("导出失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
        private void xuatExcel()
        {
            string ten_cautruyvan = "";

            if (this.lookUpEditCauTruyVan.EditValue.ToString() != "Tên Câu Truy Vấn")
            {
                ten_cautruyvan = this.lookUpEditCauTruyVan.Text.ToString();
            }

            SaveFileDialog f = new SaveFileDialog();

            f.Filter   = "Excel file (*.xlsx)|*.xlsx";
            f.FileName = tenCSKCB + "_DichVuKyThuat_" + ten_cautruyvan + "_" + DateTime.Now.Second.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Year.ToString();


            if (f.ShowDialog() == DialogResult.OK)
            {
                CompositeLink          complink = new CompositeLink(new PrintingSystem());
                PrintableComponentLink link     = new PrintableComponentLink(new PrintingSystem());
                link.Component = this.gridControlKetQua;
                link.CreateMarginalHeaderArea += new CreateAreaEventHandler(Link_CreateMarginalHeaderArea_1);
                complink.Links.Add(link);


                //Rename Sheet
                complink.PrintingSystem.XlSheetCreated += PrintingSystem_XlSheetCreated_1;
                complink.CreatePageForEachLink();
                XlsxExportOptions options = new XlsxExportOptions();
                options.ExportMode = XlsxExportMode.SingleFilePageByPage;
                complink.ExportToXlsx(f.FileName, options);

                MessageBox.Show("Xuất Excel Thành Công!");
            }
        }
        private void xuatExcel()
        {
            SaveFileDialog f = new SaveFileDialog();

            f.Filter   = "Excel file (*.xlsx)|*.xlsx";
            f.FileName = "DichVuKyThuat_" + DateTime.Now.Second.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Year.ToString();

            if (f.ShowDialog() == DialogResult.OK)
            {
                /*
                 * CompositeLink complink = new CompositeLink(new PrintingSystem());
                 * PrintableComponentLink link = new PrintableComponentLink(new PrintingSystem());
                 * link.Component = this.gridControlCSKCB;
                 * link.CreateMarginalHeaderArea += new CreateAreaEventHandler(Link_CreateMarginalHeaderArea);
                 * complink.Links.Add(link);
                 */

                //Rename Sheet
                complinkMain.PrintingSystem.XlSheetCreated += PrintingSystem_XlSheetCreated;
                complinkMain.CreatePageForEachLink();
                XlsxExportOptions options = new XlsxExportOptions();
                options.ExportMode = XlsxExportMode.SingleFilePageByPage;
                complinkMain.ExportToXlsx(f.FileName, options);
                flag_i = 0;

                MessageBox.Show("Xuất Excel Thành Công!");
            }
        }
Esempio n. 4
0
        private void btn_Export_Click(object sender, EventArgs e)
        {
            try
            {
                SplashScreenManager.ShowForm(this, typeof(Masters.WaitForm1), true, true, false);
                if (pivotGridControlBreakHours.DataSource == null && pivotGridControlSummary.DataSource == null && pivotGridControlIdleHours.DataSource == null)
                {
                    SplashScreenManager.CloseForm(false);
                    XtraMessageBox.Show("Data not found, cannot export");
                    return;
                }
                PivotGridControl[] pivotGrids = new PivotGridControl[] { pivotGridControlSummary, pivotGridControlIdleHours, pivotGridControlBreakHours };
                PrintingSystem     ps         = new PrintingSystem();
                ps.SetCommandVisibility(new PrintingSystemCommand[] {
                    PrintingSystemCommand.ExportCsv, PrintingSystemCommand.ExportTxt, PrintingSystemCommand.ExportXlsx,
                    PrintingSystemCommand.ExportDocx, PrintingSystemCommand.ExportXls, PrintingSystemCommand.Open
                }, CommandVisibility.All);
                ps.XlSheetCreated += PrintingSystem_XlSheetCreated;
                CompositeLink cl = new CompositeLink(ps);

                PrintableComponentLink linkSummary = new PrintableComponentLink();
                linkSummary.Component = pivotGridControlSummary;
                linkSummary.PaperName = "Summary";

                PrintableComponentLink linkIdle = new PrintableComponentLink();
                linkIdle.Component = pivotGridControlIdleHours;
                linkIdle.PaperName = "Idle Hours";

                PrintableComponentLink linkBreak = new PrintableComponentLink();
                linkBreak.Component = pivotGridControlBreakHours;
                linkBreak.PaperName = "Break Hours";

                cl.Links.AddRange(new object[] { linkSummary, linkIdle, linkBreak });
                cl.CreatePageForEachLink();

                string filePath = @"C:\Break Idle Reports\";
                string fileName = filePath + "Break Idle Reports All-" + DateTime.Now.ToString("dd-MM-yyyy-hh-mm-ss") + ".xlsx";
                SplashScreenManager.ShowForm(this, typeof(Masters.WaitForm1), true, true, false);
                if (!Directory.Exists(filePath))
                {
                    Directory.CreateDirectory(filePath);
                    Export(cl, fileName);
                }
                else
                {
                    Export(cl, fileName);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                SplashScreenManager.CloseForm(false);
            }
        }
Esempio n. 5
0
 protected override void CreateDocument(CompositeLink link)
 {
     if (link.Links.Count > 1)
     {
         link.CreatePageForEachLink();
     }
     else
     {
         base.CreateDocument(link);
     }
 }
Esempio n. 6
0
 private void ExportSummary()
 {
     try
     {
         gridViewAccuracyDetails.Columns.ColumnByFieldName("Client_Order_Number").SummaryItem.SummaryType = SummaryItemType.None;
         gridViewErrors.Columns.ColumnByFieldName("Client_Order_Number").SummaryItem.SummaryType          = SummaryItemType.None;
         SplashScreenManager.ShowForm(this, typeof(Masters.WaitForm1), true, true, false);
         PrintingSystem         ps            = new PrintingSystem();
         CompositeLink          compositeLink = new CompositeLink(ps);
         PrintableComponentLink linkAccuracy  = new PrintableComponentLink();
         linkAccuracy.Component = gridControlAccuracy;
         PrintableComponentLink linkChart = new PrintableComponentLink();
         linkChart.Component = chartControlAccuracy;
         PrintableComponentLink linkAccuracyDetails = new PrintableComponentLink();
         linkAccuracyDetails.Component = gridControlAccuracyDetails;
         PrintableComponentLink linkErrors = new PrintableComponentLink();
         linkErrors.Component = gridControlErrors;
         ps.SetCommandVisibility(PrintingSystemCommand.Open, CommandVisibility.All);
         ps.SetCommandVisibility(new PrintingSystemCommand[] { PrintingSystemCommand.ExportCsv, PrintingSystemCommand.ExportTxt,
                                                               PrintingSystemCommand.ExportXlsx, PrintingSystemCommand.ExportDocx, PrintingSystemCommand.ExportXls }, CommandVisibility.All);
         compositeLink.Links.AddRange(new object[]
         {
             linkAccuracy, linkChart, linkAccuracyDetails, linkErrors
         });
         string ReportName = "Accuracy Summary";
         string folderPath = "C:\\Temp\\";
         string Path1      = folderPath + DateTime.Now.ToString("dd-MM-yyyy-hh-mm-ss") + "-" + ReportName + ".xlsx";
         compositeLink.CreatePageForEachLink();
         ps.XlSheetCreated += PrintingSystem_XlSheetCreated;
         compositeLink.PrintingSystem.ExportToXlsx(Path1, new XlsxExportOptions()
         {
             ExportMode = XlsxExportMode.SingleFilePageByPage, ExportHyperlinks = false, TextExportMode = TextExportMode.Value, IgnoreErrors = XlIgnoreErrors.NumberStoredAsText
         });
         System.Diagnostics.Process.Start(Path1);
     }
     catch (Exception ex)
     {
         SplashScreenManager.CloseForm(false);
         XtraMessageBox.Show("Something went wrong");
     }
     finally
     {
         gridViewAccuracyDetails.Columns.ColumnByFieldName("Client_Order_Number").SummaryItem.SummaryType = SummaryItemType.Count;
         gridViewErrors.Columns.ColumnByFieldName("Client_Order_Number").SummaryItem.SummaryType          = SummaryItemType.Count;
         SplashScreenManager.CloseForm(false);
     }
 }
 private void btn_Export_Click(object sender, EventArgs e)
 {
     try
     {
         SplashScreenManager.ShowForm(this, typeof(WaitForm1), true, true, false);
         if (layoutView1.DataSource == null)
         {
             SplashScreenManager.CloseForm(false);
             XtraMessageBox.Show("Data Not Found,Can't Export");
             return;
         }
         PrintingSystem ps = new PrintingSystem();
         ps.SetCommandVisibility(new PrintingSystemCommand[] {
             PrintingSystemCommand.ExportCsv, PrintingSystemCommand.ExportTxt, PrintingSystemCommand.ExportXlsx,
             PrintingSystemCommand.ExportDocx, PrintingSystemCommand.ExportXls, PrintingSystemCommand.Open
         }, CommandVisibility.All);
         ps.XlSheetCreated += PrintingSystem_XlSheetCreated;
         CompositeLink          cl = new CompositeLink(ps);
         PrintableComponentLink linknotification = new PrintableComponentLink();
         linknotification.Component = grid_notification;
         linknotification.PaperName = "General Notification";
         cl.Links.AddRange(new object[] { linknotification });
         cl.CreatePageForEachLink();
         string filePath = @"C:\General Notification\";
         string fileName = filePath + "Gereral Notification All-" + DateTime.Now.ToString("dd-MM-yyyy-hh-mm-ss") + ".xlsx";
         SplashScreenManager.ShowForm(this, typeof(WaitForm1), true, true, false);
         if (!Directory.Exists(filePath))
         {
             Directory.CreateDirectory(filePath);
             Export(cl, fileName);
         }
         else
         {
             Export(cl, fileName);
         }
     }
     catch (Exception ex)
     {
         SplashScreenManager.CloseForm(false);
         throw ex;
     }
     finally
     {
         SplashScreenManager.CloseForm(false);
     }
 }
Esempio n. 8
0
        private void barButtonItem4_ItemClick(object sender, ItemClickEventArgs e)
        {
            try
            {
                CompositeLink          complink   = new CompositeLink(new PrintingSystem());
                PrintableComponentLink linkTable1 = new PrintableComponentLink();
                PrintableComponentLink linkTable2 = new PrintableComponentLink();
                PrintableComponentLink linkDiff   = new PrintableComponentLink();

                linkTable1.Component = gcTable1;
                complink.Links.Add(linkTable1);

                linkTable2.Component = gcTable2;
                complink.Links.Add(linkTable2);

                linkDiff.Component = gcTable3;
                complink.Links.Add(linkDiff);
                if (gcTable1.MainView.RowCount == 0 && gcTable2.MainView.RowCount == 0 && gcTable3.MainView.RowCount == 0)
                {
                    return;
                }
                else
                {
                    complink.CreatePageForEachLink();

                    SaveFileDialog saveFileDialog = new SaveFileDialog();
                    saveFileDialog.Title    = "导出Excel";
                    saveFileDialog.Filter   = "Excel文件(*.xlsx)|*.xlsx";
                    saveFileDialog.FileName = "通告比对结果";
                    DialogResult dialogResult = saveFileDialog.ShowDialog(this);
                    if (dialogResult == DialogResult.OK)
                    {
                        XlsxExportOptions option = new XlsxExportOptions();
                        option.ExportMode = XlsxExportMode.SingleFilePageByPage;

                        complink.ExportToXlsx(saveFileDialog.FileName, option);
                        MessageBox.Show("导出成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("导出失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Esempio n. 9
0
        private void Excel_Import()

        {
            CompositeLink complink = new CompositeLink(new PrintingSystem());

            PrintableComponentLink link = new PrintableComponentLink();

            link.Component = gridControl1;

            complink.Links.Add(link);

            complink.CreatePageForEachLink();

            complink.ExportToXlsx("file1.xlsx", new XlsxExportOptions()
            {
                ExportMode = XlsxExportMode.SingleFilePageByPage
            });
        }
        private void xuatExcel_ToanBoCauLenh()
        {
            SaveFileDialog f = new SaveFileDialog();

            f.Filter   = "Excel file (*.xlsx)|*.xlsx";
            f.FileName = tenCSKCB + "_DichVuKyThuat_" + DateTime.Now.Second.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Year.ToString();

            if (f.ShowDialog() == DialogResult.OK)
            {
                //Rename Sheet
                complinkMain.PrintingSystem.XlSheetCreated += PrintingSystem_XlSheetCreated;
                complinkMain.CreatePageForEachLink();
                XlsxExportOptions options = new XlsxExportOptions();
                options.ExportMode = XlsxExportMode.SingleFilePageByPage;
                complinkMain.ExportToXlsx(f.FileName, options);
                flag_i = 0;

                MessageBox.Show("Xuất Excel Thành Công!");
            }
        }
Esempio n. 11
0
        private void ExportOrderHistory()
        {
            try
            {
                SplashScreenManager.ShowForm(this, typeof(Masters.WaitForm1), true, true, false);
                PrintingSystem         ps               = new PrintingSystem();
                CompositeLink          compositeLink    = new CompositeLink(ps);
                PrintableComponentLink LinkOrderhistory = new PrintableComponentLink();
                LinkOrderhistory.Component = gridControlOrderHistory;
                PrintableComponentLink LinkOrderStatusHistory = new PrintableComponentLink();
                LinkOrderStatusHistory.Component = gridControlOrderStatusHistory;

                ps.SetCommandVisibility(PrintingSystemCommand.Open, CommandVisibility.All);
                ps.SetCommandVisibility(new PrintingSystemCommand[] { PrintingSystemCommand.ExportCsv, PrintingSystemCommand.ExportTxt,
                                                                      PrintingSystemCommand.ExportXlsx, PrintingSystemCommand.ExportDocx, PrintingSystemCommand.ExportXls }, CommandVisibility.All);
                compositeLink.Links.AddRange(new object[]
                {
                    LinkOrderhistory, LinkOrderStatusHistory
                });
                string ReportName = "Order History";
                string folderPath = "C:\\Temp\\";
                string Path1      = folderPath + DateTime.Now.ToString("dd-MM-yyyy-hh-mm-ss") + "-" + ReportName + ".xlsx";
                compositeLink.CreatePageForEachLink();
                ps.XlSheetCreated += PrintingSystem_XlSheetCreated;
                compositeLink.PrintingSystem.ExportToXlsx(Path1, new XlsxExportOptions()
                {
                    ExportMode = XlsxExportMode.SingleFilePageByPage, ExportHyperlinks = false, TextExportMode = TextExportMode.Value, IgnoreErrors = XlIgnoreErrors.NumberStoredAsText
                });
                System.Diagnostics.Process.Start(Path1);
            }
            catch (Exception e)
            {
                throw e;
            }
            finally
            {
                SplashScreenManager.CloseForm(false);
            }
        }