コード例 #1
0
    /// <summary>
    /// 导出Excel【支持导出噪声、降尘、空气类】
    /// </summary>
    /// <param name="year"></param>
    /// <param name="month"></param>
    /// <param name="XmlPath"></param>
    /// <param name="ExcelPath"></param>
    /// <param name="SheetName"></param>
    /// <returns></returns>
    public ISheet ExcelExportSpecial(string year, string month, string XmlPath, string ExcelPath, string SheetName)
    {
        string strXmlPath   = Server.MapPath(XmlPath);
        string strExcelPath = Server.MapPath(ExcelPath);
        ISheet sheet        = new i3.BusinessLogic.Channels.Env.Import.ImportExcelLogic().GetExportExcelSheetSpecial(strXmlPath, strExcelPath, SheetName, year, month);

        return(sheet);
    }
コード例 #2
0
    protected void btnExport_Click(object sender, EventArgs e)
    {
        string strXmlPath   = Server.MapPath("../../xmlTemp/Export/RiverTemple.xml");
        string strExcelPath = Server.MapPath("../../excelTemp/河流.xls");
        ISheet sheet        = new i3.BusinessLogic.Channels.Env.Import.ImportExcelLogic().GetExportExcelSheet(strXmlPath, strExcelPath, "Sheet1", "2013", "1");

        using (MemoryStream stream = new MemoryStream())
        {
            sheet.Workbook.Write(stream);
            HttpContext curContext = HttpContext.Current;
            // 设置编码和附件格式
            curContext.Response.ContentType     = "application/vnd.ms-excel";
            curContext.Response.ContentEncoding = Encoding.UTF8;
            curContext.Response.Charset         = "";
            curContext.Response.AppendHeader("Content-Disposition",
                                             "attachment;filename=" + HttpUtility.UrlEncode("江河水.xls", Encoding.UTF8));
            curContext.Response.BinaryWrite(stream.GetBuffer());
            curContext.Response.End();
        }
    }
コード例 #3
0
    protected void btn1_Click(object sender, EventArgs e)
    {
        if (this.fileUpload1.PostedFile.ContentLength >= 20971520)
        {
            LigerDialogAlert("上传的文件不能大于20M", "error"); return;
        }
        if (this.fileUpload1.PostedFile.ContentLength <= 0)
        {
            LigerDialogAlert("请选择文件", "error"); return;
        }
        Stream       stream       = this.fileUpload1.FileContent;
        HSSFWorkbook hssfworkbook = new HSSFWorkbook(stream);
        ISheet       sheet        = hssfworkbook.GetSheet("Sheet1");
        bool         isSuccess    = new i3.BusinessLogic.Channels.Env.Import.ImportExcelLogic().importExcelSpecial(Server.MapPath("../../xmlTemp/Import/FunctionNoiseTemple.xml"), sheet);

        if (isSuccess)
        {
            Alert("导入成功");
        }
        else
        {
            Alert("导入失败");
        }
    }
