Spire.Doc in ASP.NET

1

I am starting to use Spire.Doc , and I would like to know how to include an image in a table (a dynamic image)

I have the code that comes on the page of Spire.Doc

Table:

    //Se crea la tabla
    document = new Document();
    section = document.AddSection();
    Spire.Doc.Table tabla = section.AddTable(true);

    //Crear encabezado de tabla
    string [] Encabezado = {"Producto","Precio"};
    string[][] Datos = {
                        new string[]{"Monitor","$8,500"},
                        new string[]{"Laptop","$15,500"},
                        new string[]{"Teclado","$500"},
                        };
    //Agregar Celdas
    tabla.ResetCells(Datos.Length + 1, Encabezado.Length);

    //Encabezado de Filas
    Spire.Doc.TableRow Filas = tabla.Rows[0];
    Filas.IsHeader = true;

    //Alto de las filas
    Filas.Height = 23;

    //Formato del Encabezado
    Filas.RowFormat.BackColor = Color.AliceBlue;
    for (int i = 0; i < Encabezado.Length; i++)
    {
        //Formato de las celdas
        paragraph = Filas.Cells[i].AddParagraph();
        Filas.Cells[i].CellFormat.VerticalAlignment = VerticalAlignment.Middle;
        paragraph.Format.HorizontalAlignment = HorizontalAlignment.Center;

        //Formato de los datos
        TextRange TR = paragraph.AppendText(Encabezado[i]);
        TR.CharacterFormat.FontName = "Calibri";
        TR.CharacterFormat.FontSize = 14;
        TR.CharacterFormat.TextColor = Color.Teal;
        TR.CharacterFormat.Bold = true;
    }

    //Datos de la Fila
    for (int j = 0; j < Datos.Length; j++)
    {
        Spire.Doc.TableRow DR = tabla.Rows[j + 1];

        //Tamaño de las filas
        DR.Height = 20;

        //K Representara las columnas
        for (int k = 0; k < Datos[j].Length; k++)
        {
            //Posicion de las celdas
            DR.Cells[k].CellFormat.VerticalAlignment = VerticalAlignment.Middle;

            //Llenar las filas
            Paragraph paragraph2 = DR.Cells[k].AddParagraph();
            TextRange TR2 = paragraph2.AppendText(Datos[j][k]);

            //Formato de celdas
            paragraph2.Format.HorizontalAlignment = HorizontalAlignment.Center;
            TR2.CharacterFormat.FontName = "Calibri";
            TR2.CharacterFormat.TextColor = Color.Brown;
            TR2.CharacterFormat.FontSize = 12;
        }
    }

    //Guardar
    document.SaveToFile("PruebaTabla.doc");

and This takes the picture:

    //Toma la imagen de la ruta especifica
    Bitmap p = new Bitmap(System.Drawing.Image.FromFile("C:/Users/marcor/Pictures/Azul.jpg"));

    //Inserta imagen en el documento
    DocPicture picture = document.Sections[0].Paragraphs[0].AppendPicture(p);

    //Configuración de la posición de la imagen
    picture.HorizontalPosition = 50.0F;
    picture.VerticalPosition = 60.0F;

    //Configuración del tamaño de la imagen
    picture.Width = 200;
    picture.Height = 200;

    //Ajusta la imagen
    picture.TextWrappingStyle = TextWrappingStyle.TopAndBottom;
    
asked by Marco Torres 13.10.2016 в 20:12
source

0 answers