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
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReportes y ConsultasCódigo de Usuario (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Código Navegador
WINDEV Mobile
AndroidWidget Android iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Otros
Procedimientos almacenados
Inserta una tabla en un procesador de textos Document ir reemplaza el fragmento especificado con un nuevo tabla.
Ejemplo
// 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:
<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
Componente: wd290mdl.dll
Versión mínima requerida
  • Versión 22
Esta página también está disponible para…
Comentarios
using the DocInsertTable
1) you must add at least 2 lines in the docinserttable

DOC is document <- edt_doc // edt_doc is the document control

// inserts a document at position w 2 lines.
Frag is docFragment = DocInsertTable(doc,position,1,2)

now we look at the fragment for the lines we just added.. the table will usually NOT be in the first paragraph of the fragment so you must loop till you find it.

for each pTable of Frag..Paragraph
if pTable = Null then continue
for each string aString,tndx of arrString separated by CR
indx = add(ptable..table..Rows)
ptable..table..cells[indx,1)..content..text = aString
END
//remove the top 2 blank lines
delete(ptable..table..Rows,1)
delete(ptable..table..Rows,1)
//once 1st line deleted line 2 becomes line 1 so you delete again

Andy <<Cowboy>>Stapleton
andy@wxperts.com



Howard Stapleton
19 08 2019

Última modificación: 07/04/2023

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