在编一个程序时遇见了一个问题.
有一个程序需要将一些WORD上传并转为html,而且这些word是有图片和表格。现在在转换为html时这些图片和表格被显示在web页面的左方,不随显示器的大小改变位置,但文字部分就会随显示器大小改变位置,这样图片等就不能居中显示,而且图片和文字还发生错位.请问各位大虾,该怎样解决这个问题??.
有一个程序需要将一些WORD上传并转为html,而且这些word是有图片和表格。现在在转换为html时这些图片和表格被显示在web页面的左方,不随显示器的大小改变位置,但文字部分就会随显示器大小改变位置,这样图片等就不能居中显示,而且图片和文字还发生错位.请问各位大虾,该怎样解决这个问题??.
解决方案 »
- 我想获得隐藏列的值,但得不到。看看
- 涉及到 for循環和 變量名字的問題
- 请教:我的asp.net服务启动不起来,请高手指点
- 这里是不是真没有高手!这样的小问题都不能。。。。。
- 方法覆盖与重写的区别?
- 如何用正则表达式获取所有的超级链接(A)标签
- 关于窗体显示问题!请高手帮忙!
- 如何获得行号?DataRow findRow = thisDataSet.Tables["Customers"].Rows.Find("这是ID");
- 怎样在winForm中去掉文本框的复制粘贴功能?
- 一个关于SqlDataAdapter的Update问题
- 求一段代码!
- 用C#如何开发WEBSERVICE?像我文档这样的?
Type wordType = word.GetType();
Word.Documents docs = word.Documents;
// Open word document.
Type docsType = docs.GetType();
object fileName = "d:\\test.doc";
Word.Document doc = (Word.Document)docsType.InvokeMember("Open",System.Reflection.BindingFlags.InvokeMethod, null, docs, new Object[] {fileName, true, true});
// Save as html file.
Type docType = doc.GetType();
object saveFileName = "d:\\test1.html";
docType.InvokeMember("SaveAs", System.Reflection.BindingFlags.InvokeMethod,
null, doc, new object[]{saveFileName, Word.WdSaveFormat.wdFormatHTML});
// Quit.
wordType.InvokeMember("Quit", System.Reflection.BindingFlags.InvokeMethod,null, word, null);
希望大家多给意见
谢谢!!1
{ Word.ApplicationClass word = new Word.ApplicationClass();
Type wordType = word.GetType();
Word.Documents docs = word.Documents;
// 打开文件
Type docsType = docs.GetType();
//应当先把文件上传至服务器然后再解析文件为html
string filePath = uploadWord(wordFilePath);
//判断是否上传文件成功
if (filePath == "0")
return "0"; //判断是否为word文件
if (filePath == "1")
return "1";
object fileName = filePath;
Word.Document doc = (Word.Document)docsType.InvokeMember("Open", System.Reflection.BindingFlags.InvokeMethod, null, docs, new Object[] { fileName, true, true }); // 转换格式,另存为html
Type docType = doc.GetType(); string filename = System.DateTime.Now.Year.ToString() + System.DateTime.Now.Month.ToString() + System.DateTime.Now.Day.ToString() +System.DateTime.Now.Hour.ToString() + System.DateTime.Now.Minute.ToString() + System.DateTime.Now.Second.ToString();
//被转换的html文档保存的位置
string ConfigPath = HttpContext.Current.Server.MapPath("upload/" + filename + ".html");
TB_filepath.Text = "upload/" + filename + ".html";
object saveFileName = ConfigPath; docType.InvokeMember("SaveAs", System.Reflection.BindingFlags.InvokeMethod, null, doc, new object[] { saveFileName, Word.WdSaveFormat.wdFormatFilteredHTML });
// 退出 Word
wordType.InvokeMember("Quit", System.Reflection.BindingFlags.InvokeMethod, null, word, null);
//转到新生成的页面
return ("upload/" + filename + ".html");
}