Exemplo n.º 1
0
        private void insertComentarios(wp.Paragraph par, List<ReportRow> rows)
        {
            wp.Table tableComents;
            wp.TableRow trComents;
            wp.TableRow trHeader;
            wp.TableRow trComentsSep;
            wp.Paragraph parComentsSeparator;

            // vai buscar o template para os comentários
            String templateDoc = _projecto.Template_Mnemonica;

            String filename = rootPath + "docTemplates\\" + templateDoc + "_COMENTS.docx";
            wp.TableRow tr;

            using (WordprocessingDocument wordDoc = WordprocessingDocument.Open(filename, true))
            {

                tableComents = (wp.Table)wordDoc.MainDocumentPart.Document.Body.Elements<wp.Table>().ElementAt(0).Clone();

                trHeader = (wp.TableRow)tableComents.Elements<wp.TableRow>().ElementAt(0);
                trComents = (wp.TableRow)tableComents.Elements<wp.TableRow>().ElementAt(1);
                trComentsSep = (wp.TableRow)tableComents.Elements<wp.TableRow>().ElementAt(2);
                trComentsSep.Elements<wp.TableCell>().First().Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Elements<wp.Text>().First().Text = "";

                tableComents.Elements<wp.TableRow>().ElementAt(0).Remove();
                tableComents.Elements<wp.TableRow>().ElementAt(0).Remove();
                tableComents.Elements<wp.TableRow>().ElementAt(0).Remove();

                parComentsSeparator = (wp.Paragraph)wordDoc.MainDocumentPart.Document.Body.Elements<wp.Paragraph>().ElementAt(0);
            }

            // produzir a secção de comentários

            if (rows == null)
            {
                par.Append((wp.Paragraph)parComentsSeparator.Clone());
            }
            else
            {
                foreach (ReportRow rr in rows)
                {
                    if (rr.dados[0] == "BREAK")
                        tr = trComentsSep.Clone() as wp.TableRow;
                    else if (rr.dados[0] != "")
                    {
                        tr = trHeader.Clone() as wp.TableRow;
                        tr.Elements<wp.TableCell>().First().Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Elements<wp.Text>().First().Text = rr.dados[0];
                    }
                    else
                    {
                        tr = trComents.Clone() as wp.TableRow;
                        tr.Elements<wp.TableCell>().First().Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Elements<wp.Text>().First().Text = rr.dados[1];
                    }
                    tableComents.Append(tr);
                }
                par.Append(tableComents);
            }

            // eliminar o texto do marcador
            par.Elements<wp.Run>().First().Elements<wp.Text>().First().Text = "";
        }
