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 Feb 08, 2016 7:09 pm

I have code that allows for reading HTML text from MSSQL DB into text field, append it to a HTML doc and write to local disk, then load into a DOCX and rewrite it back to the local disk as a WORD DOCX file. I now want to do all of this via a MemoryStream object, in other words I want to do a complete conversion in memory and write back to another table in the MSSQL DB without ever writing to the local disk. I also want to allow for editing this stream in WORD and writing it back to the database without ever writing a file to disk.

I started by loading the MemoryStream from a text field containing the HTML string and trying to save it to disk as a test.
Code: Select all
                MemoryStream memstreamOriginal = new MemoryStream();
                byte[] arrByteDataHTML = new byte[lblHTML.Text.ToString().Length];
                Document docx = new Document();
                memstreamOriginal.Write(arrByteDataHTML,0,arrByteDataHTML.Length);
                docx.LoadFromStream(memstreamOriginal, FileFormat.Html);
                docx.SaveToFile(strFileName, FileFormat.Html);


I received this error.
Code: Select all
A first chance exception of type 'System.Xml.Schema.XmlSchemaValidationException' occurred in System.Xml.dll
The element 'html' in namespace 'http://www.w3.org/1999/xhtml' has incomplete content. List of possible elements expected: 'http://www.w3.org/1999/xhtml:body'.


This is the HTML code
Code: Select all
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:st1="urn:schemas-microsoft-com:office:smarttags" xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<meta name=ProgId content=Word.Document>
<meta name=Generator content="Microsoft Word 11">
<meta name=Originator content="Microsoft Word 11">
<link rel=File-List href="Narrative2_files/filelist.xml">
<link rel=Edit-Time-Data href="Narrative2_files/editdata.mso">
<o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"  name="place"/>
<o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"  name="PlaceType"/>
<o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"  name="PlaceName"/>
<!--[if gte mso 9]><xml>
 <w:WordDocument>
  <w:Zoom>0</w:Zoom>
  <w:ValidateAgainstSchemas/>
  <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
  <w:IgnoreMixedContent>false</w:IgnoreMixedContent>
  <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
  <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
 </w:WordDocument>
</xml><![endif]--><!--[if gte mso 9]><xml>
 <w:LatentStyles DefLockedState="false" LatentStyleCount="156">
 </w:LatentStyles>
</xml><![endif]--><!--[if !mso]><object
 classid="clsid:38481807-CA0E-42D2-BF39-B33AF135CC4D" id=ieooui></object>
