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.

Wed Jul 24, 2019 2:43 am

Hi there, love your product but I'm fairly new to it. Having problems merging in some HTML to a word doc. I'm guessing it's something in the HTML string which is upsetting it, but struggling to find it. Throws NullReferenceException on the AppendHTML line, there is definately HTML string in the reader.
I';m using Spire.Doc 7.7 Any pointers? Thank you

Dim strSQL As String = "SELECT * FROM SCHEDULE where contract_id=58527"
Using c As SqlConnection = New SqlConnection(ConfigurationManager.ConnectionStrings("etb").ConnectionString)
c.Open()
Using Cmd As SqlCommand = New SqlCommand(strsql, c)
Using myreader As SqlDataReader = Cmd.ExecuteReader()
If myreader.HasRows Then
Dim dx As New Document()
dx.AddSection()
Dim p0 As Paragraph = dx.Sections(0).AddParagraph()

Do While myreader.Read()
p0.AppendBreak(BreakType.PageBreak)
If Not IsDBNull(myreader("BODY")) Then p0.AppendHTML(myreader("BODY"))
Loop
Using ms As IO.MemoryStream = New IO.MemoryStream()
dx.SaveToStream(ms, FileFormat.Docx)
Response.Clear()
Response.ContentType = "application/msword"
Response.AddHeader("Content-Disposition", "attachment; filename=myfile.docx")
Response.BinaryWrite(ms.ToArray())
End Using
Response.Flush()
Response.Close()
Response.End()

End If
End Using
End Using
End Using

dodgeyb
 
Posts: 2
Joined: Tue Jun 25, 2019 4:58 am

Wed Jul 24, 2019 3:37 am

Hello,

Thanks for your inquiry.
To help us investigate your issue accurately, please provide the content of your appended html string that causes the exception. You also could send it to us via email (support@e-iceblue.com). Thanks in advance.

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1261
Joined: Wed Apr 25, 2018 3:20 am

Sun Jul 28, 2019 10:54 pm