Exemplo n.º 2
0
        private void insertDetailsSkill(wp.Paragraph par, MainDocumentPart mainPart)
        {
            // na primira fase fazer sem os gráficos

            // ir buscar o template
            // cria o documento final base com base no template
            String templateDoc = _projecto.Template_Mnemonica;

            String filename = rootPath + "docTemplates\\" + templateDoc + "_SKILS_DETAILS.docx";

            wp.Table tabTitulo1;

            wp.Table tab1;
            wp.TableRow rowTab1Par;
            wp.TableRow rowTab1Impar;

            wp.Run plusSign;
            wp.Run minusSign;
            wp.Run naSign;
            wp.Run eqSign;

            wp.Table legendaTab1;
            wp.Paragraph quebraPagina;

            using (WordprocessingDocument wordDoc = WordprocessingDocument.Open(filename, true))
            {
                // primeira tabela do template
                tabTitulo1 = (wp.Table)wordDoc.MainDocumentPart.Document.Body.Elements<wp.Table>().ElementAt(0).Clone();

                // primeira tabela com comportamentos
                tab1 = (wp.Table)wordDoc.MainDocumentPart.Document.Body.Elements<wp.Table>().ElementAt(1).Clone();
                rowTab1Impar = (wp.TableRow)tab1.Elements<wp.TableRow>().ElementAt(1).Clone();
                rowTab1Par = (wp.TableRow)tab1.Elements<wp.TableRow>().ElementAt(2).Clone();
                tab1.Elements<wp.TableRow>().ElementAt(1).Remove();
                tab1.Elements<wp.TableRow>().ElementAt(1).Remove();

                // apanha os run + e - (mais e menos)
                minusSign = (wp.Run)rowTab1Impar.Elements<wp.TableCell>().ElementAt(1).Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Clone();
                naSign = (wp.Run)rowTab1Impar.Elements<wp.TableCell>().ElementAt(2).Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Clone();
                plusSign = (wp.Run)rowTab1Par.Elements<wp.TableCell>().ElementAt(1).Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Clone();
                eqSign = (wp.Run)rowTab1Par.Elements<wp.TableCell>().ElementAt(2).Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Clone();

                // eliminar o mais e o menos das linhas e o tracinho
                rowTab1Impar.Elements<wp.TableCell>().ElementAt(1).Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Remove();
                rowTab1Impar.Elements<wp.TableCell>().ElementAt(2).Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Remove();
                rowTab1Par.Elements<wp.TableCell>().ElementAt(1).Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Remove();
                rowTab1Par.Elements<wp.TableCell>().ElementAt(2).Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Remove();

                // depois tenho algures aqui a legenda da tabela
                legendaTab1 = (wp.Table)wordDoc.MainDocumentPart.Document.Body.Elements<wp.Table>().ElementAt(2).Clone();

                //parágrafo quebra de página
                quebraPagina = new wp.Paragraph(new wp.Run(new wp.Text("")));
                quebraPagina.ParagraphProperties = new wp.ParagraphProperties();
                quebraPagina.ParagraphProperties.PageBreakBefore = new wp.PageBreakBefore();
                quebraPagina.ParagraphProperties.PageBreakBefore.Val = DocumentFormat.OpenXml.OnOffValue.FromBoolean(true);

            }
            // fim da recolha dos elementos template.
            // passamos para a inserção destes elementos para cada competência

            // eliminar o texto do marcador
            par.Elements<wp.Run>().First().Elements<wp.Text>().First().Text = "";

            wp.Paragraph p;
            wp.Run r;
            wp.Text t;
            wp.Table tab;

            wp.Table tab1Temp;

            wp.TableRow tab1r;
            wp.TableCell tab1c;

            int count = 0;

            String pergunta;
            String tempTexto;
            int contaPaginas = 1;

            foreach (FamiliaCompetencias fam in _Modelo.Familias.Values)
                foreach (Competencia comp in fam.Competencias.Values)
                {
                    // são duas páginas de detalhes por cada competência
                    // header da 1ªpágina

                    if (comp.Type == "C") continue; // é uma competência comentário
                    if (comp.Type == "D") continue; // é uma zona de derrailers

                    // Nome da competência
                    tab = (wp.Table)tabTitulo1.Clone();
                    p = tab.Elements<wp.TableRow>().ElementAt(0).Elements<wp.TableCell>().First().Elements<wp.Paragraph>().First();
                    r = p.Elements<wp.Run>().First();
                    t = r.Elements<wp.Text>().First();
                    t.Text = repCalcs.getCompetenciaText(comp.CompetenciaID);

                    par.Append(tab);// o nome da competência

                    // PREPARA AS DUAS TABELAS COM OS DETALHES
                    tab1Temp = (wp.Table)tab1.Clone();
                    // tab2Temp = (wp.Table)tab2.Clone();

                    // os valores obtidos em cada comportamento
                    List<ReportRow> dataComportamentos = repCalcs.getAvaliacaoComportamentosCriticos(comp.CompetenciaID);
                    List<ReportRow> dataComportamentosFracosFortes = repCalcs.getAvaliacaoComportamentosCriticos_FracosFortes(comp.CompetenciaID);
                    count = 0;
                    foreach (Pratica prat in comp.Praticas.Values)
                        foreach (Pergunta perg in prat.Perguntas.Values)
                        {
                            pergunta = repCalcs.getPergunta(perg.PerguntaID);
                            if (count % 2 == 0)
                            {
                                // linha par
                                tab1r = (wp.TableRow)rowTab1Par.Clone();
                                // tab2r = (wp.TableRow)rowTab2Par.Clone();
                            }
                            else
                            {
                                // linha impar
                                tab1r = (wp.TableRow)rowTab1Impar.Clone();
                                // tab2r = (wp.TableRow)rowTab2Impar.Clone();
                            }

                            tab1c = tab1r.Elements<wp.TableCell>().ElementAt(0);
                            // tab2c = tab2r.Elements<wp.TableCell>().ElementAt(0);

                            if (count + 1 < dataComportamentos.Count)
                            {
                                // introduz o texto da pergunta
                                tab1c.Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Elements<wp.Text>().First().Text = dataComportamentos[count + 1].dados[0];
                                // tab2c.Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Elements<wp.Text>().First().Text = dataComportamentos[count + 1].dados[0];
                                // introduz os valores de cada prática

                                // os mais e os menos desta linha (prática), por S;B;P;C;O
                                for (int i = 1; i < dataComportamentos[count + 1].dados.Length; i++ )
                                {
                                    tab1c = tab1r.Elements<wp.TableCell>().ElementAt(i);
                                    fillPlusMinus(tab1c, dataComportamentos[count + 1].dados[i], plusSign, minusSign, naSign, eqSign);
                                }
                            }

                            // junta às tabelas as linhas
                            tab1Temp.Append(tab1r);
                            // tab2Temp.Append(tab2r);

                            count++;
                        }

                    // INSERE A TABELA 1
                    par.Append(tab1Temp);
                    // LEGENDA 1

                    tempTexto = "";

                    //legendaTab1.Elements<wp.TableRow>().ElementAt(1).Elements<wp.TableCell>().First().Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Elements<wp.Text>().First().Text = tempTexto;
                    par.Append((wp.Table)legendaTab1.Clone());

                    // QUEBRA DE PÁGINA 1
                    par.Append((wp.Paragraph)quebraPagina.Clone());

                    // um parágrafo de espaçamento para que as tabelas não colem
                    par.Append(new wp.Paragraph());

                    contaPaginas++;
                }
        }
Exemplo n.º 3
0
 private void clearParagraphText(wp.Paragraph p)
 {
     foreach (wp.Run ru in p.Elements<wp.Run>())
     {
         foreach (wp.Text tx in ru.Elements<wp.Text>())
             tx.Text = "";
     }
 }
Exemplo n.º 4
0
 private void fillPlusMinus(wp.TableCell cell, String Value, wp.Run plus, wp.Run minus, wp.Run na, wp.Run eq)
 {
     if (Value == "*")
         cell.Elements<wp.Paragraph>().First().Append((wp.Run)na.Clone());
     else if (Value == "+")
         cell.Elements<wp.Paragraph>().First().Append((wp.Run)plus.Clone());
     else if (Value == "-")
         cell.Elements<wp.Paragraph>().First().Append((wp.Run)minus.Clone());
     else
         cell.Elements<wp.Paragraph>().First().Append((wp.Run)eq.Clone());
 }
