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 Jul 10, 2017 6:44 am

I want to replace text in a word template with HTML. I know how to append HTML to last paragraph but this paragraph is in the middle of word document.

shruti1009
 
Posts: 4
Joined: Mon Jul 10, 2017 6:42 am

Mon Jul 10, 2017 7:04 am

Dear shruti1009,

Thanks for your inquiry. Here is a guide to replace text with HTML.
https://www.e-iceblue.com/Tutorials/Spi ... -HTML.html
Hope this helps. If you still have the issue, please provide us with the input file and the HTML, then we will provide corresponding code for you.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Mon Jul 10, 2017 7:53 am

No this is not helpful for me. I have one word doc file in which i have placed one word eg. {{{wordToReplace}}} and i want to replace this place holder to HTML content. I need this code in c#. I have a licensed version of spire doc. Please help me out.

shruti1009
 
Posts: 4
Joined: Mon Jul 10, 2017 6:42 am

Mon Jul 10, 2017 8:24 am

Dear shruti1009,

Thanks for your response.
Here is C# code for your kind reference.
Code: Select all
      Document document = new Document(@"F:\sample.docx");
      List<Paragraph> replacement = new List<Paragraph>();

      //create a temp section to contains HTML
      Section tempSection = document.AddSection();
      Paragraph p4 = tempSection.AddParagraph();
      p4.AppendHTML("your HTML");
      foreach (var par in tempSection.Paragraphs)
      {
            Paragraph para = par as Paragraph;
            replacement.Add(para);
      }

      TextSelection[] selections = document.FindAllString("{{{wordToReplace}}}", false, true);
      List<TextRangeLocation> locations = new List<TextRangeLocation>();
      foreach (TextSelection selection in selections)
      {
         locations.Add(new TextRangeLocation(selection.GetAsOneRange()));
      }
      locations.Sort();
      foreach (TextRangeLocation location in locations)
      {
         Replace(location, replacement);
      }

      //remove the temp section
      document.Sections.Remove(tempSection);

      document.SaveToFile("11052.docx",FileFormat.Docx);
   }

        private static void Replace(TextRangeLocation location, IList<Paragraph> replacement)
        {
            //will be replaced
            TextRange textRange = location.Text;

            //textRange index
            int index = location.Index;

            //owener paragraph
            Paragraph paragraph = location.Owner;

            //owner text body
            Body sectionBody = paragraph.OwnerTextBody;

            //get the index of paragraph in section
            int paragraphIndex = sectionBody.ChildObjects.IndexOf(paragraph);
            int replacementIndex = -1;
            if (index == 0)
            {
                //remove
                paragraph.ChildObjects.RemoveAt(0);

                replacementIndex = sectionBody.ChildObjects.IndexOf(paragraph);
            }
            else if (index == paragraph.ChildObjects.Count - 1)
            {
                paragraph.ChildObjects.RemoveAt(index);
                replacementIndex = paragraphIndex + 1;
            }
            else
            {
                //split owner paragraph
                Paragraph paragraph1 = (Paragraph)paragraph.Clone();
                while (paragraph.ChildObjects.Count > index)
                {
                    paragraph.ChildObjects.RemoveAt(index);
                }
                int i = 0;
                int count = index + 1;
                while (i < count)
                {
                    paragraph1.ChildObjects.RemoveAt(0);
                    i += 1;
                }
                sectionBody.ChildObjects.Insert(paragraphIndex + 1, paragraph1);

                replacementIndex = paragraphIndex + 1;
            }
            //insert replacement
            for (int i = 0; i <= replacement.Count - 1; i++)
            {
                sectionBody.ChildObjects.Insert(replacementIndex + i, replacement[i].Clone());
            }
        }
        public class TextRangeLocation : IComparable<TextRangeLocation>
        {
            public TextRangeLocation(TextRange text)
            {
                this.Text = text;
            }
            public TextRange Text
            {
                get { return m_Text; }
                set { m_Text = value; }
            }
            private TextRange m_Text;
            public Paragraph Owner
            {
                get { return this.Text.OwnerParagraph; }
            }
            public int Index
            {
                get { return this.Owner.ChildObjects.IndexOf(this.Text); }
            }
            public int CompareTo(TextRangeLocation other)
            {
                return -(this.Index - other.Index);
            }
        }

