void ITopButton.Download()
        {
            if (this.dataGridView1.Rows.Count <= 0)
            {
                return;
            }

            try
            {
                this.Cursor = Cursors.WaitCursor;

                SaveFileDialog saveFileDialog = new SaveFileDialog();
                //saveFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
                //saveFileDialog.InitialDirectory = saveFileDialog.InitialDirectory = "{Desktop}";
                saveFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
                saveFileDialog.Filter           = "Excel File(*.xlsx)|*.xlsx";

                if (saveFileDialog.ShowDialog(this) == DialogResult.OK)
                {
                    ExcelDownload.GenerateExcel((DataTable)this.dataGridView1.DataSource, saveFileDialog.FileName, "Data");

                    MessageBox.Show(string.Format("File name '{0}' generated successfully.", saveFileDialog.FileName), "File generated successfully!", MessageBoxButtons.OK, MessageBoxIcon.None);
                }

                this.Cursor = Cursors.Default;
            }
            catch (Exception ex)
            {
                this.Cursor = Cursors.Default;
                MessageBox.Show(ex.Message, "Error - btnExcel_Click", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            List <UserManagerTest> testList = new List <UserManagerTest>
            {
                new UserManagerTest
                {
                    CreateDate = DateTime.Now, Name = "王二狗", Old = 20, Money = 3.76
                },
                new UserManagerTest
                {
                    CreateDate = DateTime.Now, Name = "李铁梅", Old = 30, Money = 9.78
                }
            };
            ExcelDownload downLoad = new ExcelDownload("员工信息", "年度员工汇总");

            downLoad.ExportExcel(testList);
        }
Exemple #3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            string gubun = xmlCommonUtil.GUBUN;

            if (!xmlCommonUtil.CheckSessionID() && !PassCheckSessionID)
            {
                return;
            }

            switch (gubun)
            {
            //sessionID_check
            case XMLCommonUtil.SESSIONID_CHECK_GUBUN:
            case XMLCommonUtil.GET_SESSIONID_GUBUN:
                xmlCommonUtil.returnSessionID();
                break;

            //userlogin
            case XMLCommonUtil.USER_LOGIN_GUBUN:
                xmlCommonUtil.WriteXML(true);
                break;

            case "menu_ctrl_bind":
                xmlCommonUtil.ReturnMenuXML();
                break;

            /*/sendSMS - 사용안함.
             * case "send_public_sms":
             *  string dataMmsPublicKey = xmlCommonUtil.QueryString["mms_public_key"];
             *  if (string.IsNullOrEmpty(dataMmsPublicKey))
             *  {
             *      break;
             *  }
             *  string mmsPublicKey = ConfigurationManager.AppSettings["mms_public_key"].ToString();
             *  if (!string.Equals(dataMmsPublicKey, mmsPublicKey))
             *  {
             *      break;
             *  }
             *
             *  SendMobileMSGCommon smmc2 = new SendMobileMSGCommon();
             *  smmc2.SendMobileMSG();
             *  break;
             * //*/

            case "send_sms":
                SendMobileMSGCommon smmc = new SendMobileMSGCommon();
                smmc.SendMobileMSG();
                break;

            case "csv":
                ExcelDownload ed = new ExcelDownload();
                ed.DownLoadCSVFile();
                break;

            case "send_email":
                SendEmail se = new SendEmail();
                se.send();
                break;

            case "upload_twitpic":
                UploadAndPostTwitPic ut = new UploadAndPostTwitPic();
                ut.UploadAndPost();
                break;

            /*기본 xml return *********************************/
            default:
                if (!string.IsNullOrEmpty(xmlCommonUtil.QueryString[XMLCommonUtil.PROC_KEY_STRING]))
                {
                    xmlCommonUtil.WriteXML(false);
                }
                else
                {
                    xmlCommonUtil.ResponseWriteErrorMSG("필수 매개변수를 넘기지 않았습니다.");
                    return;
                }
                break;
            }
        }
    }