c# word转换html,C# Execl WOrd 转化为html显示在页面上

///

///

///

/// 文件路径

/// 保存html格式的路径

public static void WordHtml(string filePath, string htmlPath)

{

Word.Application wordApp;

Word.Document wordDoc;

Object Nothing = Missing.Value;

Console.WriteLine("Input path:");

Object path = Console.ReadLine();

path = filePath;

wordApp = new Word.ApplicationClass();

wordDoc = wordApp.Documents.Add(ref path, ref Nothing, ref Nothing, ref Nothing);

object format = Word.WdSaveFormat.wdFormatFilteredHTML;

Object newPath = htmlPath;

wordDoc.SaveAs(ref newPath, ref format, ref Nothing, ref Nothing, ref Nothing,

ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing,

ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing);

wordDoc.Close(ref Nothing, ref Nothing, ref Nothing);

wordApp.Quit(ref Nothing, ref Nothing, ref Nothing);

}

///

///

///

/// 文件路径

/// 保存html格式的路径

public static void ExeclHtml(string filePath, string htmlPath)

{

try

{

Microsoft.Office.Interop.Excel.Application app = new Microsoft.Office.Interop.Excel.Application();

app.Visible = false;

app.DisplayAlerts = false;

object o = Missing.Value;

Microsoft.Office.Interop.Excel.Workbook workbook = null;

workbook = app.Workbooks.Open(filePath, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);

object fileName = htmlPath;

object format = Microsoft.Office.Interop.Excel.XlFileFormat.xlHtml;

workbook.SaveAs(fileName, format, o, o, o, o, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlExclusive, o, o, o, o);

app.Quit();

Process[] myProces = Process.GetProcessesByName("EXCEL");

foreach (Process proces in myProces)

{

proces.Kill();

}

}

catch (Exception ex)

{

System.Console.Write(ex.Message);

}

}

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Vant是一款基于Vue.js的移动端UI组件库,提供丰富的组件用于构建移动应用。列表是Vant中的一个常用组件,用于展示列表数据。可以通过Vant的列表组件轻松实现在移动端展示Word和Excel文档的功能。 要在Vant的列表中显示Word和Excel文档,可以按照以下步骤操作: 1. 首先,需要引入Vant的列表组件。可以通过在Vue的组件中使用Vant的List组件,来实现列表的显示。 2. 接下来,准备好要展示的Word和Excel文档的数据。可以在Vue的data中定义一个数组,包含所有要展示的文档的对象。每个对象包含文档的相关信息,比如文档的标题、文件路径等。 3. 在Vue的模板中,使用Vant的List组件,并将数据传递给组件的属性中。可以使用v-for指令循环遍历数据,将每个文档都展示出来。可以通过模板字符串来拼接每个文档的展示内容,比如将文档的标题放在一个`<div>`中,将文件路径放在一个`<span>`中。 4. 可以为每个文档项添加点击事件,当用户点击某个文档时,可以执行相应的操作,比如打开文档、下载等。可以通过在模板中的文档项元素上绑定一个@click事件,并将点击事件的处理函数写在Vue的methods选项中。 5. 最后,可以为列表添加样式,使其在移动端展示更加美观。可以通过在模板中的List组件上添加class或style属性来自定义样式,也可以使用Vant提供的样式类来美化列表。 通过以上步骤,我们可以在Vant的列表组件中成功显示Word和Excel文档。用户可以通过列表查看文档,并进行相应的操作。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值