The name '' does not exist in the current context. C #

0

Good afternoon I have a functionality to generate an Excel file from a template. By clicking on a button the code is executed and the data contained in the variables "listTema", "listaProyectos" says: The name '....' does not exist in the current context. I can not find the reason why these variables are without context.

    protected void btnGenerar_Click(object sender, EventArgs e)
    {
        FundacionBL fundacionBL = new FundacionBL();
        FundacionBE fundacionBE = new FundacionBE();
        fundacionBE = fundacionBL.Consultar(Convert.ToInt32(ddlFundacion.SelectedValue));

        hdServerPath.Value = Server.MapPath("../Archivos/Excel/");
        string sPlantillaOrigen = hdServerPath.Value + "PLANTILLA_PROYECTOS_SIF.xlsm";
        hdArchivoDestino.Value = fundacionBE.Sigla + "-ProyectosInvestigaciones.xlsm";

        // Generar archivo Excel de la fundación seleccionada.
        int idFundacion = Convert.ToInt32(ddlFundacion.SelectedValue.ToString());
        GenerarArchivoExcel(idFundacion, sPlantillaOrigen, hdServerPath.Value.ToString() + hdArchivoDestino.Value.ToString());

        // Mostrar mensaje final.
        this.Master.MostrarMensaje(Comunes.Constantes.MSJ_EXCEL_CREAR, SIFMasterPage.TipoMensaje.Informacion);
        btnDescargar.Visible = true;
    }

    private void GenerarArchivoExcel(int idFundacion, string sPlantillaOrigen, string sArchivoDestino)
    {
        // Cargar los temas para filtro de temas
        DominioBL dominioBL = new DominioBL();
        List<DominioBE> listaTema = new List<DominioBE>();
        listaTema = dominioBL.ConsultarTemas();

        // Cargar los proyectos de la fundación
        ProyectoExcelBL proyectoExcelBL = new ProyectoExcelBL();
        List<ProyectoExcelBE> listaProyectos = new List<ProyectoExcelBE>();
        listaProyectos = proyectoExcelBL.Consultar(idFundacion);

        // Si existe el archivo de salida se elimina primero.
        if (System.IO.File.Exists(sArchivoDestino)) System.IO.File.Delete(sArchivoDestino);

        System.Reflection.Missing Default = System.Reflection.Missing.Value;
        OfficeExcel.Application ExcelAPP = new OfficeExcel.Application();
        OfficeExcel._Workbook LibroWB = ExcelAPP.Workbooks.Open(sPlantillaOrigen, Default, Default, Default, Default, Default, Default, Default, Default, Default, Default, Default, Default, Default, Default);

        // Llenar la hoja oculta de Temas para el combo de Temas
        OfficeExcel._Worksheet HojaTema = (OfficeExcel._Worksheet)LibroWB.Worksheets["SeleccionarTema"];

        // TODO. Ciclo de la lista de Temas
        HojaTema.Cells[3, 1] = "OK";

        // Guardar Como el libro Excel destino.
        LibroWB.SaveAs(sArchivoDestino, Default, Default, Default, false, Default, OfficeExcel.XlSaveAsAccessMode.xlNoChange, Default, Default, Default, Default, Default);
        LibroWB.Close(Default, Default, Default);
        ExcelAPP.Quit();
    }

Thanks for the help you can provide

    
asked by AlejoR 15.11.2017 в 19:03
source

0 answers