html网页转换成word文档,转换成功,并且可以保存图片,但是总是为"web版式"的格式,如何改成“页面”格式,谢谢
转换成功,并且可以保存图片,但是总是为"web版式"的格式,如何改成“页面”格式,谢谢
Word.Document thisDocument = null;
Word.FormFields formFields = null;
Word.Application thisApplication = new Word.ApplicationClass();
thisApplication.Visible = true;
thisApplication.Caption = "";
thisApplication.Options.CheckSpellingAsYouType = false;
thisApplication.Options.CheckGrammarAsYouType = false;
Object ConfirmConversions = false;
Object ReadOnly = true;
object AddToRecentFiles = true;
Object PasswordDocument = System.Type.Missing;
Object PasswordTemplate = System.Type.Missing;
Object Revert = System.Type.Missing;
Object WritePasswordDocument = System.Type.Missing;
Object WritePasswordTemplate = System.Type.Missing;
Object Format = System.Type.Missing;//
Object Encoding = System.Type.Missing;
Object Visible = System.Type.Missing;
Object OpenAndRepair = System.Type.Missing;
Object DocumentDirection = System.Type.Missing;
Object NoEncodingDialog = System.Type.Missing;
Object XMLTransform = System.Type.Missing;
object FileFormat = Word.WdSaveFormat.wdFormatDocument;
object SaveNativePictureFormat = false;
object LineEnding = Word.WdLineEndingType.wdCRLF;//Word.WdLineEndingType.wdLSPS;
Word.ApplicationClass word = new ApplicationClass();
object nothing = System.Reflection.Missing.Value;
//路径
object filename = "D:\\test.html";
string FileName="D:\\test.doc";
Word.Document doc =
thisApplication.Documents.Open(ref filename, ref ConfirmConversions,
ref ReadOnly, ref AddToRecentFiles, ref PasswordDocument, ref PasswordTemplate,
ref Revert, ref WritePasswordDocument, ref WritePasswordTemplate, ref Format,
ref Encoding, ref Visible, ref OpenAndRepair, ref DocumentDirection,
ref NoEncodingDialog, ref XMLTransform);
//doc.Paragraphs.Last.Range.Text = this.richTextBox1.Text;
object myfileName = FileName;
//将WordDoc文档对象的内容保存为doc文档
doc.SaveAs(ref myfileName,ref FileFormat, ref nothing, ref nothing, ref AddToRecentFiles, ref nothing, ref nothing, ref nothing,ref SaveNativePictureFormat, ref nothing, ref nothing, ref nothing, ref nothing, ref nothing, ref LineEnding, ref nothing);
//关闭WordDoc文档对象
doc.Close(ref nothing, ref nothing, ref nothing);
//关闭WordApp组件对象
word.Quit(ref nothing, ref nothing, ref nothing);
Response.Write("successfully!");
System.Diagnostics.Process[] ps = System.Diagnostics.Process.GetProcesses();
foreach (System.Diagnostics.Process p in ps)
{
if (p.ProcessName.ToLower().CompareTo("winword") == 0)
p.Kill();
}
------解决方案--------------------
不知道 友情帮顶