If there is still issue, please provide us with the input file and the HTML for testing.

Thanks,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Mon Jul 10, 2017 10:56 am

Thanks for ur reply. Your code helped me partially. Its working for all Html elements except <table> tag.
Rest all code is working for me. if i add simple html code in p4.AppendHTML("<b>hello world</b>"). It shows me correct Html format. but if i add my html content as
Code: Select all
<table class='widthStyle' style='width:100%;'><tbody><tr><td style='vertical-align: top;'><ul><li>Boat Cover</li><li>Propeller</li><li>Bilge Pump</li><li>Inboard Motors</li></ul></td><td style='vertical-align: top;'><ul style='vertical-align:top;'><li>Canvas Top</li><li>Step Wedges</li><li>Dock Ties</li></ul></td><td style='vertical-align: top;'><ul><li>Fire Extinguisher</li><li>Reboarding Step</li><li>Jet Ski Cover</li></ul></td></tr></tbody></table>

its not working. Is there any problem with <table> tag.
Thank you.

shruti1009
 
Posts: 4
Joined: Mon Jul 10, 2017 6:42 am

Tue Jul 11, 2017 2:12 am

Dear shruti1009,

Thanks for your response.
If there is also HTML table, please change the List<Paragraph> to List<DocumentObject>, and adjust the corresponding code.
Whole code for your kind reference.
Code: Select all
            Document document = new Document(@"F:\sample.docx");
            //collect document object, it could get paragraph, table and so on.
            List<DocumentObject> replacement = new List<DocumentObject>();

            Section tempSection = document.AddSection();
            Paragraph p4 = tempSection.AddParagraph();
            p4.AppendHTML("your HTML");

            foreach (var obj in tempSection.Body.ChildObjects)
            {
                DocumentObject O = obj as DocumentObject;
                replacement.Add(O);
            }

            TextSelection[] selections = document.FindAllString("{{{wordToReplace}}}", false, true);
            List<TextRangeLocation> locations = new List<TextRangeLocation>();
            foreach (TextSelection selection in selections)
            {
                locations.Add(new TextRangeLocation(selection.GetAsOneRange()));
            }
            locations.Sort();
            foreach (TextRangeLocation location in locations)
            {
                ReplaceObj(location, replacement);
            }
            //remove the temp section
            document.Sections.Remove(tempSection);
            document.SaveToFile("11052-table.docx", FileFormat.Docx);
        }
        private static void ReplaceObj(TextRangeLocation location, List<DocumentObject> replacement)
        {
            //will be replaced
            TextRange textRange = location.Text;

            //textRange index
            int index = location.Index;

            //owener paragraph
            Paragraph paragraph = location.Owner;

            //owner text body
            Body sectionBody = paragraph.OwnerTextBody;

            //get the index of paragraph in section
            int paragraphIndex = sectionBody.ChildObjects.IndexOf(paragraph);

            int replacementIndex = -1;
            if (index == 0)
            {
                //remove
                paragraph.ChildObjects.RemoveAt(0);

                replacementIndex = sectionBody.ChildObjects.IndexOf(paragraph);
            }
            else if (index == paragraph.ChildObjects.Count - 1)
            {
                paragraph.ChildObjects.RemoveAt(index);
                replacementIndex = paragraphIndex + 1;

            }
            else
            {
                //split owner paragraph
                Paragraph paragraph1 = (Paragraph)paragraph.Clone();
                while (paragraph.ChildObjects.Count > index)
                {
                    paragraph.ChildObjects.RemoveAt(index);
                }
                int i = 0;
                int count = index + 1;
                while (i < count)
                {
                    paragraph1.ChildObjects.RemoveAt(0);
                    i += 1;
                }
                sectionBody.ChildObjects.Insert(paragraphIndex + 1, paragraph1);

                replacementIndex = paragraphIndex + 1;
            }

            //insert replacement
            for (int i = 0; i <= replacement.Count - 1; i++)
            {
                sectionBody.ChildObjects.Insert(replacementIndex + i, replacement[i].Clone());
            }
        }       
       public class TextRangeLocation : IComparable<TextRangeLocation>
        {
            public TextRangeLocation(TextRange text)
            {
                this.Text = text;
            }
            public TextRange Text
            {
                get { return m_Text; }
                set { m_Text = value; }
            }
            private TextRange m_Text;
            public Paragraph Owner
            {
                get { return this.Text.OwnerParagraph; }
            }
            public int Index
            {
                get { return this.Owner.ChildObjects.IndexOf(this.Text); }
            }
            public int CompareTo(TextRangeLocation other)
            {
                return -(this.Index - other.Index);
            }
        }