Exemplo n.º 5
0
        //private void insertTable_Ranking(wp.Paragraph par, List<ReportRow> rows, String tipo)
        //{
        //    if (!rankingTables)
        //    {
        //        setupRankingTables();
        //    }
        //    if (rows == null)
        //    {
        //        par.Elements<wp.Run>().First().Elements<wp.Text>().First().Text = "";
        //        return;
        //    }
        //    // Selecionar o template apropriado
        //    wp.TableRow theRow;
        //    wp.Table theTable = (wp.Table)tableRankS.Clone();
        //    wp.Paragraph theHeader = (wp.Paragraph)parHeadingParS.Clone();
        //    switch (tipo)
        //    {
        //        case "T":
        //            theTable = (wp.Table)tableRankT.Clone();
        //            theHeader = (wp.Paragraph)parHeadingParT.Clone();
        //            break;
        //        case "B":
        //            theTable = (wp.Table)tableRankB.Clone();
        //            theHeader = (wp.Paragraph)parHeadingParB.Clone();
        //            break;
        //        case "C":
        //            theTable = (wp.Table)tableRankC.Clone();
        //            theHeader = (wp.Paragraph)parHeadingParC.Clone();
        //            break;
        //        case "P":
        //            theTable = (wp.Table)tableRankP.Clone();
        //            theHeader = (wp.Paragraph)parHeadingParP.Clone();
        //            break;
        //        case "O":
        //            theTable = (wp.Table)tableRankO.Clone();
        //            theHeader = (wp.Paragraph)parHeadingParO.Clone();
        //            break;
        //    }
        //    // criar a tabela
        //    int count = 0;
        //    wp.Paragraph tempPar;
        //    foreach (ReportRow rr in rows)
        //    {
        //        if (count % 2 == 0)
        //            theRow = (wp.TableRow)trRankRowPar.Clone();
        //        else
        //            theRow = (wp.TableRow)trRankRowImpar.Clone();
        //        for (int i = 0; i < rr.dados.Length; i++)
        //        {
        //            tempPar = theRow.Elements<wp.TableCell>().ElementAt(i).Elements<wp.Paragraph>().First();
        //            tempPar.Elements<wp.Run>().First().Elements<wp.Text>().First().Text = rr.dados[i];
        //        }
        //        theTable.Append(theRow);
        //        count++;
        //    }
        //    // INSERE O HEADER
        //    par.Append(theHeader);
        //    // INSERE A TABELA
        //    par.Append(theTable);
        //    // eliminar o texto do marcador
        //    clearParagraphText(par);
        //}
        private void insertTable_Gaps(wp.Paragraph par, List<ReportRow> rows, String tipo)
        {
            int index = 0;
            int counter = 0;

            if (!gapTables)
            {
                setupGapTables();
            }
            if (rows == null)
            {
                par.Elements<wp.Run>().First().Elements<wp.Text>().First().Text = "";
                return;
            }

            foreach (String s in _projecto.GroupsCodes)
            {
                if (s == tipo)
                {
                    index = counter;
                }
                counter++;
            }

            // Selecionar o template apropriado
            wp.TableRow theRow;
            wp.Table theTable = (wp.Table)tablesRank[index].Clone();
            wp.Paragraph theHeader = (wp.Paragraph)parsHeading[index].Clone();

            /*
            switch (tipo)
            {
                case "Co":
                    theTable = (wp.Table)tableRankB.Clone();
                    theHeader = (wp.Paragraph)parHeadingParB.Clone();
                    break;
                case "Me":
                    theTable = (wp.Table)tableRankC.Clone();
                    theHeader = (wp.Paragraph)parHeadingParC.Clone();
                    break;
                case "Mg":
                    theTable = (wp.Table)tableRankP.Clone();
                    theHeader = (wp.Paragraph)parHeadingParP.Clone();
                    break;
                case "Ve":
                    theTable = (wp.Table)tableRankO.Clone();
                    theHeader = (wp.Paragraph)parHeadingParO.Clone();
                    break;
                case "Pa":
                    theTable = (wp.Table)tableRankO.Clone();
                    theHeader = (wp.Paragraph)parHeadingParO.Clone();
                    break;
            }
            */

            // criar a tabela
            int count = 0;
            wp.Paragraph tempPar;

            foreach (ReportRow rr in rows)
            {
                if (count % 2 == 0)
                    theRow = (wp.TableRow)trRankRowPar.Clone();
                else
                    theRow = (wp.TableRow)trRankRowImpar.Clone();

                for (int i = 0; i < rr.dados.Length - 1; i++)
                {
                    tempPar = theRow.Elements<wp.TableCell>().ElementAt(i).Elements<wp.Paragraph>().First();
                    tempPar.Elements<wp.Run>().First().Elements<wp.Text>().First().Text = rr.dados[i];
                }

                //tempPar = theRow.Elements<wp.TableCell>().ElementAt(rr.dados.Length - 1).Elements<wp.Paragraph>().First();
                // wp.Run rSymbol = tempPar.Elements<wp.Run>().First();
                // rSymbol.Elements<wp.SymbolChar>().First().Char = rr.dados[rr.dados.Length - 1];

                if (rr.dados[rr.dados.Length - 1] == "F0F1")
                    theRow.Elements<wp.TableCell>().ElementAt(rr.dados.Length - 1).Elements<wp.Paragraph>().First().Append((wp.Run)UpSign.Clone());
                else if (rr.dados[rr.dados.Length - 1] == "F0F2")
                    theRow.Elements<wp.TableCell>().ElementAt(rr.dados.Length - 1).Elements<wp.Paragraph>().First().Append((wp.Run)EqSign.Clone());
                else
                    theRow.Elements<wp.TableCell>().ElementAt(rr.dados.Length - 1).Elements<wp.Paragraph>().First().Append((wp.Run)LessSign.Clone());

                theTable.Append(theRow);
                count++;
            }

            // INSERE O HEADER
            par.Append(theHeader);

            // INSERE A TABELA
            par.Append(theTable);

            // eliminar o texto do marcador
            clearParagraphText(par);
        }
Exemplo n.º 6
0
    private void insertTable_Ranking(wp.Paragraph par, List<ReportRow> rows, String tipo)
    {
        if (!rankingTables)
        {
            setupRankingTables();
        }
        if (rows == null)
        {
            par.Elements<wp.Run>().First().Elements<wp.Text>().First().Text = "";
            return;
        }
        // Selecionar o template apropriado por defeito fica o G0
        wp.TableRow theRow;
        wp.Table theTable = (wp.Table)tableRankS.Clone();
        wp.Paragraph theHeader = (wp.Paragraph)parHeadingParS.Clone();

        switch (tipo)
        {
            case "T":
                theTable = (wp.Table)tableRankT.Clone();
                theHeader = (wp.Paragraph)parHeadingParT.Clone();
                break;
            case "G1":
                theTable = (wp.Table)tableRankB.Clone();
                theHeader = (wp.Paragraph)parHeadingParB.Clone();
                break;
            case "G2":
                theTable = (wp.Table)tableRankC.Clone();
                theHeader = (wp.Paragraph)parHeadingParC.Clone();
                break;
            case "G3":
                theTable = (wp.Table)tableRankP.Clone();
                theHeader = (wp.Paragraph)parHeadingParP.Clone();
                break;
            case "G4":
                theTable = (wp.Table)tableRankO.Clone();
                theHeader = (wp.Paragraph)parHeadingParO.Clone();
                break;
        }

        // criar a tabela
        int count = 0;
        wp.Paragraph tempPar;

        foreach (ReportRow rr in rows)
        {
            if (count % 2 == 0)
                theRow = (wp.TableRow)trRankRowPar.Clone();
            else
                theRow = (wp.TableRow)trRankRowImpar.Clone();
            for (int i = 0; i < rr.dados.Length; i++)
            {
                tempPar = theRow.Elements<wp.TableCell>().ElementAt(i).Elements<wp.Paragraph>().First();
                tempPar.Elements<wp.Run>().First().Elements<wp.Text>().First().Text = rr.dados[i];
            }
            theTable.Append(theRow);
            count++;
        }

        // INSERE O HEADER
        par.Append(theHeader);

        // INSERE A TABELA
        par.Append(theTable);

        // eliminar o texto do marcador
        clearParagraphText(par);
    }
