|
|
|
|
- Manejar una Mesa mediante programación
Inserta una tabla en un procesador de textos Document ir reemplaza el fragmento especificado con un nuevo tabla. // Inserts a 3x3 table at position 1 DocInsertTable(WP_Table, 1, 3, 3)
// Inserts a table containing 3 columns and 2 rows at cursor position DocInsertTable(WP_Table, WP_Table.Cursor, 3, 2)
Sintaxis
Insertar un tabla en un procesador de textos Document Ocultar los detalles
<Result> = DocInsertTable(<Document> , <Position> [, <Number of columns> [, <Number of rows>]])
<Result>: Variable de tipo DocFragment Variable de tipo docFragment que contiene el fragmento insertado. <Document>: Documento Variable o cadena de caracteres Document para usar. Este documento corresponde a: - el nombre de un control Procesador de texto.
- a Variable de tipo Document.
<Position>: Integro La posición donde se insertará la tabla. Esta posición se expresa en número de caracteres. <Number of columns>: Entero opcional Número de columnas en la tabla. De forma predeterminada, este parámetro corresponde a 1. <Number of rows>: Entero opcional Número de filas en la tabla. Este parámetro corresponde al 1 de Default.
Reemplazando el fragmento existente por una nueva tabla Ocultar los detalles
<Result> = DocInsertTable(<Fragment> [, <Number of columns> [, <Number of rows>]])
<Result>: Variable de tipo DocFragment Variable de tipo docFragment que contiene el fragmento insertado. <Fragment>: Variable de tipo DocFragment Nombre de la docFragment Variable que corresponde al fragmento a manipular. El contenido actual del fragmento será sustituido por el creado por tabla. <Number of columns>: Entero opcional Número de columnas en la tabla. De forma predeterminada, este parámetro corresponde a 1. <Number of rows>: Entero opcional Número de filas en la tabla. Este parámetro corresponde al 1 de Default. Observaciones Manejar una Mesa mediante programación Una tabla en un procesador de textos Document puede ser manejada por las funciones de WLanguage para la gestión de arrays. Por ejemplo: Ejemplo: // Inserts a 3x3 table at position 1 DocInsertTable(WP_ExampleWP, 1, 3, 3) // Define a fragment corresponding to the table f is docFragment(WP_ExampleWP.Value, WP_ExampleWP.Cursor, 0) let para <- f.Paragraph[1] IF para.Table = Null THEN RETURN END doc is Document <- WP_ExampleWP.Value // Adds a row to the table nIndex is int = Add(para.Table.Rows) // Input in cell 2,2 para.Table.Cells[2,2].Content.Text = "I am in cell 2,2" // Deletes row 3 Delete(para.Table.Rows, 3) // Deletes column 3 Delete(para.Table.Columns, 3) // Deletes the entire table where the cursor is positioned Delete(doc.Paragraph, para.ParagraphSubscript) Ejemplo de creación de un tabla en un documento con el contenido de un control Tabla: // A window contains a Table control populated programmatically named TABLE_Demo // and a Word Processing control named WP_Demo // The following code adds a table into the Word Processing control with: // - in first table row, the title of columns found in the Table control, // - the content of Table control in the other table rows. MyDoc is Document cTable is Control <- TABLE_Demo pCol is Control FragmentStart is docFragment(MyDoc,1) FragmentStart.Formatting.FontSize = 24 FragmentStart.Formatting.TextColor = DarkRed FragmentStart.Text = "Table in WP with " + cTable.Caption + CR + CR // Insert the table into the document in memory ... DocInsertTable(MyDoc, 20, TableCount(cTable, toColumn), cTable.Occurrence + 1) FOR EACH para OF MyDoc.Paragraph IF para.Table <> Null THEN // For all columns of the table control ... FOR nColumn = 1 _TO_ TableCount(cTable, toColumn) // First tab le line containing the title of columns pCol <- TableEnumColumn(cTable, nColumn) para.Table.Cells[1, nColumn].Content.Text = pCol.Caption // Fill all rows of this column FOR nRow = 1 _TO_ cTable.Occurrence para.Table.Cells[nRow+1, nColumn].Content.Text = pCol[nRow] END END BREAK END END // Document in memory assigned to the Word Processing control WP_Demo = MyDoc
Esta página también está disponible para…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|