Exemple #1
0
        /// <summary>
        /// Shows how to set a table to auto fit to 50% of the page width.
        /// </summary>
        private static void AutoFitToPageWidth(string dataDir)
        {
            // ExStart:AutoFitToPageWidth
            Document        doc     = new Document();
            DocumentBuilder builder = new DocumentBuilder(doc);

            // Insert a table with a width that takes up half the page width.
            Table table = builder.StartTable();

            // Insert a few cells
            builder.InsertCell();
            table.PreferredWidth = PreferredWidth.FromPercent(50);
            builder.Writeln("Cell #1");

            builder.InsertCell();
            builder.Writeln("Cell #2");

            builder.InsertCell();
            builder.Writeln("Cell #3");

            dataDir = dataDir + "Table.PreferredWidth_out.doc";

            // Save the document to disk.
            doc.Save(dataDir);
            // ExEnd:AutoFitToPageWidth
            Console.WriteLine("\nTable autofit successfully to 50% of the page width.\nFile saved at " + dataDir);
        }
        // Token: 0x06000010 RID: 16 RVA: 0x00002640 File Offset: 0x00000840
        public bool InsertScoreTable(bool dishand, bool distab, string handText)
        {
            bool result;

            try
            {
                this.oWordApplic.StartTable();
                this.oWordApplic.ParagraphFormat.Alignment = ParagraphAlignment.Left;
                this.oWordApplic.InsertCell();
                this.oWordApplic.CellFormat.Width             = 100.0;
                this.oWordApplic.CellFormat.PreferredWidth    = PreferredWidth.FromPoints(115.0);
                this.oWordApplic.CellFormat.Borders.LineStyle = LineStyle.None;
                this.oWordApplic.StartTable();
                this.oWordApplic.RowFormat.Height = 20.2;
                this.oWordApplic.InsertCell();
                this.oWordApplic.CellFormat.Borders.LineStyle = LineStyle.Single;
                this.oWordApplic.Font.Size = 10.5;
                this.oWordApplic.Bold      = false;
                this.oWordApplic.Write("评卷人");
                this.oWordApplic.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
                this.oWordApplic.ParagraphFormat.Alignment    = ParagraphAlignment.Center;
                this.oWordApplic.CellFormat.Width             = 50.0;
                this.oWordApplic.CellFormat.PreferredWidth    = PreferredWidth.FromPoints(50.0);
                this.oWordApplic.RowFormat.Height             = 20.0;
                this.oWordApplic.InsertCell();
                this.oWordApplic.CellFormat.Borders.LineStyle = LineStyle.Single;
                this.oWordApplic.Font.Size = 10.5;
                this.oWordApplic.Bold      = false;
                this.oWordApplic.Write("得分");
                this.oWordApplic.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
                this.oWordApplic.ParagraphFormat.Alignment    = ParagraphAlignment.Center;
                this.oWordApplic.CellFormat.Width             = 50.0;
                this.oWordApplic.CellFormat.PreferredWidth    = PreferredWidth.FromPoints(50.0);
                this.oWordApplic.EndRow();
                this.oWordApplic.RowFormat.Height = 25.0;
                this.oWordApplic.InsertCell();
                this.oWordApplic.RowFormat.Height = 25.0;
                this.oWordApplic.InsertCell();
                this.oWordApplic.EndRow();
                this.oWordApplic.EndTable();
                this.oWordApplic.InsertCell();
                this.oWordApplic.CellFormat.Width             = 390.0;
                this.oWordApplic.CellFormat.PreferredWidth    = PreferredWidth.Auto;
                this.oWordApplic.CellFormat.Borders.LineStyle = LineStyle.None;
                this.oWordApplic.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
                this.oWordApplic.ParagraphFormat.Alignment    = ParagraphAlignment.Left;
                this.oWordApplic.Font.Size = 11.0;
                this.oWordApplic.Bold      = true;
                this.oWordApplic.Write(handText);
                this.oWordApplic.EndRow();
                this.oWordApplic.RowFormat.Height = 28.0;
                this.oWordApplic.EndTable();
                result = true;
            }
            catch
            {
                result = false;
            }
            return(result);
        }
Exemple #3
0
        /// <summary>
        /// Shows how to set the different preferred width settings.
        /// </summary>
        private static void SetPreferredWidthSettings(string dataDir)
        {
            // ExStart:SetPreferredWidthSettings
            Document        doc     = new Document();
            DocumentBuilder builder = new DocumentBuilder(doc);

            // Insert a table row made up of three cells which have different preferred widths.
            Table table = builder.StartTable();

            // Insert an absolute sized cell.
            builder.InsertCell();
            builder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(40);
            builder.CellFormat.Shading.BackgroundPatternColor = Color.LightYellow;
            builder.Writeln("Cell at 40 points width");

            // Insert a relative (percent) sized cell.
            builder.InsertCell();
            builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);
            builder.CellFormat.Shading.BackgroundPatternColor = Color.LightBlue;
            builder.Writeln("Cell at 20% width");

            // Insert a auto sized cell.
            builder.InsertCell();
            builder.CellFormat.PreferredWidth = PreferredWidth.Auto;
            builder.CellFormat.Shading.BackgroundPatternColor = Color.LightGreen;
            builder.Writeln("Cell automatically sized. The size of this cell is calculated from the table preferred width.");
            builder.Writeln("In this case the cell will fill up the rest of the available space.");

            dataDir = dataDir + "Table.CellPreferredWidths_out.doc";
            // Save the document to disk.
            doc.Save(dataDir);
            // ExEnd:SetPreferredWidthSettings
            Console.WriteLine("\nDifferent preferred width settings set successfully.\nFile saved at " + dataDir);
        }
Exemple #4
0
        static void Main(string[] args)
        {
            Document        doc     = new Document();
            DocumentBuilder builder = new DocumentBuilder(doc);

            builder.StartTable();
            builder.InsertCell();
            builder.Write("Table 1, Row 1, cell 1.");
            builder.InsertCell();
            builder.Write("Table 1, Row 1, cell 2.");
            builder.EndTable();

            builder.InsertParagraph();

            builder.StartTable();
            builder.InsertCell();
            builder.Write("Table 2, Row 1, cell 1.");
            builder.InsertCell();
            builder.Write("Table 2, Row 1, cell 2.");
            builder.EndTable();

            foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
            {
                table.PreferredWidth = PreferredWidth.FromPercent(100);
            }

            doc.Save("Fitting all Tables to the Page Width.docx");
        }
        public void PreferredWidthSettings()
        {
            //ExStart:PreferredWidthSettings
            Document        doc     = new Document();
            DocumentBuilder builder = new DocumentBuilder(doc);

            // Insert a table row made up of three cells which have different preferred widths.
            builder.StartTable();

            // Insert an absolute sized cell.
            builder.InsertCell();
            builder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(40);
            builder.CellFormat.Shading.BackgroundPatternColor = Color.LightYellow;
            builder.Writeln("Cell at 40 points width");

            // Insert a relative (percent) sized cell.
            builder.InsertCell();
            builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);
            builder.CellFormat.Shading.BackgroundPatternColor = Color.LightBlue;
            builder.Writeln("Cell at 20% width");

            // Insert a auto sized cell.
            builder.InsertCell();
            builder.CellFormat.PreferredWidth = PreferredWidth.Auto;
            builder.CellFormat.Shading.BackgroundPatternColor = Color.LightGreen;
            builder.Writeln(
                "Cell automatically sized. The size of this cell is calculated from the table preferred width.");
            builder.Writeln("In this case the cell will fill up the rest of the available space.");

            doc.Save(ArtifactsDir + "WorkingWithTables.PreferredWidthSettings.docx");
            //ExEnd:PreferredWidthSettings
        }
        public void NegativeIndent()
        {
            //ExStart
            //ExFor:HtmlSaveOptions.AllowNegativeIndent
            //ExFor:HtmlSaveOptions.TableWidthOutputMode
            //ExSummary:Shows how to preserve negative indents in the output .html.
            Document        doc     = new Document();
            DocumentBuilder builder = new DocumentBuilder(doc);

            // Insert a table and give it a negative value for its indent, effectively pushing it out of the left page boundary
            Table table = builder.StartTable();

            builder.InsertCell();
            builder.Write("Cell 1");
            builder.InsertCell();
            builder.Write("Cell 2");
            builder.EndTable();
            table.LeftIndent     = -36;
            table.PreferredWidth = PreferredWidth.FromPoints(144);

            // When saving to .html, this indent will only be preserved if we set this flag
            HtmlSaveOptions options = new HtmlSaveOptions(SaveFormat.Html);

            options.AllowNegativeIndent  = true;
            options.TableWidthOutputMode = HtmlElementSizeOutputMode.RelativeOnly;

            // The first cell with "Cell 1" will not be visible in the output
            doc.Save(ArtifactsDir + "HtmlSaveOptions.AllowNegativeIndent.html", options);
            //ExEnd
        }