<style>
st1\:*{behavior:url(#ieooui) }
</style>
<![endif]-->
<style>
<!--
st1\:*{behavior:url(#ieooui) }
st1\:*{behavior:url(#ieooui) }
st1\:*{behavior:url(#ieooui) }

 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
   {mso-style-parent:"";
   margin:0in;
   margin-bottom:.0001pt;
   mso-pagination:widow-orphan;
   font-size:11.0pt;
   font-family:Arial;
   mso-fareast-font-family:Arial;}
h1
   {mso-style-next:Normal;
   margin:0in;
   margin-bottom:.0001pt;
   mso-pagination:widow-orphan;
   page-break-after:avoid;
   mso-outline-level:1;
   font-size:16.0pt;
   font-family:Arial;
   mso-fareast-font-family:Arial;
   mso-font-kerning:16.0pt;}
@page Section1
   {size:8.5in 11.0in;
   margin:.5in 54.7pt .5in 54.7pt;
   mso-header-margin:.5in;
   mso-footer-margin:.5in;
   mso-paper-source:0;}
div.Section1
   {page:Section1;}
-->
</style>
<!--[if gte mso 10]>
<style>
 /* Style Definitions */
 table.MsoNormalTable
   {mso-style-name:"Table Normal";
   mso-tstyle-rowband-size:0;
   mso-tstyle-colband-size:0;
   mso-style-noshow:yes;
   mso-style-parent:"";
   mso-padding-alt:0in 5.4pt 0in 5.4pt;
   mso-para-margin:0in;
   mso-para-margin-bottom:.0001pt;
   mso-pagination:widow-orphan;
   font-size:10.0pt;
   font-family:"Times New Roman";
   mso-ansi-language:#0400;
   mso-fareast-language:#0400;
   mso-bidi-language:#0400;}
</style>
<![endif]--><OBJECT id=ieooui classid=clsid:38481807-CA0E-42D2-BF39-B33AF135CC4D></OBJECT><OBJECT id=ieooui classid=clsid:38481807-CA0E-42D2-BF39-B33AF135CC4D></OBJECT><OBJECT id=ieooui classid=clsid:38481807-CA0E-42D2-BF39-B33AF135CC4D></OBJECT>
</head>

<body lang=EN-US style='tab-interval:.5in'>

<div class=Section1>

<p class=MsoNormal>AB 1653 (Chapter 218, Statutes of 2010) revises the Medi-Cal
hospital provider fee and supplemental payments enacted by AB 1383 (Chapter
627, Statutes of 2009).<span style='mso-spacerun:yes'>&nbsp; </span>AB 1653
alters the methodology, timing, and frequency of supplemental payments,
increases capitation payments, and increases payments to mental health
plans.<span style='mso-spacerun:yes'>&nbsp; </span>AB 1653 allows the
Department to proceed with implementing the Quality Assurance Fee (QAF) once a
letter indicating likely federal approval has been received.<span
style='mso-spacerun:yes'>&nbsp; </span>AB 1653 also allows the State to retain
up to $420 million from the portion of the Hospital Quality Assurance Revenue
Fund (HQARF) (Item 4260-610-3158) set aside for direct grants to designated
public hospitals for the State&#8217;s use while the bill is in effect.<span
style='mso-spacerun:yes'>&nbsp; </span>In exchange, a portion of federal
flexibility funding would be allocated to the designated public hospitals and
be identical in amount to the sum retained by the State from the QAF fund.<span
style='mso-spacerun:yes'>&nbsp; </span>The Department would claim these federal
funds upon receipt of the necessary expenditure reports and certifications from
the public hospitals, and would distribute those funds in conformity with the <st1:place
w:st="on"><st1:PlaceName w:st="on">QAF</st1:PlaceName> <st1:PlaceType w:st="on">Hospital</st1:PlaceType></st1:place>
payment schedule.<span style='mso-spacerun:yes'>&nbsp; </span></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal>This policy change reflects the retention of the $420
million from the HQARF fund by the State and the payment of $420 million in
federal flexibility funds to the DPHs for their CPEs.<span
style='mso-spacerun:yes'>&nbsp; </span>The retention and the payments were both
completed in December 2010.<span style='mso-spacerun:yes'>&nbsp; </span>Other
supplemental payments authorized by AB 1383 and AB 1653 are shown in a separate
PC.<span style='mso-spacerun:yes'>&nbsp; </span>The funding adjustment is
reflected in the management summary.<span style='mso-spacerun:yes'>&nbsp;
</span></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<div align=center>

<table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0
 style='border-collapse:collapse;mso-yfti-tbllook:480;mso-padding-alt:0in 2.15pt 0in 2.15pt'>
 <tr style='mso-yfti-irow:0;mso-yfti-firstrow:yes'>
  <td width=106 valign=bottom style='width:1.1in;padding:0in 2.15pt 0in 2.15pt'>
  <p class=MsoNormal align=center style='text-align:center'><b
  style='mso-bidi-font-weight:normal'>FY 2010-11<o:p></o:p></b></p>
  </td>
  <td width=115 valign=bottom style='width:1.2in;border:none;border-bottom:
  solid windowtext 1.0pt;mso-border-bottom-alt:solid windowtext .5pt;
  padding:0in 2.15pt 0in 2.15pt'>
  <p class=MsoNormal align=center style='text-align:center'><b
  style='mso-bidi-font-weight:normal'>TF<o:p></o:p></b></p>
  </td>
  <td width=16 valign=top style='width:11.8pt;padding:0in 2.15pt 0in 2.15pt'>
  <p class=MsoNormal align=center style='text-align:center'><b
  style='mso-bidi-font-weight:normal'><o:p>&nbsp;</o:p></b></p>
  </td>
  <td width=125 valign=bottom style='width:1.3in;border:none;border-bottom:
  solid windowtext 1.0pt;mso-border-bottom-alt:solid windowtext .5pt;
  padding:0in 2.15pt 0in 2.15pt'>
  <p class=MsoNormal align=center style='text-align:center'><b
  style='mso-bidi-font-weight:normal'>GF<o:p></o:p></b></p>
  </td>
  <td width=16 valign=top style='width:11.8pt;padding:0in 2.15pt 0in 2.15pt'>
  <p class=MsoNormal align=center style='text-align:center'><b
  style='mso-bidi-font-weight:normal'><o:p>&nbsp;</o:p></b></p>
  </td>
  <td width=115 valign=top style='width:1.2in;border:none;border-bottom:solid windowtext 1.0pt;
  mso-border-bottom-alt:solid windowtext .5pt;padding:0in 2.15pt 0in 2.15pt'>
  <p class=MsoNormal align=center style='text-align:center'><b
  style='mso-bidi-font-weight:normal'>Hosp. QA Rev. Fund<o:p></o:p></b></p>
  </td>
  <td width=16 valign=top style='width:11.8pt;padding:0in 2.15pt 0in 2.15pt'>
  <p class=MsoNormal align=center style='text-align:center'><b
  style='mso-bidi-font-weight:normal'><o:p>&nbsp;</o:p></b></p>
  </td>
  <td width=115 valign=bottom style='width:1.2in;border:none;border-bottom:
  solid windowtext 1.0pt;mso-border-bottom-alt:solid windowtext .5pt;
  padding:0in 2.15pt 0in 2.15pt'>
  <p class=MsoNormal align=center style='text-align:center'><b
  style='mso-bidi-font-weight:normal'>FF<o:p></o:p></b></p>
  </td>
 </tr>
 <tr style='mso-yfti-irow:1;mso-yfti-lastrow:yes'>
  <td width=106 valign=top style='width:1.1in;padding:0in 2.15pt 0in 2.15pt'>
  <p class=MsoNormal><b style='mso-bidi-font-weight:normal'><o:p>&nbsp;</o:p></b></p>
  </td>
  <td width=115 style='width:1.2in;border:none;mso-border-top-alt:solid windowtext .5pt;
  padding:0in 2.15pt 0in 2.15pt'>
  <p class=MsoNormal align=right style='text-align:right'><b style='mso-bidi-font-weight:
  normal'>$420,000,000<o:p></o:p></b></p>
  </td>
  <td width=16 valign=top style='width:11.8pt;padding:0in 2.15pt 0in 2.15pt'>
  <p class=MsoNormal align=right style='text-align:right'><b style='mso-bidi-font-weight:
  normal'><o:p>&nbsp;</o:p></b></p>
  </td>
  <td width=125 style='width:1.3in;border:none;mso-border-top-alt:solid windowtext .5pt;
  padding:0in 2.15pt 0in 2.15pt'>
  <p class=MsoNormal align=right style='text-align:right'><b style='mso-bidi-font-weight:
  normal'>$-420,000,000<o:p></o:p></b></p>
  </td>
  <td width=16 valign=top style='width:11.8pt;padding:0in 2.15pt 0in 2.15pt'>
  <p class=MsoNormal align=right style='text-align:right'><b style='mso-bidi-font-weight:
  normal'><o:p>&nbsp;</o:p></b></p>
  </td>
  <td width=115 style='width:1.2in;border:none;mso-border-top-alt:solid windowtext .5pt;
  padding:0in 2.15pt 0in 2.15pt'>
  <p class=MsoNormal align=right style='text-align:right'><b style='mso-bidi-font-weight:
  normal'>$420,000,000<o:p></o:p></b></p>
  </td>
  <td width=16 valign=top style='width:11.8pt;padding:0in 2.15pt 0in 2.15pt'>
  <p class=MsoNormal align=right style='text-align:right'><b style='mso-bidi-font-weight:
  normal'><o:p>&nbsp;</o:p></b></p>
  </td>
  <td width=115 style='width:1.2in;border:none;mso-border-top-alt:solid windowtext .5pt;
  padding:0in 2.15pt 0in 2.15pt'>
  <p class=MsoNormal align=right style='text-align:right'><b style='mso-bidi-font-weight:
  normal'>$420,000,000<o:p></o:p></b></p>
  </td>
 </tr>
</table>

</div>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

</div>

</body>

</html>


How do I go about doing a complete HTML-to-WORD conversion and edit using MemoryStream as a conduit and calling your library functions?

Thank You

:Darrell

DarrellRobertParker
 
Posts: 8
Joined: Tue Dec 29, 2015 5:37 pm

Tue Feb 09, 2016 6:09 am

Hi,

Thanks for your posting and using our component.
In your html code, there are some no closing tags.
Code: Select all
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<meta name=ProgId content=Word.Document>
<meta name=Generator content="Microsoft Word 11">
<meta name=Originator content="Microsoft Word 11">
<link rel=File-List href="Narrative2_files/filelist.xml">
<link rel=Edit-Time-Data href="Narrative2_files/editdata.mso">


After closing all tags, the new html code as below, please try.
Code: Select all
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:st1="urn:schemas-microsoft-com:office:smarttags" xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii"/>
<meta name=ProgId content="Word.Document"/>
<meta name=Generator content="Microsoft Word 11"/>
<meta name=Originator content="Microsoft Word 11"/>
<link rel=File-List href="Narrative2_files/filelist.xml"/>
<link rel=Edit-Time-Data href="Narrative2_files/editdata.mso"/>
<o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"  name="place"/>
<o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"  name="PlaceType"/>
<o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"  name="PlaceName"/>
<!--[if gte mso 9]><xml>
 <w:WordDocument>
  <w:Zoom>0</w:Zoom>
  <w:ValidateAgainstSchemas/>
  <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
  <w:IgnoreMixedContent>false</w:IgnoreMixedContent>
  <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
  <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
 </w:WordDocument>
</xml><![endif]--><!--[if gte mso 9]><xml>
 <w:LatentStyles DefLockedState="false" LatentStyleCount="156">
 </w:LatentStyles>
</xml><![endif]--><!--[if !mso]><object
 classid="clsid:38481807-CA0E-42D2-BF39-B33AF135CC4D" id=ieooui></object>
<style>
st1\:*{behavior:url(#ieooui) }
</style>
<![endif]-->
<style>
<!--
st1\:*{behavior:url(#ieooui) }
st1\:*{behavior:url(#ieooui) }
st1\:*{behavior:url(#ieooui) }

 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
   {mso-style-parent:"";
   margin:0in;
   margin-bottom:.0001pt;
   mso-pagination:widow-orphan;
   font-size:11.0pt;
   font-family:Arial;
   mso-fareast-font-family:Arial;}
h1
   {mso-style-next:Normal;
   margin:0in;
   margin-bottom:.0001pt;
   mso-pagination:widow-orphan;
   page-break-after:avoid;
   mso-outline-level:1;
   font-size:16.0pt;
   font-family:Arial;
   mso-fareast-font-family:Arial;
   mso-font-kerning:16.0pt;}
@page Section1
   {size:8.5in 11.0in;
   margin:.5in 54.7pt .5in 54.7pt;
   mso-header-margin:.5in;
   mso-footer-margin:.5in;
   mso-paper-source:0;}
div.Section1
   {page:Section1;}
-->
</style>
<!--[if gte mso 10]>
<style>
 /* Style Definitions */
 table.MsoNormalTable
   {mso-style-name:"Table Normal";
   mso-tstyle-rowband-size:0;
   mso-tstyle-colband-size:0;
   mso-style-noshow:yes;
   mso-style-parent:"";
   mso-padding-alt:0in 5.4pt 0in 5.4pt;
   mso-para-margin:0in;
   mso-para-margin-bottom:.0001pt;
   mso-pagination:widow-orphan;
   font-size:10.0pt;
   font-family:"Times New Roman";
   mso-ansi-language:#0400;
   mso-fareast-language:#0400;
   mso-bidi-language:#0400;}
</style>
<![endif]--><OBJECT id=ieooui classid=clsid:38481807-CA0E-42D2-BF39-B33AF135CC4D></OBJECT><OBJECT id=ieooui classid=clsid:38481807-CA0E-42D2-BF39-B33AF135CC4D></OBJECT><OBJECT id=ieooui classid=clsid:38481807-CA0E-42D2-BF39-B33AF135CC4D></OBJECT>
</head>

<body lang=EN-US style='tab-interval:.5in'>

<div class=Section1>

<p class=MsoNormal>AB 1653 (Chapter 218, Statutes of 2010) revises the Medi-Cal
hospital provider fee and supplemental payments enacted by AB 1383 (Chapter
627, Statutes of 2009).<span style='mso-spacerun:yes'>&nbsp; </span>AB 1653
alters the methodology, timing, and frequency of supplemental payments,
increases capitation payments, and increases payments to mental health
plans.<span style='mso-spacerun:yes'>&nbsp; </span>AB 1653 allows the
Department to proceed with implementing the Quality Assurance Fee (QAF) once a
letter indicating likely federal approval has been received.<span
style='mso-spacerun:yes'>&nbsp; </span>AB 1653 also allows the State to retain
up to $420 million from the portion of the Hospital Quality Assurance Revenue
Fund (HQARF) (Item 4260-610-3158) set aside for direct grants to designated
public hospitals for the State&#8217;s use while the bill is in effect.<span
style='mso-spacerun:yes'>&nbsp; </span>In exchange, a portion of federal
flexibility funding would be allocated to the designated public hospitals and
be identical in amount to the sum retained by the State from the QAF fund.<span
style='mso-spacerun:yes'>&nbsp; </span>The Department would claim these federal
funds upon receipt of the necessary expenditure reports and certifications from
the public hospitals, and would distribute those funds in conformity with the <st1:place
w:st="on"><st1:PlaceName w:st="on">QAF</st1:PlaceName> <st1:PlaceType w:st="on">Hospital</st1:PlaceType></st1:place>
payment schedule.<span style='mso-spacerun:yes'>&nbsp; </span></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal>This policy change reflects the retention of the $420
million from the HQARF fund by the State and the payment of $420 million in
federal flexibility funds to the DPHs for their CPEs.<span
style='mso-spacerun:yes'>&nbsp; </span>The retention and the payments were both
completed in December 2010.<span style='mso-spacerun:yes'>&nbsp; </span>Other
supplemental payments authorized by AB 1383 and AB 1653 are shown in a separate
PC.<span style='mso-spacerun:yes'>&nbsp; </span>The funding adjustment is
reflected in the management summary.<span style='mso-spacerun:yes'>&nbsp;
</span></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<div align=center>

<table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0
 style='border-collapse:collapse;mso-yfti-tbllook:480;mso-padding-alt:0in 2.15pt 0in 2.15pt'>
 <tr style='mso-yfti-irow:0;mso-yfti-firstrow:yes'>
  <td width=106 valign=bottom style='width:1.1in;padding:0in 2.15pt 0in 2.15pt'>
  <p class=MsoNormal align=center style='text-align:center'><b
  style='mso-bidi-font-weight:normal'>FY 2010-11<o:p></o:p></b></p>
  </td>
  <td width=115 valign=bottom style='width:1.2in;border:none;border-bottom:
  solid windowtext 1.0pt;mso-border-bottom-alt:solid windowtext .5pt;
  padding:0in 2.15pt 0in 2.15pt'>
  <p class=MsoNormal align=center style='text-align:center'><b
  style='mso-bidi-font-weight:normal'>TF<o:p></o:p></b></p>
  </td>
  <td width=16 valign=top style='width:11.8pt;padding:0in 2.15pt 0in 2.15pt'>
  <p class=MsoNormal align=center style='text-align:center'><b
  style='mso-bidi-font-weight:normal'><o:p>&nbsp;</o:p></b></p>
  </td>
  <td width=125 valign=bottom style='width:1.3in;border:none;border-bottom:
  solid windowtext 1.0pt;mso-border-bottom-alt:solid windowtext .5pt;
  padding:0in 2.15pt 0in 2.15pt'>
  <p class=MsoNormal align=center style='text-align:center'><b
  style='mso-bidi-font-weight:normal'>GF<o:p></o:p></b></p>
  </td>
  <td width=16 valign=top style='width:11.8pt;padding:0in 2.15pt 0in 2.15pt'>
  <p class=MsoNormal align=center style='text-align:center'><b
  style='mso-bidi-font-weight:normal'><o:p>&nbsp;</o:p></b></p>
  </td>
  <td width=115 valign=top style='width:1.2in;border:none;border-bottom:solid windowtext 1.0pt;
  mso-border-bottom-alt:solid windowtext .5pt;padding:0in 2.15pt 0in 2.15pt'>
  <p class=MsoNormal align=center style='text-align:center'><b
  style='mso-bidi-font-weight:normal'>Hosp. QA Rev. Fund<o:p></o:p></b></p>
  </td>
  <td width=16 valign=top style='width:11.8pt;padding:0in 2.15pt 0in 2.15pt'>
  <p class=MsoNormal align=center style='text-align:center'><b
  style='mso-bidi-font-weight:normal'><o:p>&nbsp;</o:p></b></p>
  </td>
  <td width=115 valign=bottom style='width:1.2in;border:none;border-bottom:
  solid windowtext 1.0pt;mso-border-bottom-alt:solid windowtext .5pt;
  padding:0in 2.15pt 0in 2.15pt'>
  <p class=MsoNormal align=center style='text-align:center'><b
  style='mso-bidi-font-weight:normal'>FF<o:p></o:p></b></p>
  </td>
 </tr>
 <tr style='mso-yfti-irow:1;mso-yfti-lastrow:yes'>
  <td width=106 valign=top style='width:1.1in;padding:0in 2.15pt 0in 2.15pt'>
  <p class=MsoNormal><b style='mso-bidi-font-weight:normal'><o:p>&nbsp;</o:p></b></p>
  </td>
  <td width=115 style='width:1.2in;border:none;mso-border-top-alt:solid windowtext .5pt;
  padding:0in 2.15pt 0in 2.15pt'>
  <p class=MsoNormal align=right style='text-align:right'><b style='mso-bidi-font-weight:
  normal'>$420,000,000<o:p></o:p></b></p>
  </td>
  <td width=16 valign=top style='width:11.8pt;padding:0in 2.15pt 0in 2.15pt'>
  <p class=MsoNormal align=right style='text-align:right'><b style='mso-bidi-font-weight:
  normal'><o:p>&nbsp;</o:p></b></p>
  </td>
  <td width=125 style='width:1.3in;border:none;mso-border-top-alt:solid windowtext .5pt;
  padding:0in 2.15pt 0in 2.15pt'>
  <p class=MsoNormal align=right style='text-align:right'><b style='mso-bidi-font-weight:
  normal'>$-420,000,000<o:p></o:p></b></p>
  </td>
  <td width=16 valign=top style='width:11.8pt;padding:0in 2.15pt 0in 2.15pt'>
  <p class=MsoNormal align=right style='text-align:right'><b style='mso-bidi-font-weight:
  normal'><o:p>&nbsp;</o:p></b></p>
  </td>
  <td width=115 style='width:1.2in;border:none;mso-border-top-alt:solid windowtext .5pt;
  padding:0in 2.15pt 0in 2.15pt'>
  <p class=MsoNormal align=right style='text-align:right'><b style='mso-bidi-font-weight:
  normal'>$420,000,000<o:p></o:p></b></p>
  </td>
  <td width=16 valign=top style='width:11.8pt;padding:0in 2.15pt 0in 2.15pt'>
  <p class=MsoNormal align=right style='text-align:right'><b style='mso-bidi-font-weight:
  normal'><o:p>&nbsp;</o:p></b></p>
  </td>
  <td width=115 style='width:1.2in;border:none;mso-border-top-alt:solid windowtext .5pt;
  padding:0in 2.15pt 0in 2.15pt'>
  <p class=MsoNormal align=right style='text-align:right'><b style='mso-bidi-font-weight:
  normal'>$420,000,000<o:p></o:p></b></p>
  </td>
 </tr>
</table>

</div>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

</div>

</body>

</html>


Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Tue Feb 09, 2016 4:40 pm

Hi Amy - Thanks for the assist. I rechecked the data stream (as well as randomly choosing others from the 25,000 that I have available) that I am using for testing and I noticed that it works fine when I use this method.

Code: Select all
                string strTempPath = Path.GetTempPath();
                Document docx = new Document();
                Section sect = docx.AddSection();
                Paragraph parag = sect.AddParagraph();
                parag.AppendHTML(lblHTML.Text.ToString()); // text to be converted that has been pulled from data table

                strFileName = FileNameReturned(strTempPath, "Temp", "html");
                docx.SaveToFile(strFileName, FileFormat.Html); // try saving it as an HTML file first

                lblMSG2.Text = "HTML document saved to file  " + strFileName;

                docx.LoadFromFile(strFileName, FileFormat.Html, XHTMLValidationType.None); // reload HTML file

                strFileName = FileNameReturned(strTempPath, "Temp", "docx");

                docx.SaveToFile(strFileName, FileFormat.Docx); // resave it as a DOCX file

                lblMSG2.Text = "Word document is created " + strFileName;

                System.Diagnostics.Process.Start(strFileName); // open file in Word


However the case is not the same for this method.

Code: Select all
                MemoryStream memstreamOriginal = new MemoryStream();
                byte[] arrByteDataHTML = new byte[lblHTML.Text.ToString().Length];
                Document docx = new Document();
                memstreamOriginal.Write(arrByteDataHTML,0,arrByteDataHTML.Length);
                docx.LoadFromStream(memstreamOriginal, FileFormat.Html);
                docx.SaveToFile(strFileName, FileFormat.Html);


The second one is critical in the sense that I am trying to accomplish all of this in Memory rather than using the less efficient first method.

Is it possible I am missing a critical logic component when making use of the MemoryStream object in order for the conversion process to complete properly?

Thank you

DarrellRobertParker
 
Posts: 8
Joined: Tue Dec 29, 2015 5:37 pm

Tue Feb 09, 2016 5:28 pm

Hi Amy - After further exploration I have determined that my use of the MemoryStream object was incorrect rather than the data being faulty.

However I would still appreciate any direction you could give me in when it comes to editing the Word stream once it has been converted in Memory. Again I am trying to avoid writing the HTML file to disk then reading it back as a Word document then saving it back to the drive before allowing it to be edited.

Hopefully that made sense.

Thank you

:Darrell

DarrellRobertParker
 
Posts: 8
Joined: Tue Dec 29, 2015 5:37 pm

Wed Feb 10, 2016 3:26 am

Hi,

Thanks for your feedback.
Sorry that at present I have no methods except the first method.

Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Return to Spire.Doc