Beispiel #1
0
        private bool createFileFormatXEAC(string sExcelFilePath, string[] oDestinyFiles, int nTotalMinutes)
        {
            bool bCreateFileFormatXEAC = false;

            StreamWriter    oCleanStreamWriter = null;
            StreamWriter    oDirtyStreamWriter = null;
            DataSet         oSheetDataSet      = null;
            ExcelConnection oExcelConnection   = null;

            string[] oPendings        = new string[] { FileFormatXEAC.NOT_EMISSION_VALUE + FileFormatXEAC.NOT_EMISSION_CHARACTER, FileFormatXEAC.NOT_EMISSION_VALUE + FileFormatXEAC.NOT_EMISSION_CHARACTER, FileFormatXEAC.NOT_EMISSION_VALUE + FileFormatXEAC.NOT_EMISSION_CHARACTER, FileFormatXEAC.NOT_EMISSION_VALUE + FileFormatXEAC.NOT_EMISSION_CHARACTER, FileFormatXEAC.NOT_EMISSION_VALUE + FileFormatXEAC.NOT_EMISSION_CHARACTER, FileFormatXEAC.NOT_EMISSION_VALUE + FileFormatXEAC.NOT_EMISSION_CHARACTER, FileFormatXEAC.NOT_EMISSION_VALUE + FileFormatXEAC.NOT_EMISSION_CHARACTER, FileFormatXEAC.NOT_EMISSION_VALUE + FileFormatXEAC.NOT_EMISSION_CHARACTER, FileFormatXEAC.NOT_EMISSION_VALUE + FileFormatXEAC.NOT_EMISSION_CHARACTER, FileFormatXEAC.NOT_EMISSION_VALUE + FileFormatXEAC.NOT_EMISSION_CHARACTER, FileFormatXEAC.NOT_EMISSION_VALUE + FileFormatXEAC.NOT_EMISSION_CHARACTER, FileFormatXEAC.NOT_EMISSION_VALUE + FileFormatXEAC.NOT_EMISSION_CHARACTER, FileFormatXEAC.NOT_EMISSION_VALUE + FileFormatXEAC.NOT_EMISSION_CHARACTER, FileFormatXEAC.NOT_EMISSION_VALUE + FileFormatXEAC.NOT_EMISSION_CHARACTER, FileFormatXEAC.NOT_EMISSION_VALUE + FileFormatXEAC.NOT_EMISSION_CHARACTER, FileFormatXEAC.NOT_EMISSION_VALUE + FileFormatXEAC.NOT_EMISSION_CHARACTER, FileFormatXEAC.NOT_EMISSION_VALUE + FileFormatXEAC.NOT_EMISSION_CHARACTER, FileFormatXEAC.NOT_EMISSION_VALUE + FileFormatXEAC.NOT_EMISSION_CHARACTER };
            string[] oIndependents    = new string[] { FileFormatXEAC.NOT_EMISSION_VALUE + FileFormatXEAC.NOT_EMISSION_CHARACTER, FileFormatXEAC.NOT_EMISSION_VALUE + FileFormatXEAC.NOT_EMISSION_CHARACTER, FileFormatXEAC.NOT_EMISSION_VALUE + FileFormatXEAC.NOT_EMISSION_CHARACTER, FileFormatXEAC.NOT_EMISSION_VALUE + FileFormatXEAC.NOT_EMISSION_CHARACTER, FileFormatXEAC.NOT_EMISSION_VALUE + FileFormatXEAC.NOT_EMISSION_CHARACTER, FileFormatXEAC.NOT_EMISSION_VALUE + FileFormatXEAC.NOT_EMISSION_CHARACTER, FileFormatXEAC.NOT_EMISSION_VALUE + FileFormatXEAC.NOT_EMISSION_CHARACTER, FileFormatXEAC.NOT_EMISSION_VALUE + FileFormatXEAC.NOT_EMISSION_CHARACTER, FileFormatXEAC.NOT_EMISSION_VALUE + FileFormatXEAC.NOT_EMISSION_CHARACTER, FileFormatXEAC.NOT_EMISSION_VALUE + FileFormatXEAC.NOT_EMISSION_CHARACTER, FileFormatXEAC.NOT_EMISSION_VALUE + FileFormatXEAC.NOT_EMISSION_CHARACTER, FileFormatXEAC.NOT_EMISSION_VALUE + FileFormatXEAC.NOT_EMISSION_CHARACTER, FileFormatXEAC.NOT_EMISSION_VALUE + FileFormatXEAC.NOT_EMISSION_CHARACTER, FileFormatXEAC.NOT_EMISSION_VALUE + FileFormatXEAC.NOT_EMISSION_CHARACTER, FileFormatXEAC.NOT_EMISSION_VALUE + FileFormatXEAC.NOT_EMISSION_CHARACTER, FileFormatXEAC.NOT_EMISSION_VALUE + FileFormatXEAC.NOT_EMISSION_CHARACTER, FileFormatXEAC.NOT_EMISSION_VALUE + FileFormatXEAC.NOT_EMISSION_CHARACTER, FileFormatXEAC.NOT_EMISSION_VALUE + FileFormatXEAC.NOT_EMISSION_CHARACTER };
            string[] oRanges          = new string[] { FileFormatXEAC.NOT_EMISSION_VALUE + FileFormatXEAC.NOT_EMISSION_CHARACTER, FileFormatXEAC.NOT_EMISSION_VALUE + FileFormatXEAC.NOT_EMISSION_CHARACTER, FileFormatXEAC.NOT_EMISSION_VALUE + FileFormatXEAC.NOT_EMISSION_CHARACTER, FileFormatXEAC.NOT_EMISSION_VALUE + FileFormatXEAC.NOT_EMISSION_CHARACTER, FileFormatXEAC.NOT_EMISSION_VALUE + FileFormatXEAC.NOT_EMISSION_CHARACTER, FileFormatXEAC.NOT_EMISSION_VALUE + FileFormatXEAC.NOT_EMISSION_CHARACTER, FileFormatXEAC.NOT_EMISSION_VALUE + FileFormatXEAC.NOT_EMISSION_CHARACTER, FileFormatXEAC.NOT_EMISSION_VALUE + FileFormatXEAC.NOT_EMISSION_CHARACTER, FileFormatXEAC.NOT_EMISSION_VALUE + FileFormatXEAC.NOT_EMISSION_CHARACTER, FileFormatXEAC.NOT_EMISSION_VALUE + FileFormatXEAC.NOT_EMISSION_CHARACTER, FileFormatXEAC.NOT_EMISSION_VALUE + FileFormatXEAC.NOT_EMISSION_CHARACTER, FileFormatXEAC.NOT_EMISSION_VALUE + FileFormatXEAC.NOT_EMISSION_CHARACTER, FileFormatXEAC.NOT_EMISSION_VALUE + FileFormatXEAC.NOT_EMISSION_CHARACTER, FileFormatXEAC.NOT_EMISSION_VALUE + FileFormatXEAC.NOT_EMISSION_CHARACTER, FileFormatXEAC.NOT_EMISSION_VALUE + FileFormatXEAC.NOT_EMISSION_CHARACTER, FileFormatXEAC.NOT_EMISSION_VALUE + FileFormatXEAC.NOT_EMISSION_CHARACTER, FileFormatXEAC.NOT_EMISSION_VALUE + FileFormatXEAC.NOT_EMISSION_CHARACTER, FileFormatXEAC.NOT_EMISSION_VALUE + FileFormatXEAC.NOT_EMISSION_CHARACTER };
            bool     bFinishDocuments = false;

            try {
                if (oDestinyFiles.Length == 8)
                {
                    oExcelConnection   = new ExcelConnection();
                    oCleanStreamWriter = new StreamWriter(oDestinyFiles[0]);
                    oDirtyStreamWriter = new StreamWriter(oDestinyFiles[1]);

                    for (int nSheet = 0; nSheet < Program.nNumElements; nSheet++)
                    {
                        int nCurrentMinute = 0;

                        oDirtyStreamWriter.Write(FileFormatXEAC.oCodes[nSheet]);
                        if (Array.IndexOf(FileFormatXEAC.oCleans, FileFormatXEAC.oCodes[nSheet]) != -1)
                        {
                            oCleanStreamWriter.Write(FileFormatXEAC.oCodes[nSheet]);
                        }

                        oSheetDataSet = oExcelConnection.load(sExcelFilePath, FileFormatXEAC.oPollutants[nSheet]);
                        if (oSheetDataSet != null)
                        {
                            if (oSheetDataSet.Tables[0].Columns.Count == 8)
                            {
                                string sCleanValue = "";
                                string sDirtyValue = "";
                                string sTypeValue  = "";

                                for (; nCurrentMinute < nTotalMinutes;)
                                {
                                    if ((4 + nCurrentMinute) < oSheetDataSet.Tables[0].Rows.Count)
                                    {
                                        DataRow oRow = oSheetDataSet.Tables[0].Rows[4 + nCurrentMinute];

                                        if (oRow[2].ToString().Trim().Length > 0)
                                        {
                                            sCleanValue = getDigitFormat(oRow[2].ToString().Trim());
                                        }
                                        else
                                        {
                                            sCleanValue = FileFormatXEAC.NOT_EMISSION_VALUE;
                                        }

                                        if (oRow[1].ToString().Trim().Length > 0)
                                        {
                                            sDirtyValue = getDigitFormat(oRow[1].ToString().Trim());
                                        }
                                        else
                                        {
                                            sDirtyValue = FileFormatXEAC.NOT_EMISSION_VALUE;
                                        }

                                        if (oRow[3].ToString().Trim().Length > 0)
                                        {
                                            sTypeValue = getEmissionTypeValue(oRow[3].ToString().Trim());
                                        }
                                        else
                                        {
                                            sTypeValue = FileFormatXEAC.NOT_EMISSION_CHARACTER;
                                        }

                                        if (sTypeValue == "S")
                                        {
                                            if (FileFormatXEAC.oPollutants[nSheet] == "H2O")
                                            {
                                                if (sCleanValue != FileFormatXEAC.NOT_EMISSION_VALUE)
                                                {
                                                    sCleanValue = "0015";
                                                }
                                                if (sDirtyValue != FileFormatXEAC.NOT_EMISSION_VALUE)
                                                {
                                                    sDirtyValue = "0015";
                                                }
                                            }
                                            else if (FileFormatXEAC.oPollutants[nSheet] == "O2")
                                            {
                                                if (sCleanValue != FileFormatXEAC.NOT_EMISSION_VALUE)
                                                {
                                                    sCleanValue = "0011";
                                                }
                                                if (sDirtyValue != FileFormatXEAC.NOT_EMISSION_VALUE)
                                                {
                                                    sDirtyValue = "0011";
                                                }
                                            }
                                            else if (FileFormatXEAC.oPollutants[nSheet] == "Temp")
                                            {
                                                if (sCleanValue != FileFormatXEAC.NOT_EMISSION_VALUE)
                                                {
                                                    sCleanValue = "0132";
                                                }
                                                if (sDirtyValue != FileFormatXEAC.NOT_EMISSION_VALUE)
                                                {
                                                    sDirtyValue = "0132";
                                                }
                                            }
                                            else if (FileFormatXEAC.oPollutants[nSheet] == "Press")
                                            {
                                                if (sCleanValue != FileFormatXEAC.NOT_EMISSION_VALUE)
                                                {
                                                    sCleanValue = "1013";
                                                }
                                                if (sDirtyValue != FileFormatXEAC.NOT_EMISSION_VALUE)
                                                {
                                                    sDirtyValue = "1013";
                                                }
                                            }
                                        }

                                        if ((oRow[1].ToString().Trim().Length == 0) || (oRow[2].ToString().Trim().Length == 0))
                                        {
                                            if (Program.bShowLog)
                                            {
                                                Program.writeLineInLogFile(Program.oLogFile, "{WARNING} No se han obtenido datos del Fichero Excel sobre el contaminante '" + FileFormatXEAC.oPollutants[nSheet] + "' del minuto " + nCurrentMinute + ", se pondra el dato de 'SIN MEDIDA' -> " + FileFormatXEAC.NOT_EMISSION_VALUE + FileFormatXEAC.NOT_EMISSION_CHARACTER, false);
                                            }
                                        }

                                        oDirtyStreamWriter.Write(sDirtyValue + sTypeValue);
                                        if (Array.IndexOf(FileFormatXEAC.oCleans, FileFormatXEAC.oCodes[nSheet]) != -1)
                                        {
                                            oCleanStreamWriter.Write(sCleanValue + sTypeValue);
                                        }

                                        if (nCurrentMinute == (nTotalMinutes - 1))
                                        {
                                            if (!((nSheet == 0) || (nSheet == 1) || (nSheet == 7) || (nSheet == 8) || (nSheet == 10) || (nSheet == 11) || (nSheet == 12) || (nSheet == 15)))
                                            {
                                                if (oRow[7].ToString().Trim().Length > 0)
                                                {
                                                    oPendings[nSheet] = getDigitFormat(oRow[7].ToString().Trim()) + sTypeValue;
                                                }
                                                else
                                                {
                                                    oPendings[nSheet] = FileFormatXEAC.NOT_EMISSION_VALUE + FileFormatXEAC.NOT_EMISSION_CHARACTER;
                                                }

                                                if (oRow[6].ToString().Trim().Length > 0)
                                                {
                                                    oIndependents[nSheet] = getDigitFormat(oRow[6].ToString().Trim()) + sTypeValue;
                                                }
                                                else
                                                {
                                                    oIndependents[nSheet] = FileFormatXEAC.NOT_EMISSION_VALUE + FileFormatXEAC.NOT_EMISSION_CHARACTER;
                                                }

                                                if (oRow[5].ToString().Trim().Length > 0)
                                                {
                                                    oRanges[nSheet] = getDigitFormat(oRow[5].ToString().Trim()) + sTypeValue;
                                                }
                                                else
                                                {
                                                    oRanges[nSheet] = FileFormatXEAC.NOT_EMISSION_VALUE + FileFormatXEAC.NOT_EMISSION_CHARACTER;
                                                }
                                            }
                                            else
                                            {
                                                if (oRow[7].ToString().Trim().Length > 0)
                                                {
                                                    oPendings[nSheet] = "1.00" + sTypeValue;
                                                }
                                                else
                                                {
                                                    oPendings[nSheet] = FileFormatXEAC.NOT_EMISSION_VALUE + FileFormatXEAC.NOT_EMISSION_CHARACTER;
                                                }

                                                if (oRow[6].ToString().Trim().Length > 0)
                                                {
                                                    oIndependents[nSheet] = "0.00" + sTypeValue;
                                                }
                                                else
                                                {
                                                    oIndependents[nSheet] = FileFormatXEAC.NOT_EMISSION_VALUE + FileFormatXEAC.NOT_EMISSION_CHARACTER;
                                                }

                                                if (oRow[5].ToString().Trim().Length > 0)
                                                {
                                                    oRanges[nSheet] = "0.00" + sTypeValue;
                                                }
                                                else
                                                {
                                                    oRanges[nSheet] = FileFormatXEAC.NOT_EMISSION_VALUE + FileFormatXEAC.NOT_EMISSION_CHARACTER;
                                                }
                                            }
                                        }

                                        if (nCurrentMinute == 59)
                                        {
                                            bFinishDocuments = true;
                                        }

                                        oRow = null;
                                    }
                                    else
                                    {
                                        sCleanValue = FileFormatXEAC.NOT_EMISSION_VALUE;
                                        sDirtyValue = FileFormatXEAC.NOT_EMISSION_VALUE;
                                        sTypeValue  = FileFormatXEAC.NOT_EMISSION_CHARACTER;

                                        if (Program.bShowLog)
                                        {
                                            Program.writeLineInLogFile(Program.oLogFile, "{WARNING} No se han obtenido datos del Fichero Excel sobre el contaminante '" + FileFormatXEAC.oPollutants[nSheet] + "' del minuto " + nCurrentMinute + ", se pondra el dato de 'SIN MEDIDA' -> " + FileFormatXEAC.NOT_EMISSION_VALUE + FileFormatXEAC.NOT_EMISSION_CHARACTER, false);
                                        }

                                        oDirtyStreamWriter.Write(sDirtyValue + sTypeValue);
                                        if (Array.IndexOf(FileFormatXEAC.oCleans, FileFormatXEAC.oCodes[nSheet]) != -1)
                                        {
                                            oCleanStreamWriter.Write(sCleanValue + sTypeValue);
                                        }

                                        if (nCurrentMinute == (nTotalMinutes - 1))
                                        {
                                            oPendings[nSheet]     = FileFormatXEAC.NOT_EMISSION_VALUE + FileFormatXEAC.NOT_EMISSION_CHARACTER;
                                            oIndependents[nSheet] = FileFormatXEAC.NOT_EMISSION_VALUE + FileFormatXEAC.NOT_EMISSION_CHARACTER;
                                            oRanges[nSheet]       = FileFormatXEAC.NOT_EMISSION_VALUE + FileFormatXEAC.NOT_EMISSION_CHARACTER;
                                        }

                                        if (nCurrentMinute == 59)
                                        {
                                            bFinishDocuments = true;
                                        }
                                    }

                                    nCurrentMinute++;
                                }
                            }
                            else
                            {
                                if (Program.bShowLog)
                                {
                                    Program.writeLineInLogFile(Program.oLogFile, "{WARNING} No se han obtenido las 8 columnas del Fichero Excel sobre el contaminante '" + FileFormatXEAC.oPollutants[nSheet] + "', se pondran datos de 'SIN MEDIDA' -> " + FileFormatXEAC.NOT_EMISSION_VALUE + FileFormatXEAC.NOT_EMISSION_CHARACTER + " en todos los minutos (" + nTotalMinutes + ")", false);
                                }

                                for (nCurrentMinute = 0; nCurrentMinute < nTotalMinutes; nCurrentMinute++)
                                {
                                    oDirtyStreamWriter.Write(FileFormatXEAC.NOT_EMISSION_VALUE + FileFormatXEAC.NOT_EMISSION_CHARACTER);

                                    if (Array.IndexOf(FileFormatXEAC.oCleans, FileFormatXEAC.oCodes[nSheet]) != -1)
                                    {
                                        oCleanStreamWriter.Write(FileFormatXEAC.NOT_EMISSION_VALUE + FileFormatXEAC.NOT_EMISSION_CHARACTER);
                                    }
                                }

                                oPendings[nSheet]     = FileFormatXEAC.NOT_EMISSION_VALUE + FileFormatXEAC.NOT_EMISSION_CHARACTER;
                                oIndependents[nSheet] = FileFormatXEAC.NOT_EMISSION_VALUE + FileFormatXEAC.NOT_EMISSION_CHARACTER;
                                oRanges[nSheet]       = FileFormatXEAC.NOT_EMISSION_VALUE + FileFormatXEAC.NOT_EMISSION_CHARACTER;

                                if (nTotalMinutes == 60)
                                {
                                    bFinishDocuments = true;
                                }
                            }

                            oSheetDataSet.Tables.Clear();
                            oSheetDataSet.Dispose();
                            oSheetDataSet = null;
                        }
                        else
                        {
                            if (Program.bShowLog)
                            {
                                Program.writeLineInLogFile(Program.oLogFile, "{WARNING} No se han obtenido datos del Fichero Excel sobre el contaminante '" + FileFormatXEAC.oPollutants[nSheet] + "', se pondran datos de 'SIN MEDIDA' -> " + FileFormatXEAC.NOT_EMISSION_VALUE + FileFormatXEAC.NOT_EMISSION_CHARACTER + " en todos los minutos (" + nTotalMinutes + ")", false);
                            }

                            for (nCurrentMinute = 0; nCurrentMinute < nTotalMinutes; nCurrentMinute++)
                            {
                                oDirtyStreamWriter.Write(FileFormatXEAC.NOT_EMISSION_VALUE + FileFormatXEAC.NOT_EMISSION_CHARACTER);

                                if (Array.IndexOf(FileFormatXEAC.oCleans, FileFormatXEAC.oCodes[nSheet]) != -1)
                                {
                                    oCleanStreamWriter.Write(FileFormatXEAC.NOT_EMISSION_VALUE + FileFormatXEAC.NOT_EMISSION_CHARACTER);
                                }
                            }

                            oPendings[nSheet]     = FileFormatXEAC.NOT_EMISSION_VALUE + FileFormatXEAC.NOT_EMISSION_CHARACTER;
                            oIndependents[nSheet] = FileFormatXEAC.NOT_EMISSION_VALUE + FileFormatXEAC.NOT_EMISSION_CHARACTER;
                            oRanges[nSheet]       = FileFormatXEAC.NOT_EMISSION_VALUE + FileFormatXEAC.NOT_EMISSION_CHARACTER;

                            if (nTotalMinutes == 60)
                            {
                                bFinishDocuments = true;
                            }
                        }

                        if (nSheet != 17)
                        {
                            oDirtyStreamWriter.Write(Environment.NewLine);
                            if (Array.IndexOf(FileFormatXEAC.oCleans, FileFormatXEAC.oCodes[nSheet]) != -1)
                            {
                                oCleanStreamWriter.Write(Environment.NewLine);
                            }
                        }
                    }

                    oDirtyStreamWriter.Write(Environment.NewLine);
                    oDirtyStreamWriter.Write(FileFormatXEAC.oCodes[18]);
                    for (int j = 0; j < Program.nNumElements; j++)
                    {
                        oDirtyStreamWriter.Write(oPendings[j]);
                    }

                    oDirtyStreamWriter.Write(Environment.NewLine);
                    oDirtyStreamWriter.Write(FileFormatXEAC.oCodes[19]);
                    for (int j = 0; j < Program.nNumElements; j++)
                    {
                        oDirtyStreamWriter.Write(oIndependents[j]);
                    }

                    oDirtyStreamWriter.Write(Environment.NewLine);
                    oDirtyStreamWriter.Write(FileFormatXEAC.oCodes[20]);
                    for (int j = 0; j < Program.nNumElements; j++)
                    {
                        oDirtyStreamWriter.Write(oRanges[j]);
                    }

                    oCleanStreamWriter.Flush();
                    oDirtyStreamWriter.Flush();

                    oCleanStreamWriter.Close();
                    oDirtyStreamWriter.Close();

                    if (bFinishDocuments)
                    {
                        try {
                            File.Copy(oDestinyFiles[0], Program.FOLDER_DESTINY_XEAC_COPY + oDestinyFiles[2] + "\\" + oDestinyFiles[4] + "\\" + oDestinyFiles[5] + "\\" + oDestinyFiles[6]);
                            File.Copy(oDestinyFiles[1], Program.FOLDER_DESTINY_XEAC_COPY + oDestinyFiles[3] + "\\" + oDestinyFiles[4] + "\\" + oDestinyFiles[5] + "\\" + oDestinyFiles[7]);
                        }
                        catch (Exception) { }
                    }

                    bCreateFileFormatXEAC = true;
                }
            } catch (Exception e) {
                if (oCleanStreamWriter != null)
                {
                    oCleanStreamWriter.Close();
                }
                if (oDirtyStreamWriter != null)
                {
                    oDirtyStreamWriter.Close();
                }

                if (File.Exists(oDestinyFiles[0]))
                {
                    File.Delete(oDestinyFiles[0]);
                }
                if (File.Exists(oDestinyFiles[1]))
                {
                    File.Delete(oDestinyFiles[1]);
                }

                if (Program.bShowLog)
                {
                    Program.writeLineInLogFile(Program.oLogFile, "{ERROR} Error durante la transformación del Fichero Excel al formato del Fichero XEAC: " + e.ToString(), false);
                }
            }

            oCleanStreamWriter = null;
            oDirtyStreamWriter = null;
            oSheetDataSet      = null;
            oExcelConnection   = null;
            oPendings          = null;
            oIndependents      = null;
            oRanges            = null;

            return(bCreateFileFormatXEAC);
        }