Exemple #7
0
        private static void CreateSimpleTable(Document doc, DocumentBuilder builder, List <GoodsModel> list)
        {
            Table table = builder.StartTable();

            #region 表头
            string[] titles = new string[] { "序号", "货品名称", "货品类型", "存放位置", "数量" };
            int[]    lens   = new int[] { 10, 25, 25, 25, 15 };
            for (int i = 0; i < 5; i++)
            {
                builder.InsertCell();                                                    //插入单元格
                builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(lens[i]); //列宽-百分比
                builder.CellFormat.Shading.BackgroundPatternColor = Color.LightGray;     //背景色-灰色
                builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;           //对齐-居中
                builder.Write(titles[i]);                                                //写入内容
            }
            builder.EndRow();                                                            //结束行
            #endregion

            #region 内容
            for (int i = 0; i < list.Count; i++)
            {
                GoodsModel model = list[i];

                builder.InsertCell();                                                    //插入单元格
                builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(lens[0]); //列宽
                builder.CellFormat.Shading.BackgroundPatternColor = Color.White;         //背景色-白色
                builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;           //对齐-居中
                builder.Write((i + 1).ToString());                                       //写入内容

                builder.InsertCell();                                                    //插入单元格
                builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(lens[1]); //列宽
                builder.CellFormat.Shading.BackgroundPatternColor = Color.White;         //背景色-白色
                builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;             //对齐-靠左
                builder.Write(model.GoodsName);                                          //写入内容

                builder.InsertCell();                                                    //插入单元格
                builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(lens[2]); //列宽
                builder.CellFormat.Shading.BackgroundPatternColor = Color.White;         //背景色-白色
                builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;           //对齐-居中
                builder.Write(model.GoodsType);                                          //写入内容

                builder.InsertCell();                                                    //插入单元格
                builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(lens[3]); //列宽
                builder.CellFormat.Shading.BackgroundPatternColor = Color.White;         //背景色-白色
                builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;            //对齐-靠右
                builder.Write(model.Location);                                           //写入内容

                builder.InsertCell();                                                    //插入单元格
                builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(lens[4]); //列宽
                builder.CellFormat.Shading.BackgroundPatternColor = Color.White;         //背景色-白色
                builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;           //对齐-居中
                builder.Write((model.GoodsNum).ToString());                              //写入内容

                builder.EndRow();                                                        //结束行
            }
            #endregion

            builder.EndTable();//结束表格
        }
Exemple #8
0
        /// <summary>
        /// 设置表格
        /// </summary>
        /// <param name="table"></param>
        public void SetTable(NodeCollection tables)
        {
            foreach (Table table in tables)
            {
                var regTitle = new Regex(@"^表[1-9]\d*");

                var paraTitleHead = table.PreviousSibling as Paragraph; // 上标题
                var paraTitleFoot = table.NextSibling as Paragraph;     // 下标题

                if (paraTitleHead != null && regTitle.IsMatch(paraTitleHead.Range.Text.Trim()))
                {
                    // 以表1开头的段落认为是表格的标题
                    paraTitleHead.ParagraphFormat.Alignment = ParagraphAlignment.Center;
                }

                if (paraTitleFoot != null && regTitle.IsMatch(paraTitleFoot.Range.Text.Trim()))
                {
                    // 以表1开头的段落认为是表格的标题
                    paraTitleFoot.ParagraphFormat.Alignment = ParagraphAlignment.Center;
                }

                // 表格居中
                table.Alignment = Aspose.Words.Tables.TableAlignment.Center;
                // 表格宽度100%
                table.PreferredWidth = PreferredWidth.FromPercent(100);

                var cells = table.GetChildNodes(NodeType.Cell, true);

                foreach (Cell c in cells)
                {
                    // 表格内边框0.5磅
                    c.CellFormat.Borders.LineWidth = 0.5;
                    // 内容垂直居中
                    c.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;


                    // 单元格内段落居中
                    foreach (Paragraph p in c.Paragraphs)
                    {
                        // 表格内段落居中、不缩进,行距最小值
                        p.ParagraphFormat.Alignment       = ParagraphAlignment.Center;
                        p.ParagraphFormat.FirstLineIndent = 0;
                        p.ParagraphFormat.LeftIndent      = 0;
                        p.ParagraphFormat.LineSpacingRule = LineSpacingRule.Multiple;
                        p.ParagraphFormat.LineSpacing     = 12; // 单倍行距

                        // 设置表格内段落内容
                        setParaContent(p);
                    }
                }

                // 外边框1.5磅
                table.SetBorder(BorderType.Top, LineStyle.Single, 1.5, System.Drawing.Color.Black, true);
                table.SetBorder(BorderType.Bottom, LineStyle.Single, 1.5, System.Drawing.Color.Black, true);
                table.SetBorder(BorderType.Left, LineStyle.Single, 1.5, System.Drawing.Color.Black, true);
                table.SetBorder(BorderType.Right, LineStyle.Single, 1.5, System.Drawing.Color.Black, true);
            }
        }
        static void Main(string[] args)
        {
            Document doc = new Document("doc.docx");

            foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
            {
                table.PreferredWidth = PreferredWidth.FromPercent(100);
            }
        }
        /// <summary>
        /// Escribe el título de la sección.
        /// </summary>
        /// <param name="docBuilder"></param>
        /// <param name="tituloSeccion"></param>
        public void EscribirTituloSeccion(DocumentBuilder docBuilder, String tituloSeccion)
        {
            docBuilder.Font.Name = "Arial";
            docBuilder.Font.Bold = true;
            docBuilder.Font.Size = 12;
            docBuilder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Heading1;
            docBuilder.Font.Color = System.Drawing.Color.Black;
            docBuilder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
            docBuilder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(100);

            docBuilder.Write(tituloSeccion);
        }
Exemple #11
0
 /// <summary>
 /// 表格通用设置,包括字体类型、大小、颜色
 /// </summary>
 public static void TableCommonSetting(GridTable tb)
 {
     if (tb == null)
     {
         return;
     }
     tb.DefaultFontName        = "微软雅黑";
     tb.DefaultFontSize        = 10.5;
     tb.DefaultForegroundColor = GetRgb("#333");
     tb.DefaultCellAlign       = CellAlign.Center;
     tb.DefaultBorderColor     = Color.LightGray;
     tb.TablePreferredWidth    = PreferredWidth.FromPercent(100);
 }
 /// <summary>
 /// Imprime el contenido de la celda con firma.
 /// </summary>
 /// <param name="saltosLinea">Cantidad de saltos de linea.</param>
 /// <param name="docBuilder">Constructor del documento.</param>
 /// <param name="widthPercent">Porcentaje en ancho.</param>
 private void ImprimeCeldaComplementaria(DocumentBuilder docBuilder, double widthPercent, int saltosLinea = 0)
 {
     docBuilder.InsertCell();
     docBuilder.CellFormat.PreferredWidth         = PreferredWidth.FromPercent(widthPercent);
     docBuilder.ParagraphFormat.Borders.Color     = Color.White;
     docBuilder.ParagraphFormat.Borders.LineStyle = LineStyle.None;
     docBuilder.ParagraphFormat.Borders.LineWidth = 0;
     for (var index = 0; index < saltosLinea; index++)
     {
         docBuilder.Writeln();
     }
     docBuilder.Font.Bold = false;
 }
