Example #1
0
            /// <summary>
            /// EXCEL 导入数据
            /// </summary>
            /// <param name="ProjectTypeID"></param>
            /// <returns></returns>
            public ActionResult ExcelToDb()
            {
                try
                {
                    var hpfb = Request.Files[0];
                    this.HandleUpFile(hpfb, new string[] { ".xlsx", ".xls" }, (file) =>
                    {
                        if (file == null || file.ContentLength < 1)
                        {
                            throw new MessageBox("请选择文件");
                        }
                    });

                    _Logic.ExcelToDb(hpfb.InputStream, (errorMsg) =>
                    {
                        if (!string.IsNullOrEmpty(errorMsg.ToStr()))
                        {
                            throw new MessageBox(errorMsg.ToString().Replace("\r\n", "<br />").Trim());
                        }
                    });

                    return(this.Success());
                }
                catch (Exception ex)
                {
                    throw new MessageBox(ex.Message.Replace("\r\n", "<br />").Trim());
                }
            }