AYUDA EN LÍNEA
 WINDEVWEBDEV Y WINDEV MOBILE

Este contenido se ha traducido automáticamente.  Haga clic aquí  para ver la versión en inglés.
Ayuda / WLanguage / Funciones WLanguage / Controles, páginas y ventanas / Funciones Procesador de texto
  • Manejar una Mesa mediante programación
Inserta una tabla en una control Procesador de texto.
Ejemplo
// Inserts a 3x3 table at position 1
WP_Table.InsertTable(1, 3, 3)
// Inserts a table containing 3 columns and 2 rows at cursor position
WP_Table.InsertTable(WP_Table.Cursor, 3, 2)
Sintaxis
<Result> = <Word Processing control>.InsertTable(<Position> [, <Number of columns> [, <Number of rows>]])
<Result>: Variable de tipo DocFragment
Variable de tipo docFragment que contiene el fragmento insertado.
<Word Processing control>: Nombre del control
Nombre del control Procesador de texto a manipular.
<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.
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:
// Retrieve the document
MyDocument is Document <- WP_ExampleWP
// Inserts a 3x3 table at position 1
WP_Example.InsertTable(1, 3, 3)
 
// Define a fragment corresponding to the table
f is WP_Example WP.Value.Fragment(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 MyDoc.docFragment(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 ...
MyDoc.DocInsertTable(20, TableCount(cTable, toColumn), cTable.Count + 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
Componente: wd290mdl.dll
Versión mínima requerida
  • Versión 23
Esta página también está disponible para…
Comentarios
Haga clic en [Agregar] para publicar un comentario

Última modificación: 22/06/2023

Señalar un error o enviar una sugerencia | Ayuda local