Exemple #13
0
        public static void SetTable(NodeCollection tables, MergeOption Options)
        {
            var regTitle = new Regex(@"^表[1-9]\d*");

            foreach (Table table in tables)
            {
                var paraTitleHead = table.PreviousSibling as Paragraph; // 上标题
                var paraTitleFoot = table.NextSibling as Paragraph;     // 下标题

                if (paraTitleHead != null && regTitle.IsMatch(paraTitleHead.Range.Text.Trim()))
                {
                    // 以表1开头的段落认为是表格的标题
                    paraTitleHead.ParagraphFormat.Alignment = ParagraphAlignment.Center;
                }

                if (paraTitleFoot != null && regTitle.IsMatch(paraTitleFoot.Range.Text.Trim()))
                {
                    // 以表1开头的段落认为是表格的标题
                    paraTitleFoot.ParagraphFormat.Alignment = ParagraphAlignment.Center;
                }

                // 表格居中
                table.Alignment = Aspose.Words.Tables.TableAlignment.Center;
                // 表格宽度100%
                table.PreferredWidth = PreferredWidth.FromPercent(100);

                var cells = table.GetChildNodes(NodeType.Cell, true);

                foreach (Cell c in cells)
                {
                    // 表格内边框0.5磅
                    c.CellFormat.Borders.LineWidth = 0.5;
                    // 内容垂直居中
                    c.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;


                    // 单元格内段落居中
                    foreach (Paragraph p in c.Paragraphs)
                    {
                        // 设置表格内部段落样式,表格的行高是固定值不设置行距
                        SetTableParaStyle(p, Options, c.ParentRow.RowFormat.HeightRule != HeightRule.Exactly);
                    }
                }

                // 外边框1.5磅
                table.SetBorder(BorderType.Top, LineStyle.Single, 1.5, System.Drawing.Color.Black, true);
                table.SetBorder(BorderType.Bottom, LineStyle.Single, 1.5, System.Drawing.Color.Black, true);
                table.SetBorder(BorderType.Left, LineStyle.Single, 1.5, System.Drawing.Color.Black, true);
                table.SetBorder(BorderType.Right, LineStyle.Single, 1.5, System.Drawing.Color.Black, true);
            }
        }
        /// <summary>
        /// Imprime el contenido de la celda con firma.
        /// </summary>
        /// <param name="miembro">Miembro a pintar.</param>
        /// <param name="docBuilder">Constructor del documento.</param>
        /// <param name="widthPercent">Porcentaje en ancho.</param>
        private void ImprimeCeldaFirmas(PersonaResponsableMiembro431000DTO miembro, DocumentBuilder docBuilder, double widthPercent)
        {
            docBuilder.InsertCell();
            docBuilder.CellFormat.PreferredWidth             = PreferredWidth.FromPercent(widthPercent);
            docBuilder.ParagraphFormat.Alignment             = ParagraphAlignment.Center;
            docBuilder.ParagraphFormat.Borders.Top.Color     = Color.Black;
            docBuilder.ParagraphFormat.Borders.Top.LineStyle = LineStyle.Single;
            docBuilder.ParagraphFormat.Borders.Top.LineWidth = 1;

            docBuilder.Font.Bold = true;
            docBuilder.Writeln(miembro.Nombre);
            docBuilder.Font.Bold = false;
            docBuilder.Writeln(miembro.Cargo);
        }
        /// <summary>
        /// Escribe el concepto como si fuera un textBlockItemType.
        /// </summary>
        /// <param name="docBuilder"></param>
        /// <param name="concepto"></param>
        /// <param name="valor"></param>
        /// <param name="dimensiones"></param>
        public void EscribirConceptoPorRenglon(DocumentBuilder docBuilder, String concepto, String valor, List <String> dimensiones)
        {
            Table tabla = docBuilder.StartTable();

            docBuilder.InsertCell();

            docBuilder.Font.Name = "Arial";
            docBuilder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
            docBuilder.Font.Color = System.Drawing.Color.Black;

            EscribirDimensionesDeConcepto(docBuilder, dimensiones);

            docBuilder.Font.Bold = true;
            docBuilder.Font.Size = 10;
            docBuilder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(99);

            if (dimensiones != null)
            {
                docBuilder.Write(" " + concepto);
            }
            else
            {
                docBuilder.Write(concepto);
            }

            docBuilder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(1);
            docBuilder.Write("");

            docBuilder.EndRow();

            docBuilder.InsertCell();
            docBuilder.Font.Bold = false;
            docBuilder.ParagraphFormat.Alignment = ParagraphAlignment.Justify;
            docBuilder.Font.Size = 8;
            docBuilder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(99);
            docBuilder.InsertHtml(valor);
            docBuilder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(1);
            docBuilder.Write("");
            docBuilder.EndRow();

            tabla.SetBorders(Aspose.Words.LineStyle.None, 0, System.Drawing.Color.Black);
            tabla.SetBorder(BorderType.Horizontal, Aspose.Words.LineStyle.Single, .75, System.Drawing.Color.DarkGray, true);
            tabla.SetBorder(BorderType.Bottom, Aspose.Words.LineStyle.Single, .75, System.Drawing.Color.DarkGray, true);
            docBuilder.EndTable();
        }
Exemple #16
0
    private static void smethod_1(Class15 A_0, PreferredWidth A_1)
    {
        Class15  class2 = A_0;
        FtsWidth auto   = FtsWidth.Auto;

        switch (A_1.Type)
        {
        case WidthType.Percentage:
            auto = FtsWidth.Percentage;
            break;

        case WidthType.Twip:
            auto = FtsWidth.Point;
            break;
        }
        class2.method_52(auto);
        class2.method_50((float)A_1.Value);
    }
        /// <summary>
        /// 创建表格
        /// </summary>
        /// <returns></returns>
        public GridTable GetTable()
        {
            var tb = new GridTable(3)
            {
                DefaultColWidth        = new double[] { 150, 320, 80 },
                TablePreferredWidth    = PreferredWidth.FromPercent(100),
                DefaultFontName        = "微软雅黑",
                DefaultFontNameAscii   = "Microsoft YaHei",
                DefaultFontSize        = 12,
                DefaultForegroundColor = GetRgb("#333"),
                DefaultCellAlign       = CellAlign.Center,
                DefaultBorderColor     = Color.LightGray,
            };

            KnowledgePoints(tb);
            MasteryLevel(tb);
            ImprovementRoom(tb);
            MajorKnowledgePoints(tb);
            KnowledgePointMicroCourse(tb);
            return(tb);
        }
        /// <summary>
        /// Imprime el valor de un hecho a dos columnas.
        /// </summary>
        /// <param name="docBuilder">Constructor del documento.</param>
        /// <param name="estructuraReporte">DTO con información general del reporte actual</param>
        /// <param name="concepto">Concepto que se presenta.</param>
        /// <param name="hecho">Hecho que se persenta.</param>
        public override void EscribirADosColumnasConceptoValor(DocumentBuilder docBuilder, ReporteXBRLDTO estructuraReporte, ConceptoReporteDTO concepto, HechoReporteDTO hecho)
        {
            Table tablaActual = docBuilder.StartTable();

            docBuilder.ParagraphFormat.SpaceAfter  = 5;
            docBuilder.ParagraphFormat.SpaceBefore = 5;

            docBuilder.InsertCell();
            if (AnchoMinimoTitulodosColumnas != null && AnchoMinimoTitulodosColumnas > 0)
            {
                docBuilder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(AnchoMinimoTitulodosColumnas ?? 50);
            }

            establecerFuenteTituloCampo(docBuilder);
            docBuilder.Font.Size  = 11;
            docBuilder.Font.Color = Color.Black;
            //AplicaEstilosEtiquetaConcepto(docBuilder, concepto.IdConcepto, estructuraReporte);
            docBuilder.Write(concepto.Valor);
            docBuilder.ParagraphFormat.Alignment = ParagraphAlignment.Justify;
            docBuilder.Write(": ");

            docBuilder.InsertCell();
            int porcentajeSegundaColumna = 50;

            docBuilder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(porcentajeSegundaColumna);
            establecerFuenteValorCampo(docBuilder);
            docBuilder.ParagraphFormat.Alignment = ParagraphAlignment.Right;
            docBuilder.Font.Size = 10;
            //AplicaEstilosValorConcepto(docBuilder, concepto.IdConcepto, estructuraReporte);
            escribirValorHecho(docBuilder, estructuraReporte, hecho, concepto);
            docBuilder.EndRow();

            tablaActual.SetBorders(LineStyle.None, 0, Color.Black);
            tablaActual.SetBorder(BorderType.Horizontal, LineStyle.Single, .75, Color.DarkGray, true);
            tablaActual.SetBorder(BorderType.Bottom, LineStyle.Single, .75, Color.DarkGray, true);

            docBuilder.EndTable();
            docBuilder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
        }
        public void AutoFitToPageWidth()
        {
            //ExStart:AutoFitToPageWidth
            Document        doc     = new Document();
            DocumentBuilder builder = new DocumentBuilder(doc);

            // Insert a table with a width that takes up half the page width.
            Table table = builder.StartTable();

            builder.InsertCell();
            table.PreferredWidth = PreferredWidth.FromPercent(50);
            builder.Writeln("Cell #1");

            builder.InsertCell();
            builder.Writeln("Cell #2");

            builder.InsertCell();
            builder.Writeln("Cell #3");

            doc.Save(ArtifactsDir + "WorkingWithTables.AutoFitToPageWidth.docx");
            //ExEnd:AutoFitToPageWidth
        }
