예제 #1
0
        protected void btnImportXLS_Click(object sender, EventArgs e)
        {
            if (fuXlsFile.PostedFile != null && !String.IsNullOrEmpty(fuXlsFile.FileName))
            {
                try
                {
                    byte[] fileBytes = fuXlsFile.FileBytes;
                    string extension = "xls";
                    if (fuXlsFile.FileName.EndsWith("xlsx"))
                    {
                        extension = "xlsx";
                    }

                    string fileName = string.Format("customers_{0}.{1}", DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss"), extension);
                    string filePath = string.Format("{0}files\\ExportImport\\{1}", HttpContext.Current.Request.PhysicalApplicationPath, fileName);

                    File.WriteAllBytes(filePath, fileBytes);
                    ImportManager.ImportCustomersFromXLS(filePath);
                }
                catch (Exception ex)
                {
                    ProcessException(ex);
                }
            }
        }