手机上docx怎么转换成html,如何将.doc或.docx转换为html c#

帮助我,我知道如何结合这些代码。希望有人能帮助我。我在asp.net中使用c#并尝试将.doc和.docx转换为html以在网页中查看。

这是我的代码:

public bool WriteViewRow(DataRowView drv)

{

string strFileLink = null;

string strFileName = Convert.ToString(drv["Name"]);

string strFilePath = WebPathCombine(WebPath(), strFileName);

bool blnFolder = IsDirectory(drv);

if (blnFolder)

{

if (!string.IsNullOrEmpty(_strHideFolderPattern) && Regex.IsMatch(strFileName, _strHideFolderPattern, RegexOptions.IgnoreCase))

{

return false;

}

strFileLink = PageUrl(strFilePath) + strFileName + "";

}

else

{

if (!string.IsNullOrEmpty(_strHideFilePattern) && Regex.IsMatch(strFileName, _strHideFilePattern, RegexOptions.IgnoreCase))

{

return false;

}

strFileLink = "" + strFileName + ""; //link to open the file

}

我想使用此代码加入我的代码,我不想上传文件,但想使用上面代码中的链接来集成此代码:

//To check the file extension if it is word document or something else

string strFileName = fUpload.FileName;

string[] strSep = fUpload.FileName.Split('.');

int arrLength = strSep.Length - 1;

string strExt = strSep[arrLength].ToString().ToUpper(); //Save the uploaded file to the folder

strPathToUpload = Server.MapPath("Datadir"); //Map-path to the folder where html to be saved

strPathToConvert = Server.MapPath("WordToHtml");

object FileName = strPathToUpload + "\\" + fUpload.FileName;

object FileToSave = strPathToConvert + "\\" + fUpload.FileName + ".htm";

if (strExt.ToUpper() == "DOCX" || strExt.ToUpper() == "DOC" )

{

fUpload.SaveAs(strPathToUpload + "\\" + fUpload.FileName);

lblMessage.Text = "File uploaded successfully";

//open the file internally in word. In the method all the parameters should be passed by object reference

objWord.Documents.Open(ref FileName, ref readOnly, ref missing, ref missing, ref missing, ref missing,

ref missing, ref missing, ref missing, ref missing, ref isVisible, ref missing, ref missing, ref missing,

ref missing, ref missing);

//Do the background activity

objWord.Visible = false;

Microsoft.Office.Interop.Word.Document oDoc = objWord.ActiveDocument;

oDoc.SaveAs(ref FileToSave, ref fltDocFormat, ref missing, ref missing, ref missing, ref missing,ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);

lblMessage.Text = fUpload.FileName + " converted to HTML successfully";

docPreview.Attributes["src"] = "../WordToHtml/" + fUpload.FileName + ".htm";

}

任何人都有一些建议吗?其实我想开发一些像webmanager这样的网页,用户可以上传,删除,查看,编辑文件..如果文件.txt ...但我无法转换这一切都已经完成了。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值