Exemple #20
0
        // Token: 0x06000011 RID: 17 RVA: 0x000029F0 File Offset: 0x00000BF0
        public bool InsertTable(DataTable dt, bool haveBorder)
        {
            Table table = this.oWordApplic.StartTable();
            ParagraphAlignment alignment = this.oWordApplic.ParagraphFormat.Alignment;

            this.oWordApplic.ParagraphFormat.Alignment = ParagraphAlignment.Center;
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                this.oWordApplic.RowFormat.Height = 25.0;
                for (int j = 0; j < dt.Columns.Count; j++)
                {
                    this.oWordApplic.InsertCell();
                    this.oWordApplic.Font.Size = 10.5;
                    this.oWordApplic.Font.Name = "宋体";
                    this.oWordApplic.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
                    this.oWordApplic.ParagraphFormat.Alignment    = ParagraphAlignment.Center;
                    this.oWordApplic.CellFormat.Width             = 60.0;
                    this.oWordApplic.CellFormat.PreferredWidth    = PreferredWidth.FromPoints(50.0);
                    if (haveBorder)
                    {
                        this.oWordApplic.CellFormat.Borders.LineStyle = LineStyle.Single;
                    }
                    this.oWordApplic.Write(dt.Rows[i][j].ToString());
                }
                this.oWordApplic.EndRow();
            }
            this.oWordApplic.EndTable();
            this.oWordApplic.ParagraphFormat.Alignment = alignment;
            table.Alignment      = TableAlignment.Center;
            table.PreferredWidth = PreferredWidth.Auto;
            table.SetBorder(BorderType.Left, LineStyle.Single, 2.0, Color.Black, true);
            table.SetBorder(BorderType.Right, LineStyle.Single, 2.0, Color.Black, true);
            table.SetBorder(BorderType.Top, LineStyle.Single, 2.0, Color.Black, true);
            table.SetBorder(BorderType.Bottom, LineStyle.Single, 2.0, Color.Black, true);
            return(true);
        }
        public static void Run()
        {
            //ExStart:CreateHeaderFooterUsingDocBuilder
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_WorkingWithDocument();

            Document        doc     = new Document();
            DocumentBuilder builder = new DocumentBuilder(doc);

            Section   currentSection = builder.CurrentSection;
            PageSetup pageSetup      = currentSection.PageSetup;

            // Specify if we want headers/footers of the first page to be different from other pages.
            // You can also use PageSetup.OddAndEvenPagesHeaderFooter property to specify
            // different headers/footers for odd and even pages.
            pageSetup.DifferentFirstPageHeaderFooter = true;

            // --- Create header for the first page. ---
            pageSetup.HeaderDistance = 20;
            builder.MoveToHeaderFooter(HeaderFooterType.HeaderFirst);
            builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;

            // Set font properties for header text.
            builder.Font.Name = "Arial";
            builder.Font.Bold = true;
            builder.Font.Size = 14;
            // Specify header title for the first page.
            builder.Write("Aspose.Words Header/Footer Creation Primer - Title Page.");

            // --- Create header for pages other than first. ---
            pageSetup.HeaderDistance = 20;
            builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);

            // Insert absolutely positioned image into the top/left corner of the header.
            // Distance from the top/left edges of the page is set to 10 points.
            string imageFileName = dataDir + "Aspose.Words.gif";

            builder.InsertImage(imageFileName, RelativeHorizontalPosition.Page, 10, RelativeVerticalPosition.Page, 10, 50, 50, WrapType.Through);

            builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;
            // Specify another header title for other pages.
            builder.Write("Aspose.Words Header/Footer Creation Primer.");

            // --- Create footer for pages other than first. ---
            builder.MoveToHeaderFooter(HeaderFooterType.FooterPrimary);

            // We use table with two cells to make one part of the text on the line (with page numbering)
            // to be aligned left, and the other part of the text (with copyright) to be aligned right.
            builder.StartTable();

            // Clear table borders.
            builder.CellFormat.ClearFormatting();

            builder.InsertCell();

            // Set first cell to 1/3 of the page width.
            builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(100 / 3);

            // Insert page numbering text here.
            // It uses PAGE and NUMPAGES fields to auto calculate current page number and total number of pages.
            builder.Write("Page ");
            builder.InsertField("PAGE", "");
            builder.Write(" of ");
            builder.InsertField("NUMPAGES", "");

            // Align this text to the left.
            builder.CurrentParagraph.ParagraphFormat.Alignment = ParagraphAlignment.Left;

            builder.InsertCell();
            // Set the second cell to 2/3 of the page width.
            builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(100 * 2 / 3);

            builder.Write("(C) 2001 Aspose Pty Ltd. All rights reserved.");

            // Align this text to the right.
            builder.CurrentParagraph.ParagraphFormat.Alignment = ParagraphAlignment.Right;

            builder.EndRow();
            builder.EndTable();

            builder.MoveToDocumentEnd();
            // Make page break to create a second page on which the primary headers/footers will be seen.
            builder.InsertBreak(BreakType.PageBreak);

            // Make section break to create a third page with different page orientation.
            builder.InsertBreak(BreakType.SectionBreakNewPage);

            // Get the new section and its page setup.
            currentSection = builder.CurrentSection;
            pageSetup      = currentSection.PageSetup;

            // Set page orientation of the new section to landscape.
            pageSetup.Orientation = Orientation.Landscape;

            // This section does not need different first page header/footer.
            // We need only one title page in the document and the header/footer for this page
            // has already been defined in the previous section
            pageSetup.DifferentFirstPageHeaderFooter = false;

            // This section displays headers/footers from the previous section by default.
            // Call currentSection.HeadersFooters.LinkToPrevious(false) to cancel this.
            // Page width is different for the new section and therefore we need to set
            // a different cell widths for a footer table.
            currentSection.HeadersFooters.LinkToPrevious(false);

            // If we want to use the already existing header/footer set for this section
            // but with some minor modifications then it may be expedient to copy headers/footers
            // from the previous section and apply the necessary modifications where we want them.
            CopyHeadersFootersFromPreviousSection(currentSection);

            // Find the footer that we want to change.
            HeaderFooter primaryFooter = currentSection.HeadersFooters[HeaderFooterType.FooterPrimary];

            Row row = primaryFooter.Tables[0].FirstRow;

            row.FirstCell.CellFormat.PreferredWidth = PreferredWidth.FromPercent(100 / 3);
            row.LastCell.CellFormat.PreferredWidth  = PreferredWidth.FromPercent(100 * 2 / 3);



            dataDir = dataDir + "HeaderFooter.Primer_out_.doc";
            // Save the resulting document.
            doc.Save(dataDir);
            //ExEnd:CreateHeaderFooterUsingDocBuilder

            Console.WriteLine("\nHeader and footer created successfully using document builder.\nFile saved at " + dataDir);
        }
Exemple #22
0
        public static Table WriteTable(Aspose.Words.DocumentBuilder builder, DataTable dt, int startRow,
                                       IList <double> colwidth)
        {
            var tableW = ConfigurationManager.AppSettings["tableWidth"].ToInt();

            builder.ParagraphFormat.StyleIdentifier = Aspose.Words.StyleIdentifier.BodyText;
            var table = builder.StartTable();

            //table.LeftIndent = 20.0;
            //table.AllowAutoFit = false;
            builder.RowFormat.Height   = 25.0;
            builder.CellFormat.FitText = false;

            var lstW = new List <double>();
            var ww   = colwidth.Sum();

            foreach (var v in colwidth)
            {
                lstW.Add((tableW * v / ww).Round());
            }

            builder.RowFormat.HeightRule = HeightRule.Auto;// HeightRule.AtLeast
            builder.CellFormat.Shading.BackgroundPatternColor = Color.FromArgb(191, 191, 191);
            builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
            builder.ParagraphFormat.Alignment    = ParagraphAlignment.Center;
            builder.Font.Size = 11;
            builder.Font.Name = "宋体";

            for (int i = 0; i < dt.Columns.Count; i++)
            {
                builder.InsertCell();
                builder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(lstW[i]);
                builder.Write(dt.Columns[i].ColumnName);
            }

            builder.EndRow();
            builder.Font.Size = 10.5;
            builder.CellFormat.Shading.BackgroundPatternColor = Color.White;
            builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
            builder.ParagraphFormat.Alignment    = ParagraphAlignment.Center;

            for (int j = startRow; j < dt.Rows.Count; j++)
            {
                for (int i = 0; i < dt.Columns.Count; i++)
                {
                    builder.InsertCell();
                    //builder.CellFormat.Width = lstW[i];
                    builder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(lstW[i]);
                    //builder.CellFormat.WrapText = true ;
                    // builder.CellFormat.FitText = false;
                    builder.Write(dt.Rows[j][i].ToString().Trim());
                }

                builder.EndRow();
            }
            builder.EndTable();
            table.AllowAutoFit = false;
            //table.AutoFit(AutoFitBehavior.FixedColumnWidths);
            //MergeCell(builder, table, mcell);
            return(table);
        }