<div style="font-size: 12px !important;">
<p><span>1)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Date of this Employment Agreement:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 21 January 2019</span></p>
<p><span><br />
2)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Date of Physical Commencement of Work:&nbsp; &nbsp; &nbsp; 4 February 2019</span></p>
<p><span><br />
3)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Principal Work Location:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;AUCKLAND/NORTH&nbsp;SHORE<br />
<br />
<br />
4)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Brand Activator Number:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; XXX</span></p>
<p><span style="font-family: Arial;"><strong><span style="text-decoration: underline; color: black;">Remuneration Rates:&nbsp; </span></strong></span></p>
<p><span>Merchandising Rate:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$18.50 per hour<br />
<br />
Travel Rate</span></p>
<p><span>General Merchandising:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .48c after the first 15km travelled each day</span></p>
<p style="text-align: justify;"><span>Travel time can be claimed from 1<sup>st</sup>&nbsp;to last call for Red Bull/Pernod Ricard</span></p>
<p style="text-align: justify;"><span>Weekend Merchandising calls only</span></p>
<p style="text-align: justify;"><span>No&nbsp;other&nbsp;Travel Time is claimable, unless prior approval is given.</span></p>
<p style="text-align: justify;"><span style="font-family: Arial;"><strong><span style="text-decoration: underline; color: black;">Laminex Allowance</span></strong></span></p>
<p style="text-align: justify;"><span>Laminex Contribution of $150.00 per year towards Commercial Car Insurance &amp; storage of products.</span></p>
<p style="text-align: justify;"><span>This contribution will be paid to the employee after 3 months of employment with the Laminex account. However, if the employee resigns within the first 6 months of employment, this contribution will be deducted from any monies owing.</span></p>
<p style="text-align: justify;"><span style="font-family: Arial;"><strong><span style="text-decoration: underline; color: black;">Laminex Shirt</span></strong></span></p>
<p style="text-align: justify;"><span>You are required to wear your Hoop Polo or vest on all Laminex &nbsp;calls</span></p>
<p style="text-align: justify;"><span><br />
Expenses for reimbursement of personal phone usage if tablet is not in working order:</span></p>
<p><span>- Text:20c per text<br />
- Pixt: 50c per pixt<br />
<br />
<strong><span style="text-decoration: underline;">Rest &amp; Meal breaks:</span><em><br />
</em></strong><br />
<span style="text-decoration: underline;">Length of employee's work period with HOOP - </span><strong><span style="text-decoration: underline;">2.00 - 4.00 hours - </span><br />
</strong><br />
1 x 10 minute paid rest break<br />
<br />
<span style="text-decoration: underline;">Length of employee's work period with HOOP - <strong>4.01 - 6.00 hours -</strong></span> <br />
<br />
1 x 10 minute paid rest break, 1 x 30 minute&nbsp;unpaid meal break&nbsp;&nbsp;<br />
<br />
<span style="text-decoration: underline;">Length of employee's work period with HOOP - <strong>6.01 - 10.00 hours</strong> -</span><br />
<br />
1 x 10 minute paid rest break, 1 x 30 minute unpaid meal break,&nbsp; 1 x 10 minute paid rest break<br />
<br />
<span style="text-decoration: underline;">Length of employee's work period with HOOP 1<strong>0-01 - 12.00 hours</strong>&nbsp;-&nbsp;</span><br />
<br />
1 x 10 minute paid rest break, 1 x 30 minute unpaid meal break,&nbsp;1 x 10 minute paid rest break, 1 x 10 minute paid rest break,<br />
<br />
<span style="text-decoration: underline;">Length of employee's work period with HOOP <strong>12.01 - 14.00 hou</strong>rs -</span><br />
<br />
1 x 10 minute paid rest break, First 30 minute unpaid meal break,&nbsp;1&nbsp;x 10 minute paid rest break,&nbsp;1 x 10 minute paid rest break,&nbsp;Second 30 minute unpaid meal break<br />
</span></p>
<p><span style="background: none 0% 0% repeat scroll white; font-family: Arial; color: black;"><span style="text-decoration: underline;"><strong>Bi-monthly Payments Provisions: </strong></span><br />
<br />
2 payments in arrears on 6<sup>th</sup>&nbsp;and 23<sup>rd</sup>&nbsp;of each Month calculations as per Schedule 5</span></p>
<p><span>Notice Period for Employee taking Annual Leave:&nbsp;</span></p>
<p><span>- 4 weeks for leave duration of 2 weeks or less and&nbsp;<br />
- 12 weeks&rsquo; notice for any leave in excess of 2 weeks<br />
<br />
Contact Details of Person for Sick and Bereavement Leave:&nbsp;XXXXXXXXX</span></p>
<p><span style="font-family: Arial;"><strong><span style="text-decoration: underline; color: black;">Probationary Period:</span></strong><strong><span style="color: black;"><br />
</span></strong><span style="color: black;"><br />
Review Cycle: 4th week, 8th week, 12 week.<br />
<br />
Notice period for termination during the Probationary Period: 2 weeks</span></span></p>
<p><span style="text-decoration: underline; font-family: Arial; color: black;"><strong>Termination of Employment:</strong></span></p>
<p><span>Termination Notice Period: 2 weeks</span><span>
<br />
<br />
Resignation Notice Period: 4 weeks<br />
<br />
Redundancy Notice Period: 4 weeks</span></p>
<p><span style="font-family: Arial;"><strong><span style="text-decoration: underline; color: black;">Reporting:</span></strong><span style="color: black;"><br />
<br />
Calls are to be entered on online: Daily on completion of each call<br />
Monthly Expense report received and calls entered online: Before monthly deadline as recorded on expense report each month<br />
<strong><br />
<span style="text-decoration: underline;">Cancellation of Work:</span></strong></span></span></p>
<p><span>Cancellation Notice Period: 48 hours<br />
Compensation in Lieu of Cancellation of Notice Period:<br />
<br />
&bull;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If not given notice before 48 hours = 25% of pay<br />
&bull;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If not given notice before 24 hours = 50% of pay<br />
&bull;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If not given notice before 12 hours = 75% of pay</span></p>
</div>

dodgeyb
 
Posts: 2
Joined: Tue Jun 25, 2019 4:58 am

Mon Jul 29, 2019 6:36 am

Hello,

Thanks for your feedback.
After testing with your html code, I didn't encounter the exception. Here, I uploaded my simple testing Demo for your reference. Please run it on your side, if your issue still occurs, please share us with your system information (E.g. Windows 7, 64 bit) and region setting (E.g. China, Chinese) to help further look into your issue.

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1261
Joined: Wed Apr 25, 2018 3:20 am

Fri Aug 02, 2019 8:29 am

Hello,

Greetings from E-iceblue.
Could you please let us know how is the issue going? Thanks in advance for your feedback and time.

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1261
Joined: Wed Apr 25, 2018 3:20 am

Return to Spire.Doc