コード例 #1
0
        private void btnInDanhSach_Click(object sender, EventArgs e)
        {
            Janus.Windows.GridEX.Export.GridEXExporter ex = new Janus.Windows.GridEX.Export.GridEXExporter();
            ex.GridEX = gxGiaoDanList1;

            string filePath = System.IO.Path.GetRandomFileName() + ".xls";

            filePath = Memory.GetTempPath(filePath);
            System.IO.FileInfo   file   = new System.IO.FileInfo(filePath);
            System.IO.FileStream stream = file.OpenWrite();
            ex.Export((System.IO.Stream)stream);
            stream.Close();
            System.Diagnostics.Process.Start(filePath);
        }
コード例 #2
0
        private void btnPLExport_Click(object sender, EventArgs e)
        {
            Janus.Windows.GridEX.GridEX grid = grdPLTrade;
            SaveFileDialog sfd = new SaveFileDialog();

            sfd.Filter = "Excel file (*.xls)|*.xls";
            if (sfd.ShowDialog() == DialogResult.OK)
            {
                FileStream stream;
                Janus.Windows.GridEX.Export.GridEXExporter gridexport = new Janus.Windows.GridEX.Export.GridEXExporter();
                gridexport.IncludeFormatStyle = true;
                gridexport.GridEX             = grid;
                stream = new FileStream(sfd.FileName, FileMode.Create);
                gridexport.Export(stream);
            }
        }
コード例 #3
0
ファイル: frmMergeData.cs プロジェクト: Vocaoson/qlgx
        public bool Export(GridEX grid, string filePath)
        {
            try
            {
                Janus.Windows.GridEX.Export.GridEXExporter ex = new Janus.Windows.GridEX.Export.GridEXExporter();
                ex.GridEX = grid;

                System.IO.FileInfo   file   = new System.IO.FileInfo(filePath);
                System.IO.FileStream stream = file.OpenWrite();
                ex.IncludeCollapsedRows = true;
                ex.Export(stream);
                stream.Close();
                return(true);
            }
            catch (Exception ex)
            {
                Memory.ShowError(ex.Message);
                return(false);
            }
        }
コード例 #4
0
        private void btnExportOrders_Click(object sender, EventArgs e)
        {
            Janus.Windows.GridEX.GridEX grid = grdOrders;
            SaveFileDialog sfd = new SaveFileDialog();

            sfd.Filter = "Excel file (*.xls)|*.xls";
            if (sfd.ShowDialog() == DialogResult.OK)
            {
                FileStream stream = null;
                try
                {
                    Janus.Windows.GridEX.Export.GridEXExporter gridExporter = new Janus.Windows.GridEX.Export.GridEXExporter();
                    gridExporter.IncludeFormatStyle   = true;
                    gridExporter.GridEX               = grid;
                    gridExporter.IncludeCollapsedRows = false;
                    gridExporter.IncludeHeaders       = true;
                    gridExporter.GridEX.AutoSizeColumns();

                    stream = new FileStream(sfd.FileName, FileMode.Create);
                    gridExporter.Export(stream);
                    MessageBox.Show("Orders Exported", "TC Admin");
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                    if (!((stream == null)))
                    {
                        stream.Close();
                        stream.Dispose();
                        stream = null;
                    }
                }
            }
            else
            {
                MessageBox.Show("Excel Export Cancel!", "TC Admin");
            }
        }