If there is any question, please let me know.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Tue Jul 11, 2017 6:00 am

Dear Betsy,
Thanks for your reply. It worked for me. It helped me alottt. Thanks to you for giving reply on time. :D

shruti1009
 
Posts: 4
Joined: Mon Jul 10, 2017 6:42 am

Tue Jul 11, 2017 6:04 am

Dear shruti1009,

Thanks for your feedback.
Please feel free to contact us if there is any question :) .

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Mon Dec 21, 2020 7:17 am

Hello E-iceblue support team,
I face an issue with display html. when i replace text by html from word tempate, the content with the table does not show in the .pdf output file, bellow is my code and html .
Please help.
Thanks.
Code: Select all
    public class SpireHelper
    {
        public static Document ReplaceTextWithHtml(Document document, string wordToReplace, string html)
        {

            List<Paragraph> replacement = new List<Paragraph>();

            //create a temp section to contains HTML
            Section tempSection = document.AddSection();
            Paragraph p4 = tempSection.AddParagraph();
           
            p4.AppendHTML(html);
            foreach (var par in tempSection.Paragraphs)
            {
                Paragraph para = par as Paragraph;
                replacement.Add(para);
            }

            TextSelection[] selections = document.FindAllString("[" + wordToReplace + "]", false, true);
            List<TextRangeLocation> locations = new List<TextRangeLocation>();
            foreach (TextSelection selection in selections)
            {
                locations.Add(new TextRangeLocation(selection.GetAsOneRange()));
            }
            locations.Sort();
            foreach (TextRangeLocation location in locations)
            {
                Replace(location, replacement);
            }

            //remove the temp section
            document.Sections.Remove(tempSection);

            return document;
        }
        private static void Replace(TextRangeLocation location, IList<Paragraph> replacement)
        {
            //will be replaced
            TextRange textRange = location.Text;

            //textRange index
            int index = location.Index;

            //owener paragraph
            Paragraph paragraph = location.Owner;

            //owner text body
            Body sectionBody = paragraph.OwnerTextBody;

            //get the index of paragraph in section
            int paragraphIndex = sectionBody.ChildObjects.IndexOf(paragraph);
            int replacementIndex = -1;
            if (index == 0)
            {
                //remove
                paragraph.ChildObjects.RemoveAt(0);

                replacementIndex = sectionBody.ChildObjects.IndexOf(paragraph);
            }
            else if (index == paragraph.ChildObjects.Count - 1)
            {
                paragraph.ChildObjects.RemoveAt(index);
                replacementIndex = paragraphIndex + 1;
            }
            else
            {
                //split owner paragraph
                Paragraph paragraph1 = (Paragraph)paragraph.Clone();
                while (paragraph.ChildObjects.Count > index)
                {
                    paragraph.ChildObjects.RemoveAt(index);
                }
                int i = 0;
                int count = index + 1;
                while (i < count)
                {
                    paragraph1.ChildObjects.RemoveAt(0);
                    i += 1;
                }
                sectionBody.ChildObjects.Insert(paragraphIndex + 1, paragraph1);

                replacementIndex = paragraphIndex + 1;
            }
            //insert replacement
            for (int i = 0; i <= replacement.Count - 1; i++)
            {
                sectionBody.ChildObjects.Insert(replacementIndex + i, replacement[i].Clone());
            }
        }
    }
    public class TextRangeLocation : IComparable<TextRangeLocation>
    {
        public TextRangeLocation(TextRange text)
        {
            this.Text = text;
        }
        public TextRange Text
        {
            get { return m_Text; }
            set { m_Text = value; }
        }
        private TextRange m_Text;
        public Paragraph Owner
        {
            get { return this.Text.OwnerParagraph; }
        }
        public int Index
        {
            get { return this.Owner.ChildObjects.IndexOf(this.Text); }
        }
        public int CompareTo(TextRangeLocation other)
        {
            return -(this.Index - other.Index);
        }
    }