コード例 #4
0
    protected void btnImport_Click(object sender, EventArgs e)
    {
        bool   isSuccess = false;
        string strType   = Request["actions"];

        if (this.importFiles.PostedFile.ContentLength <= 0)
        {
            this.lable.Text    = "请选择文件!";
            this.lable.Visible = true;
            return;
        }
        Stream       stream       = this.importFiles.FileContent;
        HSSFWorkbook hssfworkbook = new HSSFWorkbook(stream);
        ISheet       sheet        = hssfworkbook.GetSheet("Sheet1");

        switch (strType)
        {
        case "Lake":     //湖库导入
            isSuccess = new i3.BusinessLogic.Channels.Env.Import.ImportExcelLogic().importExcel(Server.MapPath("../xmlTemp/ZZ_Import/LakeTemple.xml"), sheet);
            break;

        case "DrinkUnder":     //地下饮用水导入
            isSuccess = new i3.BusinessLogic.Channels.Env.Import.ImportExcelLogic().importExcel(Server.MapPath("../xmlTemp/ZZ_Import/DrinkUnderTemple.xml"), sheet);
            break;

        case "River":     //河流导入
            isSuccess = new i3.BusinessLogic.Channels.Env.Import.ImportExcelLogic().importExcel(Server.MapPath("../xmlTemp/ZZ_Import/RiverTemple.xml"), sheet);
            break;

        case "RiverCity":    //城考
            isSuccess = new i3.BusinessLogic.Channels.Env.Import.ImportExcelLogic().importExcel(Server.MapPath("../xmlTemp/ZZ_Import/RiverCityTemple.xml"), sheet);
            break;

        case "RiverPlan":    //规划断面
            isSuccess = new i3.BusinessLogic.Channels.Env.Import.ImportExcelLogic().importExcel(Server.MapPath("../xmlTemp/ZZ_Import/RiverPlanTemple.xml"), sheet);
            break;

        case "RiverTarget":    //责任目标
            isSuccess = new i3.BusinessLogic.Channels.Env.Import.ImportExcelLogic().importExcel(Server.MapPath("../xmlTemp/ZZ_Import/RiverTarget.xml"), sheet);
            break;

        case "DrinkSource":     //饮用水源地导入(地表)
            isSuccess = new i3.BusinessLogic.Channels.Env.Import.ImportExcelLogic().importExcel(Server.MapPath("../xmlTemp/ZZ_Import/DrinkSourceTemple.xml"), sheet);
            break;

        case "UnderDrinkSource":     //饮用水源地导入(地下)
            isSuccess = new i3.BusinessLogic.Channels.Env.Import.ImportExcelLogic().importExcel(Server.MapPath("../xmlTemp/ZZ_Import/UnderDrinkSourceTemple.xml"), sheet);
            break;

        case "Rain":    //降水
            isSuccess = new i3.BusinessLogic.Channels.Env.Import.ImportExcelLogic().importExcelSpecial(Server.MapPath("../xmlTemp/ZZ_Import/RainTemple.xml"), sheet);
            break;

        case "NoiseRoad":     //道路交通噪声导入
            isSuccess = new i3.BusinessLogic.Channels.Env.Import.ImportExcelLogic().importExcelSpecial(Server.MapPath("../xmlTemp/ZZ_Import/RoadNoiseTemple.xml"), sheet);
            break;

        case "NoiseFun":     //功能区噪声导入
            isSuccess = new i3.BusinessLogic.Channels.Env.Import.ImportExcelLogic().importExcelSpecial(Server.MapPath("../xmlTemp/ZZ_Import/FunctionNoiseTemple.xml"), sheet);
            break;

        case "NoiseArea":     //区域环境噪声导入
            isSuccess = new i3.BusinessLogic.Channels.Env.Import.ImportExcelLogic().importExcelSpecial(Server.MapPath("../xmlTemp/ZZ_Import/AreaNoiseTemple.xml"), sheet);
            break;
        }
        if (isSuccess)
        {
            this.lable.Text    = "导入成功!";
            this.lable.Visible = true;
        }
        else
        {
            this.lable.Text    = "导入失败!";
            this.lable.Visible = true;
        }
    }