Exemplo n.º 7
0
    private void insertOverviewSkill(wp.Paragraph par, MainDocumentPart mainPart)
    {
        // ir buscar o template
        // cria o documento final base com base no template
        String templateDoc = _projecto.Template_Mnemonica;

        String filename = templatePath + "\\" + templateDoc + "_OVERVIEW_SKILS_DETAILS.docx";

        wp.Paragraph parHeading = null;

        wp.Table tab1 = null;
        wp.TableRow rowTab1Par = null;
        wp.TableRow rowTab1Impar = null;
        wp.TableRow rowTab1Linha3 = null;

        wp.Run red = null;
        wp.Run yellow = null;
        wp.Run green = null;

        wp.Table legendaTab2 = null;
        wp.Paragraph quebraPagina = null;

        using (WordprocessingDocument wordDoc = WordprocessingDocument.Open(filename, true))
        {
            try
            {
                // o primeiro Parágrafo tem o nome do subcapítulo
                parHeading = (wp.Paragraph)wordDoc.MainDocumentPart.Document.Body.Elements<wp.Paragraph>().ElementAt(0);

                // primeira tabela do template
                tab1 = (wp.Table)wordDoc.MainDocumentPart.Document.Body.Elements<wp.Table>().ElementAt(0).Clone();

                rowTab1Impar = (wp.TableRow)tab1.Elements<wp.TableRow>().ElementAt(1).Clone();
                rowTab1Par = (wp.TableRow)tab1.Elements<wp.TableRow>().ElementAt(2).Clone();
                rowTab1Linha3 = (wp.TableRow)tab1.Elements<wp.TableRow>().ElementAt(3).Clone();
                tab1.Elements<wp.TableRow>().ElementAt(1).Remove();
                tab1.Elements<wp.TableRow>().ElementAt(1).Remove();
                tab1.Elements<wp.TableRow>().ElementAt(1).Remove();

                // apanha os run + e - (mais e menos)
                green = (wp.Run)rowTab1Impar.Elements<wp.TableCell>().ElementAt(2).Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Clone();
                red = (wp.Run)rowTab1Par.Elements<wp.TableCell>().ElementAt(2).Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Clone();
                yellow = (wp.Run)rowTab1Linha3.Elements<wp.TableCell>().ElementAt(2).Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Clone();

                // eliminar o mais e o menos das linhas e o tracinho
                rowTab1Impar.Elements<wp.TableCell>().ElementAt(2).Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Remove();
                rowTab1Par.Elements<wp.TableCell>().ElementAt(2).Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Remove();
                rowTab1Linha3.Elements<wp.TableCell>().ElementAt(2).Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Remove();

            }
            catch
            {

            }

            //parágrafo quebra de página
            quebraPagina = new wp.Paragraph(new wp.Run(new wp.Text("")));
            quebraPagina.ParagraphProperties = new wp.ParagraphProperties();
            quebraPagina.ParagraphProperties.PageBreakBefore = new wp.PageBreakBefore();
            quebraPagina.ParagraphProperties.PageBreakBefore.Val = DocumentFormat.OpenXml.OnOffValue.FromBoolean(true);

        }
        // fim da recolha dos elementos template.
        // passamos para a inserção destes elementos para cada competência

        // eliminar o texto do marcador
        par.Elements<wp.Run>().First().Elements<wp.Text>().First().Text = "";

        wp.Paragraph p = null;
        wp.Run r = null;
        wp.Text t = null;
        wp.Table tab1Temp = null;

        wp.TableRow tab1r = null;
        wp.TableCell tab1c = null;

        int count = 0;

        String pergunta;
        //String tempTexto;
        int contaPaginas = 1;

        String gap;

        foreach (FamiliaCompetencias fam in _Modelo.Familias.Values)
            foreach (Competencia comp in fam.Competencias.Values)
            {
                // são duas páginas de detalhes por cada competência
                // header da 1ªpágina

                if (comp.Type == "C") continue; // é uma competência comentário
                if (comp.Type == "D") continue; // é uma zona de derrailers

                // Nome da competência
                p = (wp.Paragraph)parHeading.Clone();
                r = p.Elements<wp.Run>().First();
                t = r.Elements<wp.Text>().First();
                t.Text = repCalcs.getCompetenciaText(comp.CompetenciaID);

                par.Append(p);

                // PREPARA A TABELA COM OS DETALHES
                tab1Temp = (wp.Table)tab1.Clone();
                tab1r = (wp.TableRow)tab1Temp.Elements<wp.TableRow>().ElementAt(0); // header da tabela
                tab1c = tab1r.Elements<wp.TableCell>().ElementAt(0); // c´clula com o local para o texto

                // os valores obtidos em cada comportamento
                // List<ReportRow> dataComportamentos = repCalcs.getAvaliacaoComportamentosCriticos(comp.CompetenciaID);
                List<ReportRow> dataComportamentosFracosFortes = repCalcs.getAvaliacaoComportamentosCriticos_FracosFortes_3Fatores(comp.CompetenciaID);
                count = 0;
                foreach (Pratica prat in comp.Praticas.Values)
                {
                    if (tab1c.Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Elements<wp.Text>().First().Text == "#TEXT_PRATICA#")
                    {
                        String plainText;
                        if (Utility.theServer != null)
                            plainText = Regex.Replace(Utility.theServer.HtmlDecode(prat.Description), "<[^>]+?>", "");
                        else
                            plainText = prat.Description;

                        plainText = DBHelper.ParseTextProprio(plainText, new Pessoa(), false);

                        tab1c.Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Elements<wp.Text>().First().Text = plainText;

                    }
                    foreach (Pergunta perg in prat.Perguntas.Values)
                    {
                        pergunta = repCalcs.getPergunta(perg.PerguntaID);
                        if (count % 2 == 0)
                        {
                            // linha par
                            tab1r = (wp.TableRow)rowTab1Par.Clone();
                        }
                        else
                        {
                            // linha impar
                            tab1r = (wp.TableRow)rowTab1Impar.Clone();
                        }

                        //seleciona a célula do texto
                        tab1c = tab1r.Elements<wp.TableCell>().ElementAt(0);

                        // introduz o texto da pergunta
                        tab1c.Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Elements<wp.Text>().First().Text = dataComportamentosFracosFortes[count].dados[0];

                        // as cores desta linha (prática)
                        tab1c = tab1r.Elements<wp.TableCell>().ElementAt(2);
                        switch (dataComportamentosFracosFortes[count].dados[1])
                        {
                            case "C":
                                tab1c.Elements<wp.Paragraph>().First().Append((wp.Run)red.Clone());
                                break;
                            case "B":
                                tab1c.Elements<wp.Paragraph>().First().Append((wp.Run)yellow.Clone());
                                break;
                            case "A":
                                tab1c.Elements<wp.Paragraph>().First().Append((wp.Run)green.Clone());
                                break;
                        }

                        // junta às tabelas as linhas
                        tab1Temp.Append(tab1r);
                        count++;
                    }
                }

                // INSERE A TABELA
                par.Append(tab1Temp);
                par.Append((wp.Paragraph)quebraPagina.Clone());

                contaPaginas++;
            }
    }