//Html
<div class="ExternalClass6EC8314D7A06441DA9D40EEE1F113548">
   <p style="margin-left: 0in; margin-right: 0in;">
      <span style="font-size: 14px;">
         <span style="font-family: &quot;times new roman&quot;, times, serif;">
            <strong>
               <u>Kính gửi:</u> &#160;&#160;&#160;&#160;&#160;&#160;&#160; - &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; BAN LÃNH ĐẠO </strong></span></span></p>
   <ul>
      <li style="text-align: justify;">
         <span style="font-size: 14px;">
            <span style="font-family: &quot;times new roman&quot;, times, serif;">
               <em>We often come across a scenario where we need to merge data to the merge fields which are created by some others<br/></em></span></span></li>
      <li style="text-align: justify;">
         <span style="font-size: 14px;">
            <span style="font-family: &quot;times new roman&quot;, times, serif;">
               <em>The MailMerge class in Spire.Doc.Reporting namespace exposes the following methods which return a collection of merge field names or group (region) names in a word document<br/></em></span></span></li>
   </ul>
   <p style="margin-left: 4.5pt; margin-right: 0in; text-align: justify;">
      <span style="font-size: 14px;">
         <span style="font-family: &quot;times new roman&quot;, times, serif;"></span></span></p>
   <p style="margin-left: 4.5pt; margin-right: 0in; text-align: justify;">
      <span style="font-size: 14px;">
         <span style="font-family: &quot;times new roman&quot;, times, serif;">We often come across a scenario where we need to merge data to the merge fields which are created by some others, and we are not sure about the merge fields’ names. So in order to accomplish the mail merge purpose, first we need to read the names of all the merge fields<br/> </span></span></p>
   <p style="margin-left: 4.5pt; margin-right: 0in; text-align: justify;">
      <span style="font-size: 14px;">
         <span style="font-family: &quot;times new roman&quot;, times, serif;"></span></span></p>
   <table align="center" border="1" cellspacing="0" class="Table" style="border-collapse: collapse; border: 1pt solid windowtext; width: 475.4pt;">
      <tbody>
         <tr>
            <td style="height: 23.3pt; width: 50.6pt;">
               <p style="margin-left: 0in; margin-right: 0in; text-align: center;">Num<br/></p>
            </td>
            <td style="height: 23.3pt; width: 76.3pt;">
               <p style="margin-left: 0in; margin-right: 0in; text-align: center;">
                  <span style="font-size: 14px;">
                     <span style="font-family: &quot;times new roman&quot;, times, serif;">
                        <strong>
                           <span style="color: black;">Name</span></strong></span></span></p>
            </td>
            <td style="height: 23.3pt; width: 78.75pt;">
               <p style="margin-left: 0in; margin-right: 0in; text-align: center;">
                  <span style="font-size: 14px;">
                     <span style="font-family: &quot;times new roman&quot;, times, serif;">
                        <strong>
                           <span style="color: black;">No.</span></strong></span></span></p>
            </td>
            <td style="height: 23.3pt; width: 68.45pt;">
               <p style="margin-left: 0in; margin-right: 0in; text-align: center;">
                  <span style="font-size: 14px;">
                     <span style="font-family: &quot;times new roman&quot;, times, serif;">
                        <strong>
                           <span style="color: black;">Amount</span></strong></span></span></p>
            </td>
            <td style="height: 23.3pt; width: 91.6pt;">
               <p style="margin-left: 0in; margin-right: 0in; text-align: center;">
                  <span style="font-size: 14px;">
                     <span style="font-family: &quot;times new roman&quot;, times, serif;">
                        <strong>
                           <span style="color: black;">UP</span></strong></span></span></p>
            </td>
            <td style="height: 23.3pt; width: 109.7pt;">
               <p style="margin-left: 0in; margin-right: 0in; text-align: center;">
                  <span style="font-size: 14px;">
                     <span style="font-family: &quot;times new roman&quot;, times, serif;">
                        <strong>
                           <span style="color: black;">Total</span></strong></span></span></p>
            </td>
         </tr>
         <tr>
            <td style="height: 15.4pt; width: 50.6pt;">
               <p style="margin-left: 0in; margin-right: 0in; text-align: center;">
                  <span style="font-size: 14px;">
                     <span style="font-family: &quot;times new roman&quot;, times, serif;">
                        <span style="color: black;">1</span></span></span></p>
            </td>
            <td style="height: 15.4pt; width: 76.3pt;">
               <p style="margin-left: 0in; margin-right: 0in; text-align: center;">
                  <span style="font-size: 14px;">
                     <span style="font-family: &quot;times new roman&quot;, times, serif;">
                        <span style="color: black;">Đường thô</span></span></span></p>
            </td>
            <td style="height: 15.4pt; width: 78.75pt;">
               <p style="margin-left: 0in; margin-right: 0in; text-align: center;">
                  <span style="font-size: 14px;">
                     <span style="font-family: &quot;times new roman&quot;, times, serif;">
                        <span style="color: black;">120015A, 120017A</span></span></span></p>
            </td>
            <td style="height: 15.4pt; width: 68.45pt;">
               <p style="margin-left: 0in; margin-right: 0in; text-align: center;">
                  <span style="font-size: 14px;">
                     <span style="font-family: &quot;times new roman&quot;, times, serif;">
                        <span style="color: black;">22,500</span></span></span></p>
            </td>
            <td style="height: 15.4pt; width: 91.6pt;">
               <p style="margin-left: 0in; margin-right: 0in; text-align: center;">
                  <span style="font-size: 14px;">
                     <span style="font-family: &quot;times new roman&quot;, times, serif;">
                        <span style="color: black;">403.98</span></span></span></p>
            </td>
            <td style="height: 15.4pt; width: 109.7pt;">
               <p style="margin-left: 0in; margin-right: 0in; text-align: center;">
                  <span style="font-size: 14px;">
                     <span style="font-family: &quot;times new roman&quot;, times, serif;">
                        <span style="color: black;">1,711,800</span></span></span></p>
            </td>
         </tr>
         <tr>
            <td style="height: 16.95pt; width: 50.6pt;">
               <span style="font-size: 14px;">
                  <span style="font-family: &quot;times new roman&quot;, times, serif;"></span></span></td>
            <td style="height: 16.95pt; width: 76.3pt;">
               <span style="font-size: 14px;">
                  <span style="font-family: &quot;times new roman&quot;, times, serif;"></span></span></td>
            <td style="height: 16.95pt; width: 78.75pt;">
               <p style="margin-left: 0in; margin-right: 0in; text-align: center;">
                  <span style="font-size: 14px;">
                     <span style="font-family: &quot;times new roman&quot;, times, serif;">
                        <span style="color: black;"></span></span></span></p>
            </td>
            <td style="height: 16.95pt; width: 68.45pt;">
               <p style="margin-left: 0in; margin-right: 0in; text-align: center;">
                  <span style="font-size: 14px;">
                     <span style="font-family: &quot;times new roman&quot;, times, serif;">
                        <span style="color: black;"></span></span></span></p>
            </td>
            <td style="height: 16.95pt; width: 91.6pt;">
               <p style="margin-left: 0in; margin-right: 0in; text-align: center;">
                  <span style="font-size: 14px;">
                     <span style="font-family: &quot;times new roman&quot;, times, serif;">
                        <strong>
                           <span style="color: black;">TỔNG CỘNG</span></strong></span></span></p>
            </td>
            <td style="height: 16.95pt; width: 109.7pt;">
               <p style="margin-left: 0in; margin-right: 0in; text-align: center;">
                  <span style="font-size: 14px;">
                     <span style="font-family: &quot;times new roman&quot;, times, serif;">
                        <strong>
                           <span style="color: black;">1,711,800</span><span style="color: black;"></span></strong></span></span></p>
            </td>
         </tr>
      </tbody>
   </table>
   <p style="margin-left: 0in; margin-right: 0in; text-align: justify;">
      <span style="font-size: 14px;">
         <span style="font-family: &quot;times new roman&quot;, times, serif;"></span></span></p>
   <p style="margin-left: 0in; margin-right: 0in; text-align: justify;">
      <span style="font-size: 14px;">
         <span style="font-family: &quot;times new roman&quot;, times, serif;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Kính trình Ban lãnh đạo thuận duyệt chi phí trên để P. KDQT triển khai thực hiện đảm bảo đúng lịch nhập hàng.</span></span></p>
   <p style="margin-left: 0in; margin-right: 0in; text-align: justify;">
      <span style="font-size: 14px;">
         <span style="font-family: &quot;times new roman&quot;, times, serif;"></span></span></p>
   <p style="margin-left: 0in; margin-right: 0in; text-align: justify;">
      <span style="font-size: 14px;">
         <span style="font-family: &quot;times new roman&quot;, times, serif;">&#160;&#160; Trân trọng kính trình./</span></span></p>
