Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Mon Jun 08, 2015 2:37 pm

Hello everyone,

i need some help in this issue:
i save to sql data base the text from editor ajaxcontrol. the users insert some text and when i select the data table return something like this:
<table> <tbody> <tr> <td> <p>Proposta</p></td> <td> <p>2015_DRC_NOR_000098_S01</p></td></tr> <tr> <td> <p style="font-weight: bold">Montante da Proposta</p></td> <td> <p>14384,86 €</p></td></tr> <tr> <td> <p style="font-weight: bold">Prazo</p></td> <td> <p>33</p></td></tr> <tr> <td> <p style="font-weight: bold">Nº de prestações</p></td> <td> <p>33</p></td></tr> <tr> <td> <p style="font-weight: bold">Periodicidade</p></td> <td> <p>Mensal</p></td></tr> <tr> <td> <p style="font-weight: bold">Prazo de carência de capital</p></td> <td> <p>0</p></td></tr> <tr> <td> <p style="font-weight: bold">Carência de Juros</p></td> <td> <p>Sem carência</p></td></tr> <tr> <td> <p style="font-weight: bold">Taxa de juro pré-acordo</p></td> <td> <p>7,050 %</p></td></tr> <tr> <td> <p style="font-weight: bold">Taxa de juro acordo</p></td> <td> <p>7,050 %</p></td></tr> <tr> <td> <p style="font-weight: bold">Outras condições</p></td> <td> <p>Reforço de garantias</p> <p>Pagamento prévio das FT vencidas</p> <p>Execução do penhor de ações</p></td></tr></tbody></table>

I need to put this text (table html) in the middle of the template but when i test your example, it only put it on the end of the document.

Code: Select all
   Dim ptpclass As PTP = New PTP
            Dim DS As DataTable = New DataTable
            DS = ptpclass.ListarPTP(codigo).Tables(0)

            Dim document As New Document("S:\Projectos\DRC\Templates\Summary_of_Science.doc")

            'document.Replace("science", tempDoc, false, true);
            Dim replacement As IList(Of Paragraph) = New List(Of Paragraph)()
            'Dim p1 As New Paragraph(document)
            'p1.AppendText(DS.Rows(0)(1).ToString)
            'Dim p2 As New Paragraph(document)
            'p2.AppendText(DS.Rows(0)(2).ToString)
            'Dim p3 As New Paragraph(document)
            'p3.AppendText(DS.Rows(0)(3).ToString)
            'replacement.Add(p1)
            'replacement.Add(p2)
            'replacement.Add(p3)

            'the html represents two paragraphs, we create a temp section to contains them
            'Dim tempSection As Section = document.AddSection()
            'Dim p4 As Paragraph = tempSection.AddParagraph()
            'p4.AppendHTML("<p style='text-align: Right'><span style='background-color: yellow'><i><b>here is the topic text for Governing Body Oversight</b></i></span></p><p style='text-align: left'><span style='background-color: yellow'><i><b>&nbsp;&nbsp;&nbsp; fdsafds</b></i></span></p>")
            'For Each tempP In tempSection.Paragraphs
            '    replacement.Add(tempP)
            'Next

            Dim tempSection1 As Section = document.AddSection()
            Dim p41 As Paragraph = tempSection1.AddParagraph()
            Dim z As String = DS.Rows(0)(5).ToString
            p41.AppendHTML(z)
            For Each tempP In tempSection1.Paragraphs
                replacement.Add(tempP)
            Next



            Dim selections As TextSelection() = document.FindAllString("Situacao", False, True)
            Dim locations As New List(Of TextRangeLocation)()
            For Each selection As TextSelection In selections
                locations.Add(New TextRangeLocation(selection.GetAsOneRange()))
            Next
            locations.Sort()
            For Each location As TextRangeLocation In locations
                Replace(location, replacement)
            Next


note: it isn't necessary the while because i only need to replace 1 string.

i have tryed with bookmark and the problem is the same.

could you help me?
Thank you very mush

digeral
 
Posts: 2
Joined: Mon Jun 08, 2015 2:15 pm

Tue Jun 09, 2015 9:09 am

Hello,

Thanks for your inquiry.
Please provide your template file and point out which text you want to replace with the table html, and we will provide you the corresponding method. You can also send it to us( support@e-iceblue) via email.

Thanks,
Betsy
E-iceblue support team
User avatar

Betsy
 
Posts: 802
Joined: Mon Jan 19, 2015 6:14 am

Tue Jun 09, 2015 1:51 pm

Hello Betsy,

i send you a email.
thank you,
Best Regards

digeral
 
Posts: 2
Joined: Mon Jun 08, 2015 2:15 pm

Return to Spire.Doc