Exemplo n.º 8
0
    private void insertDetailsSkill(wp.Paragraph par, MainDocumentPart mainPart)
    {
        // na primira fase fazer sem os gráficos

        // ir buscar o template
        // cria o documento final base com base no template
        String templateDoc = _projecto.Template_Mnemonica;

        String filename = templatePath + "\\" + templateDoc + "_SKILS_DETAILS.docx";

        wp.Table tabTitulo1 = null;
        wp.Table tabTitulo2 = null;

        wp.Table tab1 = null;
        wp.TableRow rowTab1Par = null;
        wp.TableRow rowTab1Impar = null;

        wp.Table tab2 = null;
        wp.TableRow rowTab2Par = null;
        wp.TableRow rowTab2Impar = null;

        wp.Run plusSign = null;
        wp.Run minusSign = null;
        wp.Run naSign = null;
        wp.Run eqSign = null;

        wp.Run red = null;
        wp.Run orange = null;
        wp.Run yellow = null;
        wp.Run green = null;
        wp.Paragraph NRs = null;

        wp.Table legendaTab1 = null;
        wp.Table legendaTab2 = null;
        wp.Paragraph quebraPagina = null;

        Boolean inserirChart = true;
        Boolean Pagina1 = true;
        Boolean Pagina2 = true;

        using (WordprocessingDocument wordDoc = WordprocessingDocument.Open(filename, true))
        {
            try
            {
                // primeira tabela do template
                tabTitulo1 = (wp.Table)wordDoc.MainDocumentPart.Document.Body.Elements<wp.Table>().ElementAt(0).Clone();

                // primeira tabela com comportamentos
                tab1 = (wp.Table)wordDoc.MainDocumentPart.Document.Body.Elements<wp.Table>().ElementAt(1).Clone();
                rowTab1Impar = (wp.TableRow)tab1.Elements<wp.TableRow>().ElementAt(1).Clone();
                rowTab1Par = (wp.TableRow)tab1.Elements<wp.TableRow>().ElementAt(2).Clone();
                tab1.Elements<wp.TableRow>().ElementAt(1).Remove();
                tab1.Elements<wp.TableRow>().ElementAt(1).Remove();

                // apanha os run + e - (mais e menos)
                minusSign = (wp.Run)rowTab1Impar.Elements<wp.TableCell>().ElementAt(1).Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Clone();
                naSign = (wp.Run)rowTab1Impar.Elements<wp.TableCell>().ElementAt(2).Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Clone();
                plusSign = (wp.Run)rowTab1Par.Elements<wp.TableCell>().ElementAt(1).Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Clone();
                try
                {
                    eqSign = (wp.Run)rowTab1Par.Elements<wp.TableCell>().ElementAt(2).Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Clone();
                }
                catch
                {
                    eqSign = null;
                }
                // eliminar o mais e o menos das linhas e o tracinho
                rowTab1Impar.Elements<wp.TableCell>().ElementAt(1).Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Remove();
                rowTab1Impar.Elements<wp.TableCell>().ElementAt(2).Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Remove();
                rowTab1Par.Elements<wp.TableCell>().ElementAt(1).Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Remove();
                if (eqSign != null) rowTab1Par.Elements<wp.TableCell>().ElementAt(2).Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Remove();

                // depois tenho algures aqui a legenda da tabela
                legendaTab1 = (wp.Table)wordDoc.MainDocumentPart.Document.Body.Elements<wp.Table>().ElementAt(2).Clone();

                // o primeiro parágrafpo tem idiciação de ter ou não o chart
                try
                {
                    wp.Text chartPar = (wp.Text)wordDoc.MainDocumentPart.Document.Body.Elements<wp.Paragraph>().FirstOrDefault().Elements<wp.Run>().FirstOrDefault().Elements<wp.Text>().FirstOrDefault();
                    if (chartPar.Text != "")
                        inserirChart = true;
                    else
                        inserirChart = false;

                }
                catch
                {
                    inserirChart = false;
                }
            }
            catch
            {
                Pagina1 = false;
            }

            //parágrafo quebra de página
            quebraPagina = new wp.Paragraph(new wp.Run(new wp.Text("")));
            quebraPagina.ParagraphProperties = new wp.ParagraphProperties();
            quebraPagina.ParagraphProperties.PageBreakBefore = new wp.PageBreakBefore();
            quebraPagina.ParagraphProperties.PageBreakBefore.Val = DocumentFormat.OpenXml.OnOffValue.FromBoolean(true);

            try
            {
                // segundo header, também uma tabela
                //terá de se analisar o seu interior
                tabTitulo2 = (wp.Table)wordDoc.MainDocumentPart.Document.Body.Elements<wp.Table>().ElementAt(3).Clone();

                // tsegunda tabela
                tab2 = (wp.Table)wordDoc.MainDocumentPart.Document.Body.Elements<wp.Table>().ElementAt(4).Clone();
                rowTab2Impar = (wp.TableRow)tab2.Elements<wp.TableRow>().ElementAt(1).Clone();
                rowTab2Par = (wp.TableRow)tab2.Elements<wp.TableRow>().ElementAt(2).Clone();
                tab2.Elements<wp.TableRow>().ElementAt(1).Remove();
                tab2.Elements<wp.TableRow>().ElementAt(1).Remove();

                // agora os paragrafos de cor
                red = (wp.Run)rowTab2Impar.Elements<wp.TableCell>().ElementAt(2).Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Clone();
                orange = (wp.Run)rowTab2Impar.Elements<wp.TableCell>().ElementAt(3).Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Clone();
                yellow = (wp.Run)rowTab2Par.Elements<wp.TableCell>().ElementAt(2).Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Clone();
                green = (wp.Run)rowTab2Par.Elements<wp.TableCell>().ElementAt(3).Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Clone();
                NRs = (wp.Paragraph)rowTab2Impar.Elements<wp.TableCell>().ElementAt(5).Elements<wp.Paragraph>().First().Clone();

                // eliminar os quadrados do template
                rowTab2Impar.Elements<wp.TableCell>().ElementAt(2).Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Remove();
                rowTab2Impar.Elements<wp.TableCell>().ElementAt(3).Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Remove();
                rowTab2Impar.Elements<wp.TableCell>().ElementAt(5).Elements<wp.Paragraph>().First().Remove();

                rowTab2Par.Elements<wp.TableCell>().ElementAt(2).Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Remove();
                rowTab2Par.Elements<wp.TableCell>().ElementAt(3).Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Remove();
                rowTab2Par.Elements<wp.TableCell>().ElementAt(5).Elements<wp.Paragraph>().First().Remove();

                // legenda tabela 2
                // depois tenho algures aqui a legenda da tabela
                legendaTab2 = (wp.Table)wordDoc.MainDocumentPart.Document.Body.Elements<wp.Table>().ElementAt(5).Clone();
            }
            catch
            {
                Pagina2 = false;
            }
        }
        // fim da recolha dos elementos template.
        // passamos para a inserção destes elementos para cada competência

        // eliminar o texto do marcador
        par.Elements<wp.Run>().First().Elements<wp.Text>().First().Text = "";

        wp.Paragraph p = null;
        wp.Run r = null;
        wp.Text t = null;
        wp.Table tab = null;
        wp.Table tabTemp = null;
        wp.Table tab1Temp = null;
        wp.Table tab2Temp = null;

        wp.TableRow tab1r = null;
        wp.TableCell tab1c = null;
        wp.TableRow tab2r = null;
        wp.TableCell tab2c = null;

        wp.TableCell tcTemp = null;
        wp.TableRow trTemp = null;
        wp.TableCellProperties tcProps = null;

        int[] critic;
        int count = 0;

        String pergunta;
        //String tempTexto;
        int contaPaginas = 1;
        int ranking;
        String gap;

        foreach (FamiliaCompetencias fam in _Modelo.Familias.Values)
            foreach (Competencia comp in fam.Competencias.Values)
            {
                // são duas páginas de detalhes por cada competência
                // header da 1ªpágina
                if (Pagina1)
                {
                    if (comp.Type == "C") continue; // é uma competência comentário
                    if (comp.Type == "D") continue; // é uma zona de derrailers

                    // Nome da competência
                    tab = (wp.Table)tabTitulo1.Clone();
                    p = tab.Elements<wp.TableRow>().ElementAt(0).Elements<wp.TableCell>().First().Elements<wp.Paragraph>().First();
                    r = p.Elements<wp.Run>().First();
                    t = r.Elements<wp.Text>().First();
                    t.Text = repCalcs.getCompetenciaText(comp.CompetenciaID);

                    // Matriz de criticalidade
                    try
                    {
                        tabTemp = (wp.Table)tab.Elements<wp.TableRow>().First().Elements<wp.TableCell>().ElementAt(1).Elements<wp.Table>().First();

                        // ajustar a cor de cada backgroud destas células
                        critic = repCalcs.getCompetenciaCriticalidadeMatrixPos(comp.CompetenciaID);
                        String porRef = critic[1].ToString() + critic[0].ToString();
                        String pos;
                        for (int x = 0; x < 3; x++)
                        {
                            trTemp = tabTemp.Elements<wp.TableRow>().ElementAt(x);
                            for (int y = 0; y < 3; y++)
                            {
                                pos = x.ToString() + y.ToString();
                                tcTemp = trTemp.Elements<wp.TableCell>().ElementAt(y);
                                tcProps = tcTemp.Elements<wp.TableCellProperties>().First();
                                if (pos != porRef)
                                {
                                    tcProps.Shading.Fill = "C0C0C0";
                                }
                                //if ((critic[0] - x) * 10 + critic[1] - y != 0)

                            }
                        }
                    }
                    catch
                    {

                    }
                    par.Append(tab);

                    // um parágrafo de espaçamento para que as tabelas não colem

                    String spreadsheetTemplate = templatePath + "\\" + templateDoc + "_CHART_BARS.xlsx";
                    // String spreadsheetFileName = rootPath + "generatedFiles\\" + templateDoc + _self.Email + ".xlsx";

                    // GRÁFICO
                    // insert um gráfico com o template definido neste parágrafo 5372100, Cy = 1914525
                    String relID;

                    if (inserirChart)
                    {
                        relID = insertChart(mainPart, par, spreadsheetTemplate, 5372100, 1914525);
                        ChartsToUpdate.Add(relID, repCalcs.DB_getDADOS_GRAFICO(comp.CompetenciaID));
                    }
                }

                // PREPARA AS DUAS TABELAS COM OS DETALHES
                if (Pagina1) tab1Temp = (wp.Table)tab1.Clone();
                if (Pagina2) tab2Temp = (wp.Table)tab2.Clone();

                // os valores obtidos em cada comportamento
                List<ReportRow> dataComportamentos = repCalcs.getAvaliacaoComportamentosCriticos(comp.CompetenciaID);
                List<ReportRow> dataComportamentosFracosFortes = repCalcs.getAvaliacaoComportamentosCriticos_FracosFortes(comp.CompetenciaID);
                count = 0;
                foreach (Pratica prat in comp.Praticas.Values)
                {
                    if (Pagina1)
                    {
                        if (tab1Temp.Elements<wp.TableRow>().First().Elements<wp.TableCell>().First().Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Elements<wp.Text>().First().Text == "#TEXT_PRATICA#")
                        {
                            String plainText;
                            if (Utility.theServer != null)
                                plainText = Regex.Replace(Utility.theServer.HtmlDecode(prat.Description), "<[^>]+?>", "");
                            else
                                plainText = prat.Description;

                            plainText = DBHelper.ParseTextProprio(plainText, new Pessoa(), false);

                            tab1Temp.Elements<wp.TableRow>().First().Elements<wp.TableCell>().First().Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Elements<wp.Text>().First().Text = plainText;

                        }
                    }
                    if (Pagina2)
                    {
                        if (tab2Temp.Elements<wp.TableRow>().First().Elements<wp.TableCell>().First().Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Elements<wp.Text>().First().Text == "#TEXT_PRATICA#")
                        {
                            String plainText;
                            if (Utility.theServer != null)
                                plainText = Regex.Replace(Utility.theServer.HtmlDecode(prat.Description), "<[^>]+?>", "");
                            else
                                plainText = prat.Description;

                            plainText = DBHelper.ParseTextProprio(plainText, new Pessoa(), false);

                            tab2Temp.Elements<wp.TableRow>().First().Elements<wp.TableCell>().First().Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Elements<wp.Text>().First().Text = plainText;

                        }
                    }
                    foreach (Pergunta perg in prat.Perguntas.Values)
                    {
                        pergunta = repCalcs.getPergunta(perg.PerguntaID);
                        if (count % 2 == 0)
                        {
                            // linha par
                            if (Pagina1) tab1r = (wp.TableRow)rowTab1Par.Clone();
                            if (Pagina2) tab2r = (wp.TableRow)rowTab2Par.Clone();

                        }
                        else
                        {
                            // linha impar
                            if (Pagina1) tab1r = (wp.TableRow)rowTab1Impar.Clone();
                            if (Pagina2) tab2r = (wp.TableRow)rowTab2Impar.Clone();
                        }

                        if (Pagina1) tab1c = tab1r.Elements<wp.TableCell>().ElementAt(0);
                        if (Pagina2) tab2c = tab2r.Elements<wp.TableCell>().ElementAt(0);

                        if (count + 1 < dataComportamentos.Count)
                        {
                            // introduz o texto da pergunta
                            if (Pagina1) tab1c.Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Elements<wp.Text>().First().Text = dataComportamentos[count + 1].dados[0];
                            if (Pagina2) tab2c.Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Elements<wp.Text>().First().Text = dataComportamentos[count + 1].dados[0];
                            // introduz os valores de cada prática
                            if (Pagina1)
                            {
                                for (int i = 1; i <= _projecto.GroupsCodes.Count(); i++)
                                {

                                    tab1c = tab1r.Elements<wp.TableCell>().ElementAt(i);
                                    fillPlusMinus(tab1c, dataComportamentos[count + 1].dados[i], plusSign, minusSign, naSign, eqSign);

                                }
                            }

                        }
                        // as cores desta linha (prática)
                        if (Pagina2)
                        {
                            tab2c = tab2r.Elements<wp.TableCell>().ElementAt(2);
                            switch (dataComportamentosFracosFortes[count].dados[1])
                            {
                                case "C":
                                    tab2c.Elements<wp.Paragraph>().First().Append((wp.Run)red.Clone());
                                    break;
                                case "B":
                                    tab2c.Elements<wp.Paragraph>().First().Append((wp.Run)orange.Clone());
                                    break;
                                case "A":
                                    tab2c.Elements<wp.Paragraph>().First().Append((wp.Run)yellow.Clone());
                                    break;
                            }
                        }

                        if (Pagina2)
                        {
                            tab2c = tab2r.Elements<wp.TableCell>().ElementAt(3);
                            if (dataComportamentosFracosFortes[count].dados[2] == "D")
                                tab2c.Elements<wp.Paragraph>().First().Append((wp.Run)green.Clone());

                            // a percentagem de não respostas
                            tab2c = tab2r.Elements<wp.TableCell>().ElementAt(5);
                            NRs.Elements<wp.Run>().First().Elements<wp.Text>().First().Text = dataComportamentosFracosFortes[count].dados[3] + "%";

                            tab2c.Append((wp.Paragraph)NRs.Clone());
                        }
                        // junta às tabelas as linhas
                        if (Pagina1) tab1Temp.Append(tab1r);
                        if (Pagina2) tab2Temp.Append(tab2r);

                        count++;
                    }
                }

                // INSERE A TABELA 1
                if (Pagina1) par.Append(tab1Temp);
                // LEGENDA 1

                //tempTexto = "";

                //legendaTab1.Elements<wp.TableRow>().ElementAt(1).Elements<wp.TableCell>().First().Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Elements<wp.Text>().First().Text = tempTexto;
                if (Pagina1) par.Append((wp.Table)legendaTab1.Clone());

                // QUEBRA DE PÁGINA 1
                if (Pagina1) par.Append((wp.Paragraph)quebraPagina.Clone());

                // HEADER da 2ªpágina
                if (Pagina2)
                {
                    tab = (wp.Table)tabTitulo2.Clone();
                    p = tab.Elements<wp.TableRow>().ElementAt(1).Elements<wp.TableCell>().ElementAt(0).Elements<wp.Paragraph>().First();
                    r = p.Elements<wp.Run>().First();
                    t = r.Elements<wp.Text>().First();
                    t.Text = repCalcs.getCompetenciaText(comp.CompetenciaID);
                    try
                    {
                        // quadro dos RANKINGS ainda no header2
                        p = tab.Elements<wp.TableRow>().ElementAt(0).Elements<wp.TableCell>().ElementAt(2).Elements<wp.Paragraph>().First();
                        r = p.Elements<wp.Run>().First();
                        t = r.Elements<wp.Text>().First();
                        ranking = repCalcs.getCompetenciaRanking(comp.CompetenciaID, "T");
                        t.Text = ranking == 0 ? "-" : ranking.ToString();

                        for (int i = 1; i < _projecto.GroupsCodes.Count(); i++)
                        {
                            p = tab.Elements<wp.TableRow>().ElementAt(0).Elements<wp.TableCell>().ElementAt(i + 2).Elements<wp.Paragraph>().First();
                            r = p.Elements<wp.Run>().First();
                            t = r.Elements<wp.Text>().First();
                            ranking = repCalcs.getCompetenciaRanking(comp.CompetenciaID, repCalcs.ReportGroupCodes[i]);
                            t.Text = ranking == 0 ? "-" : ranking.ToString();
                        }

                        // quadro dos GAPS ainda no header2
                        p = tab.Elements<wp.TableRow>().ElementAt(1).Elements<wp.TableCell>().ElementAt(2).Elements<wp.Paragraph>().First();
                        r = p.Elements<wp.Run>().First();
                        gap = repCalcs.getCompetenciaGAP(comp.CompetenciaID, "T");
                        r.Elements<wp.SymbolChar>().First().Char = gap;

                        for (int i = 1; i < _projecto.GroupsCodes.Count(); i++)
                        {
                            p = tab.Elements<wp.TableRow>().ElementAt(1).Elements<wp.TableCell>().ElementAt(i + 2).Elements<wp.Paragraph>().First();
                            r = p.Elements<wp.Run>().First();
                            gap = repCalcs.getCompetenciaGAP(comp.CompetenciaID, repCalcs.ReportGroupCodes[i]);
                            r.Elements<wp.SymbolChar>().First().Char = gap;
                        }

                    }
                    catch
                    {

                    }

                    // INSERTE A TABELA DETALHE PAGINA 2
                    par.Append(tab);

                    // um parágrafo de espaçamento para que as tabelas não colem
                    par.Append(new wp.Paragraph());

                    // INSERE A TABELA 2
                    par.Append(tab2Temp);

                    // LEGENDA 2
                    //tempTexto = "";
                    par.Append((wp.Table)legendaTab2.Clone());

                    // QUEBRA DE PÁGINA 2
                    if (contaPaginas < repCalcs.getQuantidadeDeCompetencias())
                        par.Append((wp.Paragraph)quebraPagina.Clone());
                }
                contaPaginas++;
            }
    }