Exemple #23
0
        public ActionResult PrintUsulanKomtek(string Type = "pdf")
        {
            var Data = db.Database.SqlQuery <VIEW_T_KOMTEK>("SELECT * FROM VIEW_T_KOMTEK WHERE T_KOMTEK_STATUS = 0 AND T_KOMTEK_PARENT_CODE = 0").ToList();

            Aspose.Words.Document doc     = new Aspose.Words.Document();
            DocumentBuilder       builder = new DocumentBuilder(doc);

            Table table = builder.StartTable();

            // Insert a few cells
            builder.InsertCell();
            table.PreferredWidth = PreferredWidth.FromPercent(100);
            builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(5);
            builder.Writeln("No");

            builder.InsertCell();
            builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(15);
            builder.Writeln("Kode KT");

            builder.InsertCell();
            builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);
            builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
            builder.Writeln("Nama KT");

            builder.InsertCell();
            builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);
            builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
            builder.Writeln("Sekretariat");

            builder.InsertCell();
            builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(25);
            builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
            builder.Writeln("Alamat");

            builder.InsertCell();
            builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(15);
            builder.Writeln("Telepon/Fax");
            builder.EndRow();

            int no = 1;

            foreach (var list in Data)
            {
                builder.InsertCell();
                builder.Writeln("" + no++);

                builder.InsertCell();
                builder.Writeln("" + list.T_KOMTEK_CODE);

                builder.InsertCell();
                builder.Writeln("" + list.T_KOMTEK_NAME);

                builder.InsertCell();
                builder.Writeln("" + list.T_KOMTEK_SEKRETARIAT);

                builder.InsertCell();
                builder.Writeln("" + list.T_KOMTEK_ADDRESS);

                builder.InsertCell();
                builder.Writeln("" + list.T_KOMTEK_PHONE);
                builder.EndRow();
            }

            MemoryStream dstStream = new MemoryStream();

            var mime = "";

            if (Type == "pdf")
            {
                doc.Save(dstStream, SaveFormat.Pdf);
                mime = "application/pdf";
            }
            else
            {
                doc.Save(dstStream, SaveFormat.Docx);
                mime = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
            }

            byte[] byteInfo = dstStream.ToArray();
            dstStream.Write(byteInfo, 0, byteInfo.Length);
            dstStream.Position = 0;

            Response.ContentType = mime;
            Response.AddHeader("content-disposition", "attachment;  filename=Usulan_Komite_Teknis." + Type);
            Response.BinaryWrite(byteInfo);
            Response.End();
            return(new FileStreamResult(dstStream, mime));
        }
        /// Escribe el encabezado en la secci?ctual al 100% de ancho
        /// <param name="docBuilder">Clase auxiliar para escribir elementos</param>
        /// <param name="instancia">Documento de instancia actualmente procesado</param>
        /// <param name="estructuraReporte">Estructura del reporte del documento</param>
        /// @throws Exception
        ///
        public override void escribirEncabezado(DocumentBuilder docBuilder, DocumentoInstanciaXbrlDto instancia, ReporteXBRLDTO estructuraReporte, bool imprimirFooter)
        {
            var ETIQUETA_CLAVE_COTIZACION = estructuraReporte.ObtenValorEtiquetaReporte("ETIQUETA_CLAVE_COTIZACION");
            var ETIQUETA_DE = estructuraReporte.ObtenValorEtiquetaReporte("ETIQUETA_DE");

            Section seccion = docBuilder.CurrentSection;

            seccion.PageSetup.DifferentFirstPageHeaderFooter = false;
            seccion.HeadersFooters.LinkToPrevious(false);
            seccion.HeadersFooters.Clear();
            docBuilder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);

            Table tablaHead = docBuilder.StartTable();

            docBuilder.ParagraphFormat.SpaceAfter  = 0;
            docBuilder.ParagraphFormat.SpaceBefore = 0;
            docBuilder.CellFormat.ClearFormatting();
            ///Fila de año y trimestre
            docBuilder.InsertCell();
            docBuilder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
            docBuilder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(70);
            docBuilder.Font.Color = Color.Gray;
            docBuilder.Font.Bold  = false;

            docBuilder.Write(ETIQUETA_CLAVE_COTIZACION + ":       ");
            docBuilder.Font.Color = Color.Black;

            if (!String.IsNullOrEmpty(estructuraReporte.ClaveCotizacion))
            {
                docBuilder.Write(estructuraReporte.ClaveCotizacion);
            }

            docBuilder.InsertCell();
            docBuilder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);
            docBuilder.ParagraphFormat.Alignment = ParagraphAlignment.Right;
            docBuilder.Font.Color = Color.Gray;

            tablaHead.PreferredWidth = PreferredWidth.FromPercent(100);
            tablaHead.SetBorders(LineStyle.None, 0, Color.Black);
            tablaHead.SetBorder(BorderType.Horizontal, LineStyle.Single, .75, Color.DarkGray, true);
            tablaHead.SetBorder(BorderType.Bottom, LineStyle.Single, .75, Color.DarkGray, true);
            docBuilder.EndTable();

            docBuilder.MoveToHeaderFooter(HeaderFooterType.FooterPrimary);

            var leyendaReportes = System.Configuration.ConfigurationManager.AppSettings.Get("LeyendaReportes");

            if (!String.IsNullOrEmpty(leyendaReportes))
            {
                Table tablaPie = docBuilder.StartTable();
                docBuilder.InsertCell();
                docBuilder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
                docBuilder.Write(leyendaReportes);


                docBuilder.InsertCell();
                docBuilder.ParagraphFormat.Alignment = ParagraphAlignment.Right;

                docBuilder.InsertField("PAGE", "");
                docBuilder.Write(" " + ETIQUETA_DE + " ");
                docBuilder.InsertField("NUMPAGES", "");
                tablaPie.SetBorders(LineStyle.None, 0, Color.Black);
                docBuilder.EndTable();
            }
            else
            {
                docBuilder.InsertField("PAGE", "");
                docBuilder.Write(" " + ETIQUETA_DE + " ");
                docBuilder.InsertField("NUMPAGES", "");
                docBuilder.CurrentParagraph.ParagraphFormat.Alignment = ParagraphAlignment.Right;
            }

            docBuilder.MoveToDocumentEnd();
        }
Exemple #25
0
        /// <summary>
        /// 引用Aspose.Words.dll导出word数据库字典文档
        /// 注意:不依赖微软office办公软件
        /// </summary>
        /// <param name="databaseName"></param>
        /// <param name="tables"></param>
        public static void ExportWordByAsposeWords(string fileName, string databaseName, List <TableDto> tables)
        {
            Aspose.Words.Document doc = new Aspose.Words.Document();

            // TODO document properties
            doc.BuiltInDocumentProperties.Subject           = "设计文档";
            doc.BuiltInDocumentProperties.ContentType       = "数据库字典";
            doc.BuiltInDocumentProperties.Title             = "数据库字典文档";
            doc.BuiltInDocumentProperties.Author            = doc.BuiltInDocumentProperties.LastSavedBy = doc.BuiltInDocumentProperties.Manager = "trycache";
            doc.BuiltInDocumentProperties.Company           = "waodng";
            doc.BuiltInDocumentProperties.Version           = doc.BuiltInDocumentProperties.RevisionNumber = 1;
            doc.BuiltInDocumentProperties.ContentStatus     = "初稿";
            doc.BuiltInDocumentProperties.NameOfApplication = "DBCHM";
            doc.BuiltInDocumentProperties.LastSavedTime     = doc.BuiltInDocumentProperties.CreatedTime = System.DateTime.Now;

            // TODO header and footer setting
            Aspose.Words.HeaderFooter header = new Aspose.Words.HeaderFooter(doc, Aspose.Words.HeaderFooterType.HeaderPrimary);
            doc.FirstSection.HeadersFooters.Add(header);
            // Add a paragraph with text to the header.
            header.AppendParagraph("数据库字典文档").ParagraphFormat.Alignment =
                Aspose.Words.ParagraphAlignment.Right;
            Aspose.Words.HeaderFooter footer = new Aspose.Words.HeaderFooter(doc, Aspose.Words.HeaderFooterType.FooterPrimary);
            doc.FirstSection.HeadersFooters.Add(footer);
            // Add a paragraph with text to the footer.
            footer.AppendParagraph(" 版权所有 @ waodng  ").ParagraphFormat.Alignment =
                Aspose.Words.ParagraphAlignment.Center;

            Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);

            // TODO 创建文档标题书签
            CreateBookmark(builder, Aspose.Words.ParagraphAlignment.Center, Aspose.Words.OutlineLevel.Level1, 25,
                           asposeBookmark_prefix + "0", "数据库字典文档");
            builder.ParagraphFormat.OutlineLevel = Aspose.Words.OutlineLevel.BodyText;
            builder.Writeln("—— " + databaseName);

            // TODO 换行
            builder.InsertBreak(Aspose.Words.BreakType.ParagraphBreak);
            builder.InsertBreak(Aspose.Words.BreakType.ParagraphBreak);
            builder.InsertBreak(Aspose.Words.BreakType.ParagraphBreak);

            // TODO 数据库字典文档修订日志表
            CreateBookmark(builder, Aspose.Words.ParagraphAlignment.Center, Aspose.Words.OutlineLevel.Level2, 16,
                           asposeBookmarkLog, AppConst.LOG_CHAPTER_NAME);
            CreateLogTable(builder);
            builder.InsertBreak(Aspose.Words.BreakType.PageBreak);

            // TODO 创建数据库字典文档数据库概况一览表
            CreateBookmark(builder, Aspose.Words.ParagraphAlignment.Center, Aspose.Words.OutlineLevel.Level2, 16,
                           asposeBookmarkOverview, AppConst.TABLE_CHAPTER_NAME);
            CreateOverviewTable(builder, tables);
            builder.InsertBreak(Aspose.Words.BreakType.PageBreak);

            // TODO 创建书签
            CreateBookmark(builder, Aspose.Words.ParagraphAlignment.Left, Aspose.Words.OutlineLevel.Level2, 16,
                           asposeBookmark_prefix + 0, AppConst.TABLE_STRUCTURE_CHAPTER_NAME);

            int i = 0; // 计数器

            // TODO 遍历数据库表集合
            foreach (var table in tables)
            {
                string bookmarkName = table.TableName + " " + (!string.IsNullOrWhiteSpace(table.Comment) ? table.Comment : "");

                // TODO 创建书签
                CreateBookmark(builder, Aspose.Words.ParagraphAlignment.Left, Aspose.Words.OutlineLevel.Level3, 16,
                               asposeBookmark_prefix + i, table.TableOrder + "、" + bookmarkName);

                // TODO 遍历数据库表字段集合
                // TODO 创建表格
                Aspose.Words.Tables.Table asposeTable = builder.StartTable();

                // 清除段落样式
                builder.ParagraphFormat.ClearFormatting();

                #region 表格列设置,列标题,列宽,字体等
                // Make the header row.
                builder.InsertCell();
                // Set the left indent for the table. Table wide formatting must be applied after
                // at least one row is present in the table.
                asposeTable.Alignment      = Aspose.Words.Tables.TableAlignment.Center;
                asposeTable.PreferredWidth = PreferredWidth.FromPercent(120);
                asposeTable.AllowAutoFit   = false;
                // Set height and define the height rule for the header row.
                builder.RowFormat.Height     = 40.0;
                builder.RowFormat.HeightRule = Aspose.Words.HeightRule.AtLeast;
                // Some special features for the header row.
                builder.CellFormat.Shading.BackgroundPatternColor = System.Drawing.Color.FromArgb(198, 217, 241);
                builder.ParagraphFormat.Alignment = Aspose.Words.ParagraphAlignment.Center;
                builder.Font.Size = 14;
                builder.Font.Name = "Arial";
                builder.Font.Bold = true;
                builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(8);
                builder.Write("序号");

                // We don't need to specify the width of this cell because it's inherited from the previous cell.
                builder.InsertCell();
                builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);
                builder.Write("列名");

                builder.InsertCell();
                builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(12);
                builder.Write("数据类型");

                builder.InsertCell();
                builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(8);
                builder.Write("长度");

                builder.InsertCell();
                builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(8);
                builder.Write("小数位");

                builder.InsertCell();
                builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(8);
                builder.Write("主键");

                builder.InsertCell();
                builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(8);
                builder.Write("自增");

                builder.InsertCell();
                builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(8);
                builder.Write("允许空");

                builder.InsertCell();
                builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(10);
                builder.Write("默认值");

                builder.InsertCell();
                builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);
                builder.Write("列说明");
                builder.EndRow();
                #endregion

                foreach (var column in table.Columns)
                {
                    #region 遍历表格数据行写入
                    // Set features for the other rows and cells.
                    builder.CellFormat.Shading.BackgroundPatternColor = System.Drawing.Color.White;
                    builder.CellFormat.Width             = 100.0;
                    builder.CellFormat.VerticalAlignment = Aspose.Words.Tables.CellVerticalAlignment.Center;
                    //builder.CellFormat.FitText = true;
                    // Reset height and define a different height rule for table body
                    builder.RowFormat.Height     = 60.0;
                    builder.RowFormat.HeightRule = Aspose.Words.HeightRule.AtLeast;
                    builder.InsertCell();
                    // Reset font formatting.
                    builder.Font.Size = 12;
                    builder.Font.Bold = false;
                    builder.Write(column.ColumnOrder); // 序号

                    builder.InsertCell();
                    builder.Write(column.ColumnName); // 列名

                    builder.InsertCell();
                    builder.Write(column.ColumnTypeName); // 数据类型

                    builder.InsertCell();
                    builder.Write(column.Length); // 长度

                    builder.InsertCell();
                    builder.Write(column.Scale); // 小数位

                    builder.InsertCell();
                    builder.Write(column.IsPK); // 主键

                    builder.InsertCell();
                    builder.Write(column.IsIdentity); // 自增

                    builder.InsertCell();
                    builder.Write(column.CanNull); // 是否为空

                    builder.InsertCell();
                    builder.Font.Size = 10;
                    builder.Write(column.DefaultVal); // 默认值

                    builder.InsertCell();
                    builder.Font.Size = 10;
                    builder.Write(column.Comment); // 列说明

                    builder.EndRow();
                    #endregion
                }

                // TODO 表格创建完成,结束
                //asposeTable.PreferredWidth = Aspose.Words.Tables.PreferredWidth.Auto;
                //asposeTable.AutoFit(Aspose.Words.Tables.AutoFitBehavior.AutoFitToContents);
                builder.EndTable();

                i++;

                // TODO page breaks
                if (i < tables.Count)
                {
                    builder.InsertBreak(Aspose.Words.BreakType.PageBreak);
                }
            }

            // TODO 添加水印
            //InsertWatermarkText(doc, "DBCHM-51Try.Top");

            doc.Save(fileName);
        }
