Example #1
0
        public ActionResult PF(FormCollection form, HttpPostedFileBase InputFile)
        {
            if (InputFile != null)
            {
                Excel _excel = new Excel();
                byte[] excelByte = _excel.ImportaPF(InputFile.InputStream);

                if (excelByte != null)
                {
                    Response.Cache.SetCacheability(HttpCacheability.NoCache);
                    Response.Charset = "";
                    Response.ContentEncoding = System.Text.Encoding.GetEncoding("ISO-8859-1");
                    Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";

                    return File(excelByte, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "RegistrosNaoImportadosPF.xlsx");
                }
            }

            ViewBag.Sucesso = "Importação realizada com sucesso!";
            return View();
        }
Example #2
0
        public ActionResult ExportExcel()
        {
            string nome = null;
            int idRamo = 0;
            int idTipo = 0;

            if (Session["nome_export"] != null)
                nome = Session["nome_export"].ToString();
            if (Session["idRamo_export"] != null)
                idRamo = Convert.ToInt32(Session["idRamo_export"]);
            if (Session["idTipo_export"] != null)
                idTipo = Convert.ToInt32(Session["idTipo_export"]);

            string _nome = null;
            int? _idRamo = null;
            int? _idTipo = null;

            if (nome != null && nome.Length > 0)
                _nome = nome;
            if (idRamo > 0)
                _idRamo = idRamo;
            if (idTipo > 0)
                _idTipo = idTipo;

            Excel _excel = new Excel();
            byte[] excelByte = _excel.FiltroPJ(_nome, _idRamo, _idTipo);

            if (excelByte != null)
            {
                Response.Cache.SetCacheability(HttpCacheability.NoCache);
                Response.Charset = "";
                Response.ContentEncoding = System.Text.Encoding.GetEncoding("ISO-8859-1");
                Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";

                return File(excelByte, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "ListaPJ.xlsx");
            }

            return View();
        }
Example #3
0
        public ActionResult ExportExcel()
        {
            string nome = null;
            int inauguracao = 0;
            int especial = 0;
            int idOrigem = 0;
            int idProfissao = 0;

            if (Session["nome_export"] != null)
                nome = Session["nome_export"].ToString();
            if (Session["inauguracao_export"] != null)
                inauguracao = Convert.ToInt32(Session["inauguracao_export"]);
            if (Session["especial_export"] != null)
                especial = Convert.ToInt32(Session["especial_export"]);
            if (Session["origem_export"] != null)
                idOrigem = Convert.ToInt32(Session["origem_export"]);
            if (Session["profissao_export"] != null)
                idProfissao = Convert.ToInt32(Session["profissao_export"]);

            string _nome = null;
            bool? _inauguracao = null;
            bool? _especial = null;
            int? _idOrigem = null;
            int? _idProfissao = null;

            if (nome != null && nome.Length > 0)
                _nome = nome;
            if (inauguracao > 0)
                _inauguracao = inauguracao == 1 ? true : false;
            if (especial > 0)
                _especial = especial == 1 ? true : false;
            if (idOrigem > 0)
                _idOrigem = idOrigem;
            if (idProfissao > 0)
                _idProfissao = idProfissao;

            Excel _excel = new Excel();
            byte[] excelByte = _excel.FiltroPF(_nome, _inauguracao, _especial, _idOrigem, _idProfissao);

            if (excelByte != null)
            {
                Response.Cache.SetCacheability(HttpCacheability.NoCache);
                Response.Charset = "";
                Response.ContentEncoding = System.Text.Encoding.GetEncoding("ISO-8859-1");
                Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";

                return File(excelByte, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "ListaPF.xlsx");
            }

            return View();
        }