My routine to isolate the fields works. The field names returned from the database match ones in the doc but when I use the inserthyperlink method it moves to a random location in the doc and then inserts this:
HYPERLINK \l "http://www.aspose.com"
Which is obviously not a working link. And then the text appears in another random location. Regardless the links don’t work. What is the fix?
My insert method:
Public Sub InsertHyperlink(ByVal id_sales As String, ByVal sproc As String, ByVal doc As Document, ByVal builder As DocumentBuilder)
Dim sField As String, sValue As String, sType As String
Dim dt As DataTable = Nothing
'builder.PushFont()
'builder.Font.Color = Color.Blue
'builder.Font.Underline = Underline.Single
'builder.Font.UnderlineColor = Color.Blue
Try
Using myConnection As New SqlConnection(ConfigurationManager.ConnectionStrings("cnn_BC").ConnectionString)
Dim myCommand As New SqlCommand(sproc, myConnection)
myCommand.CommandType = CommandType.StoredProcedure
myCommand.Parameters.Add(New SqlParameter("@ID", SqlDbType.Int))
myCommand.Parameters("@ID").Value = CInt(id_sales)
myConnection.Open()
myCommand.ExecuteNonQuery()
Dim r As SqlDataReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection)
Do While r.Read
For i As Integer = 0 To r.FieldCount
Try
sField = r.GetName(i).ToString
sValue = r.GetValue(i).ToString.Trim
sType = r.GetFieldType(i).ToString
builder.MoveToMergeField(sField)
’ Specify font formatting for the hyperlink.
builder.Font.Color = Color.Blue
builder.Font.Underline = Underline.Single
’ Insert the link.
builder.InsertHyperlink("Aspose Website", "<http://www.aspose.com>", True)
’ Revert to default formatting.
builder.Font.ClearFormatting()
Catch ex As Exception
'expected
End Try
Next
Loop
r.Close()
myConnection.Close()
End Using
Catch myException As Exception
End Try
End Sub