Exemple #26
0
        private void PintaTabla(DocumentBuilder docBuilder, DocumentoInstanciaXbrlDto instancia, IndiceReporteDTO rolAExportar, ReporteXBRLDTO estructuraReporte, IList <ConceptoReporteDTO> listaConseptosReporte)
        {
            docBuilder.Writeln();
            Table tablaActual = docBuilder.StartTable();
            Color colorTitulo = Color.FromArgb(ColorTituloTabla[0], ColorTituloTabla[1], ColorTituloTabla[2]);

            docBuilder.ParagraphFormat.SpaceAfter  = 0;
            docBuilder.ParagraphFormat.SpaceBefore = 2;

            ConceptoReporteDTO primerConcepto = null;

            if (!estructuraReporte.Roles.ContainsKey(rolAExportar.Rol))
            {
                throw new IndexOutOfRangeException("No existe el rol [" + rolAExportar.Rol + "] dentro del listado de roles del reporte.");
            }
            if (estructuraReporte.Roles.ContainsKey(rolAExportar.Rol))
            {
                foreach (ConceptoReporteDTO concepto in estructuraReporte.Roles[rolAExportar.Rol])
                {
                    if (!concepto.Abstracto)
                    {
                        primerConcepto = concepto;
                        break;
                    }
                }
            }
            establecerFuenteTituloCampo(docBuilder);
            docBuilder.Font.Size = TamanioLetraTituloTabla;
            docBuilder.InsertCell();

            //tablaActual.StyleIdentifier = StyleIdentifier.LIGHT_GRID_ACCENT_1;
            //tablaActual.StyleOptions = TableStyleOptions.FIRST_ROW;

            docBuilder.CellFormat.Shading.BackgroundPatternColor = colorTitulo;
            docBuilder.CellFormat.PreferredWidth = PreferredWidth.Auto;
            docBuilder.Font.Color = Color.White;
            docBuilder.Write(estructuraReporte.ObtenValorEtiquetaReporte("ETIQUETA_CONCEPTO"));

            foreach (String periodo in primerConcepto.Hechos.Keys)
            {
                docBuilder.InsertCell();
                docBuilder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
                docBuilder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(AnchoPreferidoColumnaDatos);
                //docBuilder.CellFormat.Width = 35;
                docBuilder.CellFormat.WrapText = false;
                docBuilder.CellFormat.Shading.BackgroundPatternColor = colorTitulo;
                String descPeriodo = estructuraReporte.PeriodosReporte[periodo];
                docBuilder.Writeln(estructuraReporte.Titulos[periodo]);
                docBuilder.Write(descPeriodo.Replace("_", " - "));
            }
            docBuilder.RowFormat.HeadingFormat = true;
            docBuilder.EndRow();

            establecerFuenteValorCampo(docBuilder);
            docBuilder.Font.Size = TamanioLetraContenidoTabla;


            foreach (ConceptoReporteDTO concepto in listaConseptosReporte)
            {
                //  string valor = ObtenertipoDato(concepto, TIPO_DATO_MONETARY);
                //string tipoNoNegativo = ObtenertipoDato(concepto, TIPO_DATO_NoNEGATIVO);
                if (concepto.IdConcepto != ID_Importe && concepto.IdConcepto != ID_IVA && concepto.IdConcepto != ID_Total)

                {
                    docBuilder.InsertCell();
                    docBuilder.CellFormat.PreferredWidth = PreferredWidth.Auto;
                    docBuilder.CellFormat.Shading.BackgroundPatternColor = Color.White;
                    docBuilder.CellFormat.WrapText = true;
                    docBuilder.Font.Color          = Color.Black;
                    if (concepto.Abstracto)
                    {
                        docBuilder.Bold       = true;
                        docBuilder.Font.Color = Color.White;
                        docBuilder.CellFormat.Shading.BackgroundPatternColor = colorTitulo;
                    }
                    else
                    {
                        docBuilder.Bold = false;
                    }
                    docBuilder.ParagraphFormat.LeftIndent = (concepto.Tabuladores < 0 ? concepto.Tabuladores : 0);
                    docBuilder.ParagraphFormat.Alignment  = ParagraphAlignment.Left;
                    if (concepto.AtributosAdicionales != null)
                    {
                        if (concepto.AtributosAdicionales.Count == 1)
                        {
                            conceptosEnIndice(docBuilder, concepto);
                        }
                        else
                        {
                            docBuilder.Write(concepto.Valor);
                        }
                    }
                    else
                    {
                        docBuilder.Write(concepto.Valor);
                    }
                    if (concepto.Abstracto)
                    {
                        for (int iCell = 0; iCell < primerConcepto.Hechos.Count(); iCell++)
                        {
                            docBuilder.InsertCell();
                            docBuilder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(AnchoPreferidoColumnaDatos);
                        }
                    }
                    else
                    {
                        foreach (HechoReporteDTO hecho in concepto.Hechos.Values)
                        {
                            docBuilder.InsertCell();
                            docBuilder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(AnchoPreferidoColumnaDatos);

                            docBuilder.ParagraphFormat.LeftIndent = 0;
                            if (concepto.Numerico)
                            {
                                docBuilder.CellFormat.WrapText       = true;
                                docBuilder.ParagraphFormat.Alignment = ParagraphAlignment.Right;
                            }
                            else
                            {
                                docBuilder.CellFormat.WrapText       = false;
                                docBuilder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
                            }
                            escribirValorHecho(docBuilder, estructuraReporte, hecho, concepto);
                        }
                    }
                    docBuilder.RowFormat.AllowBreakAcrossPages = true;
                    docBuilder.RowFormat.HeadingFormat         = false;
                    docBuilder.EndRow();
                }
            }
            establecerBordesGrisesTabla(tablaActual);
            docBuilder.EndTable();
            docBuilder.Writeln();
        }