コード例 #5
0
        private void uiCommandManager1_CommandClick(object sender, Janus.Windows.UI.CommandBars.CommandEventArgs e)
        {
            try
            {
                switch (e.Command.Key)
                {
                case "cmdSave":
                    this.saveFileDialog1.ShowDialog();
                    string file = this.saveFileDialog1.FileName;
                    if (file == "")
                    {
                        return;
                    }

                    DataSet dt = (DataSet)bindingSource1.DataSource;

                    dt.WriteXml(file, XmlWriteMode.WriteSchema);
                    break;

                case "cmdExamine":
                    if (MessageBox.Show("This will clear the current text in the Query text field. Are you sure you want to clear the text?", "Clear Current Text", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == System.Windows.Forms.DialogResult.Yes)
                    {
                        ebSQL.Text = "";
                        DataSet dt2 = new DataSet();

                        this.openFileDialog1.ShowDialog();
                        string file2 = this.openFileDialog1.FileName;
                        if (file2 == "")
                        {
                            return;
                        }

                        dt2.ReadXml(file2);

                        bindingSource1.DataSource = dt2;
                        gridEX1.DataSource        = dt2;
                        gridEX1.RetrieveStructure(true);
                    }
                    break;

                case "cmdExecute":
                    try
                    {
                        ebMessage.Text = "Executing...Please Wait";
                        ebCount.Text   = "";

                        string sSQL = ebSQL.Text;
                        if (ebSQL.SelectedText.Length > 0)
                        {
                            sSQL = ebSQL.SelectedText;
                        }

                        if (sSQL == "")
                        {
                            ebMessage.Text = "No query to execute";
                            ebCount.Text   = "";
                            return;
                        }

                        DataSet ds = AtMng.AppMan.ExecuteDatasetSQL(sSQL);
                        bindingSource1.DataSource = ds;
                        gridEX1.DataSource        = ds;


                        gridEX1.RetrieveStructure(true);
                        foreach (Janus.Windows.GridEX.GridEXColumn gc in gridEX1.Tables[1].Columns)
                        {
                            gc.EditType = Janus.Windows.GridEX.EditType.NoEdit;
                            if (gc.DataTypeCode == TypeCode.DateTime)
                            {
                                gc.FormatString = "g";
                            }
                        }
                        ebMessage.Text = "Done";
                        if (ds.Tables.Count > 0)
                        {
                            ebCount.Text = ds.Tables[0].Rows.Count.ToString();
                            gridEX1.ExpandRecords();
                        }
                    }
                    catch (Exception x)
                    {
                        ebMessage.Text = "Error: " + x.Message;
                        ebCount.Text   = "";
                        UIHelper.HandleUIException(x);
                    }
                    break;

                case "cmdSaveExcel":
                    this.saveFileDialog1.ShowDialog();
                    string file3 = this.saveFileDialog1.FileName;
                    if (file3 == "")
                    {
                        return;
                    }

                    Janus.Windows.GridEX.Export.GridEXExporter oExport = new Janus.Windows.GridEX.Export.GridEXExporter();
                    oExport.GridEX = gridEX1;


                    oExport.ExportMode           = Janus.Windows.GridEX.ExportMode.AllRows;
                    oExport.IncludeChildTables   = true;
                    oExport.IncludeCollapsedRows = true;
                    oExport.IncludeExcelProcessingInstruction = true;
                    oExport.IncludeFormatStyle = true;
                    oExport.IncludeHeaders     = true;

                    System.IO.FileStream LayoutStream = new System.IO.FileStream(file3, System.IO.FileMode.Create, System.IO.FileAccess.ReadWrite, System.IO.FileShare.ReadWrite);
                    oExport.Export(LayoutStream);
                    LayoutStream.Close();
                    break;
                }
            }
            catch (Exception x)
            {
                UIHelper.HandleUIException(x);
            }
        }
コード例 #6
0
        private void uiCommandManager1_CommandClick(object sender, Janus.Windows.UI.CommandBars.CommandEventArgs e)
        {
            try
            {
                switch (e.Command.Key)
                {
                case "cmdSave":
                    if (this.folderBrowserDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        string              path = this.folderBrowserDialog1.SelectedPath;
                        DataSet             ds   = (DataSet)bindingSource1.DataSource;
                        atriumBE.DocManager dm   = this.AtMng.GetFile().GetDocMng();

                        foreach (DataRow dr in ds.Tables[0].Rows)
                        {
                            int    docrefid = (int)dr["DocRefId"];
                            int    docid    = (int)dr["DocId"];
                            string version  = (string)dr["CurrentVersion"];

                            lmDatasets.docDB.DocumentRow docr = dm.GetDocument().Load(docid);

                            docr.efSubject = dr["FullFileNumber"].ToString() + " " + docr.efSubject;
                            dm.GetDocContent().Load(docrefid, version);

                            dm.GetDocument().Export(docr, false, path);
                            dm.DB.DocContent.Clear();
                            dm.DB.DocContent.AcceptChanges();
                        }
                    }
                    break;

                case "cmdExecute":
                    try
                    {
                        ebMessage.Text = "Executing...Please Wait";
                        ebCount.Text   = "";

                        string sSQL = ebSQL.Text;
                        if (ebSQL.SelectedText.Length > 0)
                        {
                            sSQL = ebSQL.SelectedText;
                        }

                        if (sSQL == "")
                        {
                            ebMessage.Text = "No query to execute";
                            ebCount.Text   = "";
                            return;
                        }

                        DataSet ds = AtMng.AppMan.ExecuteDatasetSQL(sSQL);
                        bindingSource1.DataSource = ds;
                        gridEX1.DataSource        = ds;


                        gridEX1.RetrieveStructure(true);
                        foreach (Janus.Windows.GridEX.GridEXColumn gc in gridEX1.Tables[1].Columns)
                        {
                            gc.EditType = Janus.Windows.GridEX.EditType.NoEdit;
                            if (gc.DataTypeCode == TypeCode.DateTime)
                            {
                                gc.FormatString = "g";
                            }
                        }
                        ebMessage.Text = "Done";
                        if (ds.Tables.Count > 0)
                        {
                            ebCount.Text = ds.Tables[0].Rows.Count.ToString();
                            gridEX1.ExpandRecords();
                        }
                    }
                    catch (Exception x)
                    {
                        ebMessage.Text = "Error: " + x.Message;
                        ebCount.Text   = "";
                        UIHelper.HandleUIException(x);
                    }
                    break;

                case "cmdSaveExcel":
                    this.saveFileDialog1.ShowDialog();
                    string file3 = this.saveFileDialog1.FileName;
                    if (file3 == "")
                    {
                        return;
                    }

                    Janus.Windows.GridEX.Export.GridEXExporter oExport = new Janus.Windows.GridEX.Export.GridEXExporter();
                    oExport.GridEX = gridEX1;


                    oExport.ExportMode           = Janus.Windows.GridEX.ExportMode.AllRows;
                    oExport.IncludeChildTables   = true;
                    oExport.IncludeCollapsedRows = true;
                    oExport.IncludeExcelProcessingInstruction = true;
                    oExport.IncludeFormatStyle = true;
                    oExport.IncludeHeaders     = true;

                    System.IO.FileStream LayoutStream = new System.IO.FileStream(file3, System.IO.FileMode.Create, System.IO.FileAccess.ReadWrite, System.IO.FileShare.ReadWrite);
                    oExport.Export(LayoutStream);
                    LayoutStream.Close();
                    break;
                }
            }
            catch (Exception x)
            {
                UIHelper.HandleUIException(x);
            }
        }
コード例 #7
0
ファイル: GxGrid.cs プロジェクト: Vocaoson/qlgx
        public virtual void Print()
        {
            //Janus.Windows.GridEX.GridEXPrintDocument exp = new GridEXPrintDocument();
            //PrintPreviewDialog prd = new PrintPreviewDialog();
            //exp.GridEX = this;
            //exp.FitColumns = FitColumnsMode.SizingColumns;
            //exp.ExpandFarColumn = true;
            //exp.PrintHierarchical = true;
            //exp.DefaultPageSettings.Landscape = true;
            //prd.Document = exp;
            //prd.ShowDialog();

            Janus.Windows.GridEX.Export.GridEXExporter ex = new Janus.Windows.GridEX.Export.GridEXExporter();
            ex.GridEX             = this;
            ex.IncludeFormatStyle = true;
            ex.IncludeHeaders     = true;
            ex.SheetName          = (this.DataSource as DataTable).TableName;

            string filePath = System.IO.Path.GetRandomFileName() + ".xls";

            filePath = Memory.GetTempPath(filePath);
            System.IO.FileInfo   file   = new System.IO.FileInfo(filePath);
            System.IO.FileStream stream = file.OpenWrite();
            ex.IncludeCollapsedRows = true;
            ex.Export((System.IO.Stream)stream);
            stream.Close();
            System.Diagnostics.Process.Start(filePath);

            //string templatePath = Memory.GetReportTemplatePath("common.xls");
            //string outputPath = Memory.GetTempPath("common.xls");
            //ExcelEngine excel = new ExcelEngine();
            //if (excel.CreateObject(outputPath, templatePath))
            //{
            //    try
            //    {
            //        //write header
            //        for (int i = 0; i < this.RootTable.Columns.Count; i++)
            //        {
            //            excel.Write_to_excel(1, i + 1, this.RootTable.Columns[i].Caption);
            //            excel.SetWidth(i + 1, this.RootTable.Columns[i].Width);
            //        }
            //        for (int i = 0; i < this.RowCount; i++)
            //        {
            //            for (int j = 0; j < this.RootTable.Columns.Count; j++)
            //            {
            //                object value = this.GetRow(i).Cells[j].Value;
            //                //xu ly 1 so truong hop dac biet
            //                if (this.RootTable.Columns[j].Key.StartsWith("Ngay") && !Memory.IsNullOrEmpty(value))
            //                {
            //                    value = string.Format("'{0}", value);
            //                }
            //                else if (this.RootTable.Columns[j].DataTypeCode == TypeCode.Boolean)
            //                {
            //                    value = (bool)value ? "X" : "";
            //                }
            //                excel.Write_to_excel(i + 2, j + 1, value);
            //            }
            //        }
            //        excel.End_Write();
            //        System.Diagnostics.Process.Start(outputPath);
            //    }
            //    catch (Exception e)
            //    {
            //        MessageBox.Show("Có lỗi xảy ra khi in dữ liệu trên lưới" + Environment.NewLine +
            //            e.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
            //    }
            //    finally
            //    {

            //    }
            //}
            //else
            //{
            //    MessageBox.Show("Xuất báo cáo thất bại." + Environment.NewLine +
            //                                            "Có thể do bạn chưa cài MS Office 2003 trở lên", "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
            //}
        }