将html流保存为word文件

  /// <param name="strDataValue"></param>
  private void ExportWord(string strDataValue)
  {
   FileStream Fs  =new FileStream(outputFile,FileMode.Create);
   BinaryWriter binWrite=new BinaryWriter(Fs,System.Text.Encoding.GetEncoding("GB2312"));
   binWrite.Write(strDataValue);
   binWrite.Close();
   Fs.Close();
  }

  private string GetHttpStream(string strHttpPath)
  {
   string strHtml="";
   
   HttpWebRequest httpWebRequest=(HttpWebRequest)WebRequest.Create(strHttpPath);
   httpWebRequest.KeepAlive=false;
   HttpWebResponse httpWebResponse=(HttpWebResponse)httpWebRequest.GetResponse();
   
   Stream stream=httpWebResponse.GetResponseStream();
   Encoding encode = System.Text.Encoding.GetEncoding("GB2312");
   StreamReader readStream = new StreamReader( stream,encode);
   Char[] chrArrRead = new Char[256];
   int intCount = readStream.Read( chrArrRead, 0, 256 );
   
   while (intCount > 0)
   {
    String strTemp = new String(chrArrRead, 0, intCount);
    strHtml+=strTemp.Replace("/t","");
    intCount = readStream.Read(chrArrRead, 0, 256);
   }

   httpWebResponse.Close();
   readStream.Close();
   return strHtml;
  }

 

你可能感兴趣的:(将html流保存为word文件)