コード例 #5
0
    protected void btnImport_Click(object sender, EventArgs e)
    {
        bool   isSuccess = false;
        string strType   = Request["actions"];

        if (this.importFiles.PostedFile.ContentLength <= 0)
        {
            //LigerDialogAlert("请选择文件", "error"); return;
            this.lable.Text    = "请选择文件!";
            this.lable.Visible = true;
            return;
        }
        Stream       stream       = this.importFiles.FileContent;
        HSSFWorkbook hssfworkbook = new HSSFWorkbook(stream);
        ISheet       sheet        = hssfworkbook.GetSheet("Sheet1");

        switch (strType)
        {
        case "Air":    //环境空气(天)
            //isSuccess = new i3.BusinessLogic.Channels.Env.Import.ImportExcelLogic().importExcelSpecial(Server.MapPath("../xmlTemp/Import/AirTemple.xml"), sheet);
            isSuccess = new i3.BusinessLogic.Channels.Env.Import.ImportExcelLogic().importExcelSpecial(Server.MapPath("../xmlTemp/QY_Import/AirTemple.xml"), sheet);
            break;

        case "AirHour":    //环境空气(小时)
            isSuccess = new i3.BusinessLogic.Channels.Env.Import.ImportExcelLogic().importExcelSpecial(Server.MapPath("../xmlTemp/Import/AirHourTemple.xml"), sheet);
            break;

        case "AirKs":    //环境空气科室(天)
            isSuccess = new i3.BusinessLogic.Channels.Env.Import.ImportExcelLogic().importExcelSpecial(Server.MapPath("../xmlTemp/Import/AirKsTemple.xml"), sheet);
            break;

        case "Dust":    //降尘
            // isSuccess = new i3.BusinessLogic.Channels.Env.Import.ImportExcelLogic().importExcelSpecial(Server.MapPath("../xmlTemp/Import/DustTemple.xml"), sheet);
            isSuccess = new i3.BusinessLogic.Channels.Env.Import.ImportExcelLogic().importExcelSpecial(Server.MapPath("../xmlTemp/QY_Import/DustTemple.xml"), sheet);
            break;

        case "Metal":    //底泥重金属
            // isSuccess = new i3.BusinessLogic.Channels.Env.Import.ImportExcelLogic().importExcelSpecial(Server.MapPath("../xmlTemp/Import/Metal.xml"), sheet);
            isSuccess = new i3.BusinessLogic.Channels.Env.Import.ImportExcelLogic().importExcelSpecial(Server.MapPath("../xmlTemp/QY_Import/Metal.xml"), sheet);
            break;

        case "Alkali":    //硫酸盐化速率
            isSuccess = new i3.BusinessLogic.Channels.Env.Import.ImportExcelLogic().importExcelSpecial(Server.MapPath("../xmlTemp/Import/AlkaliTemple.xml"), sheet);
            break;

        case "Rain":    //降水
            //isSuccess = new i3.BusinessLogic.Channels.Env.Import.ImportExcelLogic().importExcelSpecial(Server.MapPath("../xmlTemp/Import/RainTemple.xml"), sheet);
            isSuccess = new i3.BusinessLogic.Channels.Env.Import.ImportExcelLogic().importExcelSpecial(Server.MapPath("../xmlTemp/QY_Import/RainTemple.xml"), sheet);
            break;

        case "OffShore":     //近岸直排
            isSuccess = new i3.BusinessLogic.Channels.Env.Import.ImportExcelLogic().importExcelSpecial(Server.MapPath("../xmlTemp/Import/OffShoreTemple.xml"), sheet);
            break;

        case "Sea":     //近岸海域
            isSuccess = new i3.BusinessLogic.Channels.Env.Import.ImportExcelLogic().importExcelSpecial(Server.MapPath("../xmlTemp/Import/SeaTemple.xml"), sheet);
            break;

        case "Estuaries":     //入海河口
            isSuccess = new i3.BusinessLogic.Channels.Env.Import.ImportExcelLogic().importExcel(Server.MapPath("../xmlTemp/Import/EstuariesTemple.xml"), sheet);
            break;

        case "River":     //河流导入
            isSuccess = new i3.BusinessLogic.Channels.Env.Import.ImportExcelLogic().importExcel(Server.MapPath("../xmlTemp/QY_Import/RiverTemple.xml"), sheet);
            break;

        case "NoiseFun":     //功能区噪声导入
            isSuccess = new i3.BusinessLogic.Channels.Env.Import.ImportExcelLogic().importExcelSpecial(Server.MapPath("../xmlTemp/QY_Import/FunctionNoiseTemple.xml"), sheet);
            break;

        case "NoiseRoad":     //道路交通噪声导入
            isSuccess = new i3.BusinessLogic.Channels.Env.Import.ImportExcelLogic().importExcelSpecial(Server.MapPath("../xmlTemp/QY_Import/RoadNoiseTemple.xml"), sheet);
            break;

        case "NoiseArea":     //区域环境噪声导入
            isSuccess = new i3.BusinessLogic.Channels.Env.Import.ImportExcelLogic().importExcelSpecial(Server.MapPath("../xmlTemp/QY_Import/AreaNoiseTemple.xml"), sheet);
            break;

        case "DrinkSource":     //饮用水源地导入
            //isSuccess = new i3.BusinessLogic.Channels.Env.Import.ImportExcelLogic().importExcel(Server.MapPath("../xmlTemp/Import/DrinkSourceTemple.xml"), sheet);
            isSuccess = new i3.BusinessLogic.Channels.Env.Import.ImportExcelLogic().importExcel(Server.MapPath("../xmlTemp/QY_Import/DrinkSourceTemple.xml"), sheet);
            break;

        case "DrinkUnder":     //湖库饮用水导入
            isSuccess = new i3.BusinessLogic.Channels.Env.Import.ImportExcelLogic().importExcel(Server.MapPath("../xmlTemp/QY_Import/DrinkUnderTemple.xml"), sheet);
            //isSuccess = new i3.BusinessLogic.Channels.Env.Import.ImportExcelLogic().importExcel(Server.MapPath("../xmlTemp/Import/DrinkUnderTemple.xml"), sheet);
            break;

        case "Lake":     //湖库导入
            isSuccess = new i3.BusinessLogic.Channels.Env.Import.ImportExcelLogic().importExcel(Server.MapPath("../xmlTemp/Import/LakeTemple.xml"), sheet);
            break;

        case "PolluteWater":     //污染源常规(废水)导入
            isSuccess = new i3.BusinessLogic.Channels.Env.Import.ImportExcelLogic().ExcelSpecial(Server.MapPath("../xmlTemp/Import/PolluteWater.xml"), sheet);
            break;

        case "PolluteAir":     //污染源常规(废气)导入
            isSuccess = new i3.BusinessLogic.Channels.Env.Import.ImportExcelLogic().ExcelSpecialAir(Server.MapPath("../xmlTemp/Import/PolluteAir.xml"), sheet);
            break;
        }
        if (isSuccess)
        {
            this.lable.Text    = "导入成功!";
            this.lable.Visible = true;
        }
        else
        {
            this.lable.Text    = "导入失败!";
            this.lable.Visible = true;
        }
    }