Exemplo n.º 1
0
        public ActionResult XuatPhieu(ThongTinQHXD thongTinQHXD, QHCT_SUDUNGDAT quyHoachChiTietSDD, THONGTINDOAN thongTinDoAn, ImageQHXD imageQHXD)
        {
            thongTinQHXD.ThongTinDoAn       = thongTinDoAn;
            thongTinQHXD.QuyHoachChiTietSDD = quyHoachChiTietSDD;
            thongTinQHXD.ImageQHXD          = imageQHXD;
            var io   = new ExlThongTinQHXD();
            var path = HostingEnvironment.ApplicationPhysicalPath + @"/Resources/MauPhieu/MauPhieuThongTin_GIS.xlsx";

            HttpContext.Response.Headers.Add("Access-Control-Expose-Headers", "Content-Disposition");
            return(File(io.Build(path, thongTinQHXD), System.Net.Mime.MediaTypeNames.Application.Octet, "report.xlsx"));
        }
Exemplo n.º 2
0
        public byte[] Build(string path, ThongTinQHXD model)
        {
            FileInfo     fileInfo = new FileInfo(path);
            ExcelPackage p        = new ExcelPackage(fileInfo);

            this.myWorksheet = p.Workbook.Worksheets.First();

            setFieldValueExcel(THONGTINDOAN.TenDoAn, model.ThongTinDoAn.TenDoAn);
            setFieldValueExcel(THONGTINDOAN.DiaDiem, model.ThongTinDoAn.DiaDiem);
            setFieldValueExcel(THONGTINDOAN.ChuDauTu, model.ThongTinDoAn.ChuDauTu);
            setFieldValueExcel(THONGTINDOAN.NgayPheDuyet, model.NgayPheDuyet);
            setFieldValueExcel(THONGTINDOAN.SoQuyetDinhPheDuyet, model.ThongTinDoAn.SoQuyetDinhPheDuyet);
            setFieldValueExcel(THONGTINDOAN.NgayPheDuyet, model.ThongTinDoAn.NgayPheDuyet.ToString());
            setFieldValueExcel(THONGTINDOAN.CoQuanPheDuyet, model.ThongTinDoAn.CoQuanPheDuyet);
            setFieldValueExcel(QHCT_SUDUNGDAT.KiHieuLoDat, model.QuyHoachChiTietSDD.KiHieuLoDat);
            setFieldValueExcel(QHCT_SUDUNGDAT.KiHieuKhuDat, model.QuyHoachChiTietSDD.KiHieuKhuDat);
            setFieldValueExcel(QHCT_SUDUNGDAT.LoaiDat, model.QuyHoachChiTietSDD.LoaiDat);
            setFieldValueExcel(QHCT_SUDUNGDAT.ChucNang, model.QuyHoachChiTietSDD.ChucNang);
            setFieldValueExcel(QHCT_SUDUNGDAT.GiaiDoanQuyHoach, model.QuyHoachChiTietSDD.GiaiDoanQuyHoach);
            setFieldValueExcel(QHCT_SUDUNGDAT.DienTichLoDat, model.QuyHoachChiTietSDD.DienTichLoDat);
            setFieldValueExcel(QHCT_SUDUNGDAT.MatDoXayDung, model.QuyHoachChiTietSDD.MatDoXayDung);
            setFieldValueExcel(QHCT_SUDUNGDAT.TangCao, model.QuyHoachChiTietSDD.TangCao);
            setFieldValueExcel(QHCT_SUDUNGDAT.KhoangLuiChinh, model.QuyHoachChiTietSDD.KhoangLuiChinh);
            setFieldValueExcel(QHCT_SUDUNGDAT.KhoangLuiBien, model.QuyHoachChiTietSDD.KhoangLuiBien);
            setFieldValueExcel(QHCT_SUDUNGDAT.HeSoSuDungDat, model.QuyHoachChiTietSDD.HeSoSuDungDat);


            int rowIndex = 7;
            int colIndex = 3;

            int       Height = 235;
            int       Width  = 525;
            WebClient wc     = new WebClient();
            string    bbox   = null;

            if (model.ImageQHXD.url != null && model.ImageQHXD.xmin != null && model.ImageQHXD.xmin != null && model.ImageQHXD.xmax != null && model.ImageQHXD.ymax != null)
            {
                bbox = model.ImageQHXD.xmin + "," + model.ImageQHXD.ymin + "," + model.ImageQHXD.xmax + "," + model.ImageQHXD.ymax;
                string       url   = model.ImageQHXD.url + "/export?bbox=" + bbox + "&bboxSR=102100&imageSR=102100&size=1366%2C573&f=image&size=1366%2C573";
                byte[]       bytes = wc.DownloadData(url);
                MemoryStream ms    = new MemoryStream(bytes);
                Image        img   = Image.FromStream(ms);
                ExcelPicture pic   = this.myWorksheet.Drawings.AddPicture("Sample", img);
                pic.SetPosition(rowIndex, 0, colIndex, 0);
                pic.SetSize(Width, Height);
                this.myWorksheet.Protection.IsProtected            = false;
                this.myWorksheet.Protection.AllowSelectLockedCells = false;
            }

            return(p.GetAsByteArray());
        }