beautypg.com

Merge table rows – Kofax DOKuStar Validation User Manual

Page 106

background image

DOKuStar Validation for Ascent Capture

Page

102

Merge Table Rows

The following example merges two table rows into one. The corresponding columns will be connected by adding the
second cell’s value to the first one (strings put together separated by comma). The zone of the new cell will be the
surrounding rectangle of the individual zones.

It is assumed that the table field has three columns named

Description

,

SinglePrice

and

TotalPrice

. Whenever there is a table row that has only the

Description

filled, it shall be merged with the

preceding one.

For shortness, this example does not care about the cell’s state. Also, it is assumed that the first row always is a “full”
row.

Option Explicit

Dim WithEvents dat As Data

Private Sub Application_OnProjectLoaded(ByVal App As Application)
Set dat = App.Project.DataSet.Data
End Sub

Private Sub dat_OnPostImported(ByVal Data As Data)
Dim doc As Document
Dim table As TableField
Dim row As TableRow
Dim savedRow As TableRow '* saved full row

'* cycle through the documents and merge table rows
For Each doc In Data.Documents
Set table = doc.Fields("Table") '* get the table field
For Each row In table.Rows
If IsDescriptionRow(row) Then '* it is a description now
mergeRows savedRow, row
Else '* it is a full row
Set savedRow = row
End If
Next row
Next doc
End Sub

Private Function IsDescriptionRow(row As TableRow) As Boolean
IsDescriptionRow = False

If row("SinglePrice").Value = "" And row("TotalPrice").Value = "" And _
row("Description").Value <> "" Then
IsDescriptionRow = True
End If
End Function

Private Sub mergeRows(firstRow As TableRow, secondRow As TableRow)
Dim cell As Field
Dim cellSecond As Field

'* cycle through the cells from the first
For Each cell In firstRow
Set cellSecond = secondRow(cell.Name) '* get the corresponding cell from
second row
cell.Value = cell.Value & "," & cellSecond.Value '* merge values
mergeZones cell, cellSecond
Next cell
secondRow.Remove
End Sub