Exemplo n.º 9
0
    private void insertComentariosGroup(wp.Paragraph par, List<ReportRow> rows, String GroupID)
    {
        wp.Table tableComents;
        wp.TableRow trComents;
        wp.TableRow trHeader;
        wp.TableRow trComentsSep;
        wp.Paragraph parComentsSeparator;
        wp.Paragraph HeaderPar;

        // vai buscar o template para os comentários
        String templateDoc = _projecto.Template_Mnemonica;

        String filename = templatePath + "\\" + templateDoc + "_COMMENTS_BY_GROUP.docx";
        wp.TableRow tr;

        using (WordprocessingDocument wordDoc = WordprocessingDocument.Open(filename, true))
        {

            HeaderPar = (wp.Paragraph)wordDoc.MainDocumentPart.Document.Body.Elements<wp.Paragraph>().ElementAt(0).Clone();

            tableComents = (wp.Table)wordDoc.MainDocumentPart.Document.Body.Elements<wp.Table>().ElementAt(0).Clone();

            trHeader = (wp.TableRow)tableComents.Elements<wp.TableRow>().ElementAt(0);
            trComents = (wp.TableRow)tableComents.Elements<wp.TableRow>().ElementAt(1);
            trComentsSep = (wp.TableRow)tableComents.Elements<wp.TableRow>().ElementAt(2);
            trComentsSep.Elements<wp.TableCell>().First().Elements<wp.Paragraph>().ElementAt(0).Elements<wp.Run>().First().Elements<wp.Text>().First().Text = "";

            tableComents.Elements<wp.TableRow>().ElementAt(0).Remove();
            tableComents.Elements<wp.TableRow>().ElementAt(0).Remove();
            tableComents.Elements<wp.TableRow>().ElementAt(0).Remove();

            parComentsSeparator = (wp.Paragraph)wordDoc.MainDocumentPart.Document.Body.Elements<wp.Paragraph>().ElementAt(0);
        }

        // produzir a secção de comentários

        if (rows == null)
        {
            par.Append((wp.Paragraph)parComentsSeparator.Clone());
        }
        else if (rows.Count == 0)
        {
            par.Append((wp.Paragraph)parComentsSeparator.Clone());
        }
        else
        {
            // o início da secção
            wp.Paragraph h = (wp.Paragraph)HeaderPar.Clone();
            h.Elements<wp.Run>().First().Elements<wp.Text>().First().Text = GroupID;
            par.Append(h);

            foreach (ReportRow rr in rows)
            {
                if (rr.dados[0] == "BREAK")
                    tr = trComentsSep.Clone() as wp.TableRow;
                else if (rr.dados[0] != "")
                {
                    tr = trHeader.Clone() as wp.TableRow;
                    tr.Elements<wp.TableCell>().First().Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Elements<wp.Text>().First().Text = repCalcs.getCompetenciaText(int.Parse(rr.dados[0]));
                }
                else
                {
                    tr = trComents.Clone() as wp.TableRow;
                    tr.Elements<wp.TableCell>().First().Elements<wp.Paragraph>().First().Elements<wp.Run>().First().Elements<wp.Text>().First().Text = rr.dados[1];
                }
                tableComents.Append(tr);
            }
            par.Append(tableComents);
        }

        // eliminar o texto do marcador
        par.Elements<wp.Run>().First().Elements<wp.Text>().First().Text = "";
    }