Beispiel #2
0
        private bool createFileFormatXEAC(string sExcelFilePath, string[] oDestinyFiles, int nTotalMinutes)
        {
            bool bCreateFileFormatXEAC = false;

            StreamWriter    oCleanStreamWriter = null;
            StreamWriter    oDirtyStreamWriter = null;
            DataSet         oSheetDataSet      = null;
            ExcelConnection oExcelConnection   = null;

            try {
                if (oDestinyFiles.Length == 8)
                {
                    oExcelConnection   = new ExcelConnection();
                    oCleanStreamWriter = new StreamWriter(oDestinyFiles[0]);
                    oDirtyStreamWriter = new StreamWriter(oDestinyFiles[1]);

                    for (int nSheet = 0; nSheet < Program.nNumElements; nSheet++)
                    {
                        int nCurrentMinute = 0;

                        oDirtyStreamWriter.Write(FileFormatXEACReports.oCodes[nSheet]);
                        oCleanStreamWriter.Write(FileFormatXEACReports.oCodes[nSheet]);

                        oSheetDataSet = oExcelConnection.load(sExcelFilePath, FileFormatXEACReports.oPollutants[nSheet]);
                        if (oSheetDataSet != null)
                        {
                            if (oSheetDataSet.Tables[0].Columns.Count == 8)
                            {
                                string sCleanValue = "";
                                string sDirtyValue = "";
                                string sTypeValue  = "";

                                for (; nCurrentMinute < nTotalMinutes;)
                                {
                                    if ((4 + nCurrentMinute) < oSheetDataSet.Tables[0].Rows.Count)
                                    {
                                        DataRow oRow = oSheetDataSet.Tables[0].Rows[4 + nCurrentMinute];

                                        if (oRow[2].ToString().Trim().Length > 0)
                                        {
                                            sCleanValue = getDigitFormat(oRow[2].ToString().Trim());
                                        }
                                        else
                                        {
                                            sCleanValue = FileFormatXEACReports.NOT_EMISSION_VALUE;
                                        }

                                        if (oRow[1].ToString().Trim().Length > 0)
                                        {
                                            sDirtyValue = getDigitFormat(oRow[1].ToString().Trim());
                                        }
                                        else
                                        {
                                            sDirtyValue = FileFormatXEACReports.NOT_EMISSION_VALUE;
                                        }

                                        if (oRow[3].ToString().Trim().Length > 0)
                                        {
                                            sTypeValue = getEmissionTypeValue(oRow[3].ToString().Trim());
                                        }
                                        else
                                        {
                                            sTypeValue = FileFormatXEACReports.NOT_EMISSION_CHARACTER;
                                        }

                                        if (sTypeValue == "S")
                                        {
                                            if (FileFormatXEACReports.oPollutants[nSheet] == "H2O")
                                            {
                                                if (sCleanValue != FileFormatXEACReports.NOT_EMISSION_VALUE)
                                                {
                                                    sCleanValue = "0015";
                                                }
                                                if (sDirtyValue != FileFormatXEACReports.NOT_EMISSION_VALUE)
                                                {
                                                    sDirtyValue = "0015";
                                                }
                                            }
                                            else if (FileFormatXEACReports.oPollutants[nSheet] == "O2")
                                            {
                                                if (sCleanValue != FileFormatXEACReports.NOT_EMISSION_VALUE)
                                                {
                                                    sCleanValue = "0011";
                                                }
                                                if (sDirtyValue != FileFormatXEACReports.NOT_EMISSION_VALUE)
                                                {
                                                    sDirtyValue = "0011";
                                                }
                                            }
                                            else if (FileFormatXEACReports.oPollutants[nSheet] == "Temp")
                                            {
                                                if (sCleanValue != FileFormatXEACReports.NOT_EMISSION_VALUE)
                                                {
                                                    sCleanValue = "0132";
                                                }
                                                if (sDirtyValue != FileFormatXEACReports.NOT_EMISSION_VALUE)
                                                {
                                                    sDirtyValue = "0132";
                                                }
                                            }
                                            else if (FileFormatXEACReports.oPollutants[nSheet] == "Press")
                                            {
                                                if (sCleanValue != FileFormatXEACReports.NOT_EMISSION_VALUE)
                                                {
                                                    sCleanValue = "1013";
                                                }
                                                if (sDirtyValue != FileFormatXEACReports.NOT_EMISSION_VALUE)
                                                {
                                                    sDirtyValue = "1013";
                                                }
                                            }
                                        }

                                        if ((oRow[1].ToString().Trim().Length == 0) || (oRow[2].ToString().Trim().Length == 0))
                                        {
                                            if (Program.bShowLog)
                                            {
                                                Program.writeLineInLogFile(Program.oLogFile, "{WARNING} No se han obtenido datos del Fichero Excel sobre el contaminante '" + FileFormatXEACReports.oPollutants[nSheet] + "' del minuto " + nCurrentMinute + ", se pondra el dato de 'SIN MEDIDA' -> " + FileFormatXEACReports.NOT_EMISSION_VALUE + FileFormatXEACReports.NOT_EMISSION_CHARACTER, false);
                                            }
                                        }

                                        oDirtyStreamWriter.Write(sDirtyValue + sTypeValue);
                                        oCleanStreamWriter.Write(sCleanValue + sTypeValue);

                                        oRow = null;
                                    }
                                    else
                                    {
                                        sCleanValue = FileFormatXEACReports.NOT_EMISSION_VALUE;
                                        sDirtyValue = FileFormatXEACReports.NOT_EMISSION_VALUE;
                                        sTypeValue  = FileFormatXEACReports.NOT_EMISSION_CHARACTER;

                                        if (Program.bShowLog)
                                        {
                                            Program.writeLineInLogFile(Program.oLogFile, "{WARNING} No se han obtenido datos del Fichero Excel sobre el contaminante '" + FileFormatXEACReports.oPollutants[nSheet] + "' del minuto " + nCurrentMinute + ", se pondra el dato de 'SIN MEDIDA' -> " + FileFormatXEACReports.NOT_EMISSION_VALUE + FileFormatXEACReports.NOT_EMISSION_CHARACTER, false);
                                        }

                                        oDirtyStreamWriter.Write(sDirtyValue + sTypeValue);
                                        oCleanStreamWriter.Write(sCleanValue + sTypeValue);
                                    }

                                    nCurrentMinute++;
                                }
                            }
                            else
                            {
                                if (Program.bShowLog)
                                {
                                    Program.writeLineInLogFile(Program.oLogFile, "{WARNING} No se han obtenido las 8 columnas del Fichero Excel sobre el contaminante '" + FileFormatXEACReports.oPollutants[nSheet] + "', se pondran datos de 'SIN MEDIDA' -> " + FileFormatXEACReports.NOT_EMISSION_VALUE + FileFormatXEACReports.NOT_EMISSION_CHARACTER + " en todos los minutos (" + nTotalMinutes + ")", false);
                                }

                                for (nCurrentMinute = 0; nCurrentMinute < nTotalMinutes; nCurrentMinute++)
                                {
                                    oDirtyStreamWriter.Write(FileFormatXEACReports.NOT_EMISSION_VALUE + FileFormatXEACReports.NOT_EMISSION_CHARACTER);

                                    oCleanStreamWriter.Write(FileFormatXEACReports.NOT_EMISSION_VALUE + FileFormatXEACReports.NOT_EMISSION_CHARACTER);
                                }
                            }

                            oSheetDataSet.Tables.Clear();
                            oSheetDataSet.Dispose();
                            oSheetDataSet = null;
                        }
                        else
                        {
                            if (Program.bShowLog)
                            {
                                Program.writeLineInLogFile(Program.oLogFile, "{WARNING} No se han obtenido datos del Fichero Excel sobre el contaminante '" + FileFormatXEACReports.oPollutants[nSheet] + "', se pondran datos de 'SIN MEDIDA' -> " + FileFormatXEACReports.NOT_EMISSION_VALUE + FileFormatXEACReports.NOT_EMISSION_CHARACTER + " en todos los minutos (" + nTotalMinutes + ")", false);
                            }

                            for (nCurrentMinute = 0; nCurrentMinute < nTotalMinutes; nCurrentMinute++)
                            {
                                oDirtyStreamWriter.Write(FileFormatXEACReports.NOT_EMISSION_VALUE + FileFormatXEACReports.NOT_EMISSION_CHARACTER);

                                oCleanStreamWriter.Write(FileFormatXEACReports.NOT_EMISSION_VALUE + FileFormatXEACReports.NOT_EMISSION_CHARACTER);
                            }
                        }

                        if (nSheet != 17)
                        {
                            oDirtyStreamWriter.Write(Environment.NewLine);
                            oCleanStreamWriter.Write(Environment.NewLine);
                        }
                    }

                    oCleanStreamWriter.Flush();
                    oDirtyStreamWriter.Flush();

                    oCleanStreamWriter.Close();
                    oDirtyStreamWriter.Close();

                    oSheetDataSet         = null;
                    bCreateFileFormatXEAC = true;
                }
            } catch (Exception e) {
                if (oCleanStreamWriter != null)
                {
                    oCleanStreamWriter.Close();
                }
                if (oDirtyStreamWriter != null)
                {
                    oDirtyStreamWriter.Close();
                }

                if (File.Exists(oDestinyFiles[0]))
                {
                    File.Delete(oDestinyFiles[0]);
                }
                if (File.Exists(oDestinyFiles[1]))
                {
                    File.Delete(oDestinyFiles[1]);
                }

                if (Program.bShowLog)
                {
                    Program.writeLineInLogFile(Program.oLogFile, "{ERROR} Error durante la transformación del Fichero Excel al formato del Fichero XEAC: " + e.ToString(), false);
                }
            }

            oCleanStreamWriter = null;
            oDirtyStreamWriter = null;
            oSheetDataSet      = null;
            oExcelConnection   = null;

            return(bCreateFileFormatXEAC);
        }