Exemple #27
0
        ///
        /// (non-Javadoc)
        /// @see com.bmv.spread.xbrl.reportes.exportador.ExportadorRolDocumentoInstancia#exportarRolAWord(com.aspose.words.DocumentBuilder, com.hh.xbrl.abax.viewer.application.dto.DocumentoInstanciaXbrlDto, com.bmv.spread.xbrl.reportes.dto.IndiceReporteDTO, com.bmv.spread.xbrl.reportes.dto.ReporteXBRLDTO)
        ////
        override public void exportarRolAWord(DocumentBuilder docBuilder, DocumentoInstanciaXbrlDto instancia, IndiceReporteDTO rolAExportar, ReporteXBRLDTO estructuraReporte)
        {
            Color colorTitulo = Color.FromArgb(ColorTituloTabla[0], ColorTituloTabla[1], ColorTituloTabla[2]);

            docBuilder.CurrentSection.PageSetup.Orientation = Orientation.Portrait;
            docBuilder.CurrentSection.PageSetup.LeftMargin  = 40;
            docBuilder.CurrentSection.PageSetup.RightMargin = 40;
            escribirEncabezado(docBuilder, instancia, estructuraReporte, true);
            imprimirTituloRol(docBuilder, rolAExportar);

            //Escribir nota inicial
            IList <ConceptoReporteDTO> conceptos = estructuraReporte.Roles[rolAExportar.Rol];
            HechoReporteDTO            hechoNota = null;
            var conceptoNota = "ifrs_mx-cor_20141205_InformacionARevelarSobrePosicionMonetariaEnMonedaExtranjeraBloqueDeTexto";

            foreach (var concepto in conceptos)
            {
                if (!concepto.IdConcepto.Equals(conceptoNota))
                {
                    continue;
                }
                foreach (var llave in concepto.Hechos.Keys)
                {
                    hechoNota = concepto.Hechos[llave];
                    if (hechoNota != null)
                    {
                        if (String.IsNullOrWhiteSpace(hechoNota.Valor) && instancia.HechosPorIdConcepto.ContainsKey(conceptoNota))
                        {
                            var idsHechos = instancia.HechosPorIdConcepto[conceptoNota];
                            foreach (var idHecho in idsHechos)
                            {
                                if (instancia.HechosPorId.ContainsKey(idHecho))
                                {
                                    var hechoReal = instancia.HechosPorId[idHecho];
                                    if (!String.IsNullOrWhiteSpace(hechoReal.Valor))
                                    {
                                        hechoNota.Valor = hechoReal.Valor;
                                        break;
                                    }
                                }
                            }
                        }
                        if (!String.IsNullOrWhiteSpace(hechoNota.Valor))
                        {
                            escribirConceptoEnTablaNota(docBuilder, estructuraReporte, hechoNota, concepto);
                            break;
                        }
                    }
                }
            }
            //conceptos.Remove(0);

            conceptos = ((List <ConceptoReporteDTO>)conceptos).GetRange(1, conceptos.Count() - 1);


            Table tablaActual = docBuilder.StartTable();
            ConceptoReporteDTO primerConcepto = null;

            foreach (ConceptoReporteDTO concepto  in  conceptos)
            {        //estructuraReporte.Roles[rolAExportar.Rol]){
                if (!concepto.Abstracto)
                {
                    primerConcepto = concepto;
                    break;
                }
            }
            docBuilder.Font.Color = Color.White;
            docBuilder.ParagraphFormat.SpaceAfter  = 0;
            docBuilder.ParagraphFormat.SpaceBefore = 2;
            establecerFuenteTituloCampo(docBuilder);
            docBuilder.Font.Size = TamanioLetraTituloTabla;

            //Titlo de dimension

            docBuilder.InsertCell();
            docBuilder.CellFormat.Shading.BackgroundPatternColor = colorTitulo;
            docBuilder.CellFormat.PreferredWidth  = PreferredWidth.Auto;
            docBuilder.CellFormat.HorizontalMerge = CellMerge.None;
            int iCol = 0;

            foreach (String columna  in  primerConcepto.Hechos.Keys)
            {
                docBuilder.InsertCell();
                docBuilder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(AnchoPreferidoColumnaDatos);
                docBuilder.CellFormat.WrapText       = false;
                docBuilder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
                docBuilder.CellFormat.Shading.BackgroundPatternColor = colorTitulo;
                if (iCol == 0)
                {
                    String descPeriodo = (String)estructuraReporte.ParametrosReporte["ifrs_mx-cor_20141205_MonedasEje_HEADER"];
                    docBuilder.Write(descPeriodo);
                    docBuilder.CellFormat.HorizontalMerge = CellMerge.First;
                }
                else
                {
                    docBuilder.CellFormat.HorizontalMerge = CellMerge.Previous;
                }
                iCol++;
            }

            docBuilder.EndRow();

            docBuilder.InsertCell();
            docBuilder.CellFormat.Shading.BackgroundPatternColor = colorTitulo;
            docBuilder.CellFormat.PreferredWidth  = PreferredWidth.Auto;
            docBuilder.CellFormat.HorizontalMerge = CellMerge.None;
            foreach (String columna  in  primerConcepto.Hechos.Keys)
            {
                docBuilder.InsertCell();
                docBuilder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(AnchoPreferidoColumnaDatos);
                docBuilder.CellFormat.WrapText       = false;
                docBuilder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
                docBuilder.CellFormat.Shading.BackgroundPatternColor = colorTitulo;
                String descPeriodo = (String)estructuraReporte.ParametrosReporte[columna + "_HEADER"];
                docBuilder.Write(descPeriodo);
                docBuilder.CellFormat.HorizontalMerge = CellMerge.First;
            }
            docBuilder.EndRow();

            establecerFuenteValorCampo(docBuilder);
            docBuilder.Font.Size = TamanioLetraContenidoTabla;
            foreach (ConceptoReporteDTO concepto  in  conceptos)
            {
                if (concepto.Abstracto && !ConceptosAbstractosPermitidos.Contains(concepto.IdConcepto))
                {
                    continue;
                }
                docBuilder.InsertCell();
                docBuilder.CellFormat.PreferredWidth = PreferredWidth.Auto;
                docBuilder.CellFormat.Shading.BackgroundPatternColor = Color.White;
                docBuilder.CellFormat.WrapText = true;
                docBuilder.Font.Color          = Color.Black;
                if (concepto.Abstracto)
                {
                    docBuilder.Bold       = true;
                    docBuilder.Font.Color = Color.White;
                    docBuilder.CellFormat.Shading.BackgroundPatternColor = colorTitulo;
                }
                else
                {
                    docBuilder.Bold = false;
                }
                docBuilder.ParagraphFormat.LeftIndent = (concepto.Tabuladores < 0 ? concepto.Tabuladores : 0);
                docBuilder.ParagraphFormat.Alignment  = ParagraphAlignment.Left;
                docBuilder.Write(concepto.Valor);
                if (concepto.Abstracto)
                {
                    for (int iCell = 0; iCell < primerConcepto.Hechos.Count(); iCell++)
                    {
                        docBuilder.InsertCell();
                        docBuilder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(AnchoPreferidoColumnaDatos);
                    }
                }
                else
                {
                    foreach (HechoReporteDTO hecho  in  concepto.Hechos.Values)
                    {
                        docBuilder.InsertCell();
                        docBuilder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(AnchoPreferidoColumnaDatos);

                        docBuilder.ParagraphFormat.LeftIndent = 0;
                        if (concepto.Numerico)
                        {
                            docBuilder.CellFormat.WrapText       = true;
                            docBuilder.ParagraphFormat.Alignment = ParagraphAlignment.Right;
                        }
                        else
                        {
                            docBuilder.CellFormat.WrapText       = false;
                            docBuilder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
                        }
                        escribirValorHecho(docBuilder, estructuraReporte, hecho, concepto);
                    }
                }
                docBuilder.RowFormat.AllowBreakAcrossPages = true;
                docBuilder.RowFormat.HeadingFormat         = false;
                docBuilder.EndRow();
            }


            tablaActual.SetBorders(LineStyle.Single, 1, ReportConstants.DEFAULT_BORDER_GREY_COLOR);
            docBuilder.EndTable();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            //Create word document
            Document document = new Document();

            //Create a new section
            Section section = document.AddSection();

            //Create a table width default borders
            Table table = section.AddTable(true);
            //Set table with to 100%
            PreferredWidth width = new PreferredWidth(WidthType.Percentage, 100);

            table.PreferredWidth = width;

            //Add a new row
            TableRow row = table.AddRow();

            //Set the row as a table header
            row.IsHeader = true;
            //Set the backcolor of row
            row.RowFormat.BackColor = Color.LightGray;
            //Add a new cell for row
            TableCell cell = row.AddCell();

            cell.SetCellWidth(100, CellWidthType.Percentage);
            //Add a paragraph for cell to put some data
            Paragraph parapraph = cell.AddParagraph();

            //Add text
            parapraph.AppendText("Row Header 1");
            //Set paragraph horizontal center alignment
            parapraph.Format.HorizontalAlignment = Spire.Doc.Documents.HorizontalAlignment.Center;

            row                     = table.AddRow(false, 1);
            row.IsHeader            = true;
            row.RowFormat.BackColor = Color.Ivory;
            //Set row height
            row.Height = 30;
            cell       = row.Cells[0];
            cell.SetCellWidth(100, CellWidthType.Percentage);
            //Set cell vertical middle alignment
            cell.CellFormat.VerticalAlignment = VerticalAlignment.Middle;
            //Add a paragraph for cell to put some data
            parapraph = cell.AddParagraph();
            //Add text
            parapraph.AppendText("Row Header 2");
            parapraph.Format.HorizontalAlignment = Spire.Doc.Documents.HorizontalAlignment.Center;

            //Add many common rows
            for (int i = 0; i < 70; i++)
            {
                row  = table.AddRow(false, 2);
                cell = row.Cells[0];
                //Set cell width to 50% of table width
                cell.SetCellWidth(50, CellWidthType.Percentage);
                cell.AddParagraph().AppendText("Column 1 Text");
                cell = row.Cells[1];
                cell.SetCellWidth(50, CellWidthType.Percentage);
                cell.AddParagraph().AppendText("Column 2 Text");
            }
            //Set cell backcolor
            for (int j = 1; j < table.Rows.Count; j++)
            {
                if (j % 2 == 0)
                {
                    TableRow row2 = table.Rows[j];
                    for (int f = 0; f < row2.Cells.Count; f++)
                    {
                        row2.Cells[f].CellFormat.BackColor = Color.LightBlue;
                    }
                }
            }

            String result = "RepeatRowOnEachPage_out.docx";

            //Save file.
            document.SaveToFile(result, FileFormat.Docx);

            //Launching the Word file.
            WordDocViewer(result);
        }
        /// <summary>
        /// Imprime el valor de un hecho a dos columnas.
        /// </summary>
        /// <param name="docBuilder">Constructor del documento.</param>
        /// <param name="estructuraReporte">DTO con información general del reporte actual</param>
        /// <param name="concepto">Concepto que se presenta.</param>
        /// <param name="hecho">Hecho que se persenta.</param>
        public override void EscribirADosColumnasConceptoValor(DocumentBuilder docBuilder, ReporteXBRLDTO estructuraReporte, ConceptoReporteDTO concepto, HechoReporteDTO hecho)
        {
            Table tablaActual = docBuilder.StartTable();

            tablaActual.SetBorders(LineStyle.None, 0, Color.Black);
            docBuilder.ParagraphFormat.SpaceAfter  = 5;
            docBuilder.ParagraphFormat.SpaceBefore = 5;

            docBuilder.InsertCell();
            docBuilder.CellFormat.Shading.BackgroundPatternColor = Color.White;
            var anchoMinimoEtiqueta = (AnchoMinimoTitulodosColumnas != null && AnchoMinimoTitulodosColumnas > 0) ? AnchoMinimoTitulodosColumnas ?? 30 : 30;
            var anchoMinimoValor    = 100 - anchoMinimoEtiqueta;

            docBuilder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(anchoMinimoEtiqueta);

            docBuilder.CellFormat.Borders.LineStyle = LineStyle.None;
            docBuilder.CellFormat.Borders.LineWidth = 0;
            if (!concepto.IdConcepto.Equals("rel_news_Ticker"))
            {
                docBuilder.CellFormat.Borders.Right.Color     = Color.Black;
                docBuilder.CellFormat.Borders.Right.LineStyle = LineStyle.Single;
                docBuilder.CellFormat.Borders.Right.LineWidth = .75;
            }
            else
            {
                docBuilder.CellFormat.Borders.Bottom.Color     = Color.Black;
                docBuilder.CellFormat.Borders.Bottom.LineStyle = LineStyle.Single;
                docBuilder.CellFormat.Borders.Bottom.LineWidth = .75;
            }

            establecerFuenteTituloCampo(docBuilder);
            docBuilder.Font.Size  = 11;
            docBuilder.Font.Color = Color.Black;
            AplicaEstilosEtiquetaConcepto(docBuilder, concepto.IdConcepto, estructuraReporte);
            docBuilder.Write(concepto.Valor);
            docBuilder.ParagraphFormat.Alignment = ParagraphAlignment.Justify;

            //docBuilder.Write(": ");
            var estructurasRol = estructuraReporte.Roles.Values.First();
            var esPar          = estructurasRol.IndexOf(concepto) % 2;

            docBuilder.InsertCell();
            if (esPar == 0)
            {
                docBuilder.CellFormat.Shading.BackgroundPatternColor = Color.FromArgb(255, 242, 242, 242);
            }
            if (!concepto.IdConcepto.Equals("rel_news_Ticker"))
            {
                docBuilder.CellFormat.Borders.Right.Color     = Color.White;
                docBuilder.CellFormat.Borders.Right.LineStyle = LineStyle.None;
                docBuilder.CellFormat.Borders.Right.LineWidth = 0;
            }
            else
            {
                docBuilder.CellFormat.Borders.Bottom.Color     = Color.Black;
                docBuilder.CellFormat.Borders.Bottom.LineStyle = LineStyle.Single;
                docBuilder.CellFormat.Borders.Bottom.LineWidth = .75;
            }
            docBuilder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(anchoMinimoValor);
            establecerFuenteValorCampo(docBuilder);
            docBuilder.ParagraphFormat.Alignment = ParagraphAlignment.Left;

            docBuilder.Font.Size = 10;
            AplicaEstilosValorConcepto(docBuilder, concepto.IdConcepto, estructuraReporte);
            escribirValorHecho(docBuilder, estructuraReporte, hecho, concepto);
            docBuilder.EndRow();

            docBuilder.EndTable();
            docBuilder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
        }
        public override void escribirEncabezado(DocumentBuilder docBuilder, DocumentoInstanciaXbrlDto instancia, ReporteXBRLDTO estructuraReporte, bool imprimirFooter)
        {
            var etiquetaReporte = ReporteXBRLUtil.obtenerEtiquetaConcepto(estructuraReporte.Lenguaje, null, "rel_news_RelevantEventReportAbstract", instancia);
            var claveEntidad    = ReporteXBRLUtil.obtenerValorHechoDefault("rel_news_Ticker", instancia, "");
            var etiquetaFecha   = ReporteXBRLUtil.obtenerEtiquetaConcepto(estructuraReporte.Lenguaje, null, "rel_news_Date", instancia);
            var fechaReporte    = ReporteXBRLUtil.obtenerValorHechoDefault("rel_news_Date", instancia, "");
            var ETIQUETA_DE     = estructuraReporte.ObtenValorEtiquetaReporte("ETIQUETA_DE");



            Section seccion = docBuilder.CurrentSection;

            seccion.PageSetup.DifferentFirstPageHeaderFooter = false;
            seccion.HeadersFooters.LinkToPrevious(false);
            seccion.HeadersFooters.Clear();
            docBuilder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);

            Table tablaHead = docBuilder.StartTable();

            docBuilder.ParagraphFormat.SpaceAfter  = 0;
            docBuilder.ParagraphFormat.SpaceBefore = 0;
            docBuilder.CellFormat.ClearFormatting();
            ///Fila de año y trimestre
            docBuilder.InsertCell();
            docBuilder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
            docBuilder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(70);
            docBuilder.Font.Color = Color.Gray;
            docBuilder.Font.Bold  = false;
            docBuilder.Font.Size  = 9;
            docBuilder.Write(etiquetaReporte + " - " + claveEntidad);
            docBuilder.Font.Color = Color.Black;
            docBuilder.EndRow();

            docBuilder.InsertCell();
            docBuilder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
            docBuilder.Font.Color = Color.Gray;
            docBuilder.Font.Size  = 8;
            docBuilder.Write(etiquetaFecha + " - " + fechaReporte);

            tablaHead.PreferredWidth = PreferredWidth.FromPercent(100);
            tablaHead.SetBorders(LineStyle.None, 0, Color.White);
            docBuilder.EndTable();

            docBuilder.MoveToHeaderFooter(HeaderFooterType.FooterPrimary);

            var leyendaReportes = System.Configuration.ConfigurationManager.AppSettings.Get("LeyendaReportes");

            if (!String.IsNullOrEmpty(leyendaReportes))
            {
                Table tablaPie = docBuilder.StartTable();
                docBuilder.InsertCell();
                docBuilder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
                docBuilder.Write(leyendaReportes);


                docBuilder.InsertCell();
                docBuilder.ParagraphFormat.Alignment = ParagraphAlignment.Right;

                docBuilder.InsertField("PAGE", "");
                docBuilder.Write(" " + ETIQUETA_DE + " ");
                docBuilder.InsertField("NUMPAGES", "");
                tablaPie.SetBorders(LineStyle.None, 0, Color.Black);
                docBuilder.EndTable();
            }
            else
            {
                docBuilder.InsertField("PAGE", "");
                docBuilder.Write(" " + ETIQUETA_DE + " ");
                docBuilder.InsertField("NUMPAGES", "");
                docBuilder.CurrentParagraph.ParagraphFormat.Alignment = ParagraphAlignment.Right;
            }

            docBuilder.MoveToDocumentEnd();
        }