</div>
<br/>


thienthaiho
 
Posts: 3
Joined: Tue Apr 28, 2020 6:44 am

Mon Dec 21, 2020 10:10 am

Hello,

Thanks for your inquiry.
There is an easier way to achieve your requirement, below is the corresponding code for your reference. Feel free to contact us if you have further questions.
Code: Select all
            Document doc = new Document("test.docx");
            string str = "good";
            string html = "your html";


            Document docHtml = new Document();
            docHtml.AddSection().AddParagraph().AppendHTML(html);
            IDocument replaceDoc = docHtml as IDocument;
            doc.Replace(str, replaceDoc, false, true);
            doc.SaveToFile("result.pdf", FileFormat.PDF);


Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Mon Dec 21, 2020 3:15 pm

Dear Brian,

Thanks for your feedback,
but the table in the code secment below cannot display in .pdf result file.

Code: Select all
<div class="ExternalClass6EC8314D7A06441DA9D40EEE1F113548">
   <p style="margin-left: 0in; margin-right: 0in;">
      <span style="font-size: 14px;">
         <span style="font-family: &quot;times new roman&quot;, times, serif;">
            <strong>
               <u>Kính gửi:</u> &#160;&#160;&#160;&#160;&#160;&#160;&#160; - &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; BAN LÃNH ĐẠO </strong></span></span></p>
   <ul>
      <li style="text-align: justify;">
         <span style="font-size: 14px;">
            <span style="font-family: &quot;times new roman&quot;, times, serif;">
               <em>We often come across a scenario where we need to merge data to the merge fields which are created by some others<br/></em></span></span></li>
      <li style="text-align: justify;">
         <span style="font-size: 14px;">
            <span style="font-family: &quot;times new roman&quot;, times, serif;">
               <em>The MailMerge class in Spire.Doc.Reporting namespace exposes the following methods which return a collection of merge field names or group (region) names in a word document<br/></em></span></span></li>
   </ul>
   <p style="margin-left: 4.5pt; margin-right: 0in; text-align: justify;">
      <span style="font-size: 14px;">
         <span style="font-family: &quot;times new roman&quot;, times, serif;"></span></span></p>
   <p style="margin-left: 4.5pt; margin-right: 0in; text-align: justify;">
      <span style="font-size: 14px;">
         <span style="font-family: &quot;times new roman&quot;, times, serif;">We often come across a scenario where we need to merge data to the merge fields which are created by some others, and we are not sure about the merge fields’ names. So in order to accomplish the mail merge purpose, first we need to read the names of all the merge fields<br/> </span></span></p>
   <p style="margin-left: 4.5pt; margin-right: 0in; text-align: justify;">
      <span style="font-size: 14px;">
         <span style="font-family: &quot;times new roman&quot;, times, serif;"></span></span></p>
   <table align="center" border="1" cellspacing="0" class="Table" style="border-collapse: collapse; border: 1pt solid windowtext; width: 475.4pt;">
      <tbody>
         <tr>
            <td style="height: 23.3pt; width: 50.6pt;">
               <p style="margin-left: 0in; margin-right: 0in; text-align: center;">Num<br/></p>
            </td>
            <td style="height: 23.3pt; width: 76.3pt;">
               <p style="margin-left: 0in; margin-right: 0in; text-align: center;">
                  <span style="font-size: 14px;">
                     <span style="font-family: &quot;times new roman&quot;, times, serif;">
                        <strong>
                           <span style="color: black;">Name</span></strong></span></span></p>
            </td>
            <td style="height: 23.3pt; width: 78.75pt;">
               <p style="margin-left: 0in; margin-right: 0in; text-align: center;">
                  <span style="font-size: 14px;">
                     <span style="font-family: &quot;times new roman&quot;, times, serif;">
                        <strong>
                           <span style="color: black;">No.</span></strong></span></span></p>
            </td>
            <td style="height: 23.3pt; width: 68.45pt;">
               <p style="margin-left: 0in; margin-right: 0in; text-align: center;">
                  <span style="font-size: 14px;">
                     <span style="font-family: &quot;times new roman&quot;, times, serif;">
                        <strong>
                           <span style="color: black;">Amount</span></strong></span></span></p>
            </td>
            <td style="height: 23.3pt; width: 91.6pt;">
               <p style="margin-left: 0in; margin-right: 0in; text-align: center;">
                  <span style="font-size: 14px;">
                     <span style="font-family: &quot;times new roman&quot;, times, serif;">
                        <strong>
                           <span style="color: black;">UP</span></strong></span></span></p>
            </td>
            <td style="height: 23.3pt; width: 109.7pt;">
               <p style="margin-left: 0in; margin-right: 0in; text-align: center;">
                  <span style="font-size: 14px;">
                     <span style="font-family: &quot;times new roman&quot;, times, serif;">
                        <strong>
                           <span style="color: black;">Total</span></strong></span></span></p>
            </td>
         </tr>
         <tr>
            <td style="height: 15.4pt; width: 50.6pt;">
               <p style="margin-left: 0in; margin-right: 0in; text-align: center;">
                  <span style="font-size: 14px;">
                     <span style="font-family: &quot;times new roman&quot;, times, serif;">
                        <span style="color: black;">1</span></span></span></p>
            </td>
            <td style="height: 15.4pt; width: 76.3pt;">
               <p style="margin-left: 0in; margin-right: 0in; text-align: center;">
                  <span style="font-size: 14px;">
                     <span style="font-family: &quot;times new roman&quot;, times, serif;">
                        <span style="color: black;">Đường thô</span></span></span></p>
            </td>
            <td style="height: 15.4pt; width: 78.75pt;">
               <p style="margin-left: 0in; margin-right: 0in; text-align: center;">
                  <span style="font-size: 14px;">
                     <span style="font-family: &quot;times new roman&quot;, times, serif;">
                        <span style="color: black;">120015A, 120017A</span></span></span></p>
            </td>
            <td style="height: 15.4pt; width: 68.45pt;">
               <p style="margin-left: 0in; margin-right: 0in; text-align: center;">
                  <span style="font-size: 14px;">
                     <span style="font-family: &quot;times new roman&quot;, times, serif;">
                        <span style="color: black;">22,500</span></span></span></p>
            </td>
            <td style="height: 15.4pt; width: 91.6pt;">
               <p style="margin-left: 0in; margin-right: 0in; text-align: center;">
                  <span style="font-size: 14px;">
                     <span style="font-family: &quot;times new roman&quot;, times, serif;">
                        <span style="color: black;">403.98</span></span></span></p>
            </td>
            <td style="height: 15.4pt; width: 109.7pt;">
               <p style="margin-left: 0in; margin-right: 0in; text-align: center;">
                  <span style="font-size: 14px;">
                     <span style="font-family: &quot;times new roman&quot;, times, serif;">
                        <span style="color: black;">1,711,800</span></span></span></p>
            </td>
         </tr>
         <tr>
            <td style="height: 16.95pt; width: 50.6pt;">
               <span style="font-size: 14px;">
                  <span style="font-family: &quot;times new roman&quot;, times, serif;"></span></span></td>
            <td style="height: 16.95pt; width: 76.3pt;">
               <span style="font-size: 14px;">
                  <span style="font-family: &quot;times new roman&quot;, times, serif;"></span></span></td>
            <td style="height: 16.95pt; width: 78.75pt;">
               <p style="margin-left: 0in; margin-right: 0in; text-align: center;">
                  <span style="font-size: 14px;">
                     <span style="font-family: &quot;times new roman&quot;, times, serif;">
                        <span style="color: black;"></span></span></span></p>
            </td>
            <td style="height: 16.95pt; width: 68.45pt;">
               <p style="margin-left: 0in; margin-right: 0in; text-align: center;">
                  <span style="font-size: 14px;">
                     <span style="font-family: &quot;times new roman&quot;, times, serif;">
                        <span style="color: black;"></span></span></span></p>
            </td>
            <td style="height: 16.95pt; width: 91.6pt;">
               <p style="margin-left: 0in; margin-right: 0in; text-align: center;">
                  <span style="font-size: 14px;">
                     <span style="font-family: &quot;times new roman&quot;, times, serif;">
                        <strong>
                           <span style="color: black;">TỔNG CỘNG</span></strong></span></span></p>
            </td>
            <td style="height: 16.95pt; width: 109.7pt;">
               <p style="margin-left: 0in; margin-right: 0in; text-align: center;">
                  <span style="font-size: 14px;">
                     <span style="font-family: &quot;times new roman&quot;, times, serif;">
                        <strong>
                           <span style="color: black;">1,711,800</span><span style="color: black;"></span></strong></span></span></p>
            </td>
         </tr>
      </tbody>
   </table>
   <p style="margin-left: 0in; margin-right: 0in; text-align: justify;">
      <span style="font-size: 14px;">
         <span style="font-family: &quot;times new roman&quot;, times, serif;"></span></span></p>
   <p style="margin-left: 0in; margin-right: 0in; text-align: justify;">
      <span style="font-size: 14px;">
         <span style="font-family: &quot;times new roman&quot;, times, serif;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Kính trình Ban lãnh đạo thuận duyệt chi phí trên để P. KDQT triển khai thực hiện đảm bảo đúng lịch nhập hàng.</span></span></p>
   <p style="margin-left: 0in; margin-right: 0in; text-align: justify;">
      <span style="font-size: 14px;">
         <span style="font-family: &quot;times new roman&quot;, times, serif;"></span></span></p>
   <p style="margin-left: 0in; margin-right: 0in; text-align: justify;">
      <span style="font-size: 14px;">
         <span style="font-family: &quot;times new roman&quot;, times, serif;">&#160;&#160; Trân trọng kính trình./</span></span></p>
</div>
<br/>

thienthaiho
 
Posts: 3
Joined: Tue Apr 28, 2020 6:44 am

Tue Dec 22, 2020 2:37 am

Hello,

Thanks for your feedback.
For your html string, the code I provided works fine on my side. Here I uploaded my test project, you can run it directly on your side.

If your project settings are a little different from mine, please provide a runnable project (including your input file) that could reproduce your issue to help us investigate further. You could send it to us (support@e-iceblue.com) via email.

Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Thu Dec 24, 2020 3:06 am

Hello Brian,

Thanks so much, it work for me.

thienthaiho
 
Posts: 3
Joined: Tue Apr 28, 2020 6:44 am

Thu Dec 24, 2020 7:42 am

You are welcome. If you have any other questions, please feel free to contact us.

Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Return to Spire.Doc

cron