java 怎么把ppt转html

ppt保存为html文件的方法:用c#可以轻松实现转换:using System;using System.Collections.Generic;using System.Text;using System.IO;using PPT = Microsoft.Office.Interop.PowerPoint;using System.Reflection;namespace WritePptDemo{class Program{static void Main(string[] args){string path; //文件路径变量PPT.Application pptApp; //Excel应用程序变量PPT.Presentation pptDoc; //Excel文档变量PPT.Presentation pptDoctmp;path = @"C:\MyPPT.ppt"; //路径pptApp = new PPT.ApplicationClass(); //初始化//如果已存在,则删除if (File.Exists((string)path)){File.Delete((string)path);}//由于使用的是COM库,因此有许多变量需要用Nothing代替Object Nothing = Missing.Value;pptDoc = pptApp.Presentations.Add(Microsoft.Office.Core.MsoTriState.msoFalse);pptDoc.Slides.Add(1, Microsoft.Office.Interop.PowerPoint.PpSlideLayout.ppLayoutText);string text = "示例文本";foreach (PPT.Slide slide in pptDoc.Slides){foreach (PPT.Shape shape in slide.Shapes){shape.TextFrame.TextRange.InsertAfter(text);}}//WdSaveFormat为Excel文档的保存格式PPT.PpSaveAsFileType format = PPT.PpSaveAsFileType.ppSaveAsDefault;//将excelDoc文档对象的内容保存为XLSX文档 pptDoc.SaveAs(path, format, Microsoft.Office.Core.MsoTriState.msoFalse);//关闭excelDoc文档对象 pptDoc.Close();//关闭excelApp组件对象 pptApp.Quit();Console.WriteLine(path + " 创建完毕!e68a84e8a2ade799bee5baa631333363383464");Console.ReadLine();string pathHtml = @"c:\MyPPT";PPT.Application pa = new PPT.ApplicationClass();pptDoctmp = pa.Presentations.Open(path, Microsoft.Office.Core.MsoTriState.msoTrue, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoFalse);PPT.PpSaveAsFileType formatTmp = PPT.PpSaveAsFileType.ppSaveAsHTML;pptDoctmp.SaveAs(pathHtml, formatTmp, Microsoft.Office.Core.MsoTriState.msoFalse);pptDoctmp.Close();pa.Quit();Console.WriteLine(pathHtml + " 创建完毕!");}}}这样在创建完毕后就可以在c盘找到MyPPT了。

用vbs语言可以实现的 本回答由提问者推荐

除了气功还有啥办法....ppt转html是个大工程.. 你要有兴趣研究. 去找openoffices的源码, 用你的余生了却这段心愿吧

参考如下例子,就可以轻松将txt文件转化为html文件:private static String txtToHtml(String s) { StringBuilder builder = new StringBuilder(); boolean previousWasASpace = false; for (char c : s.toCharArray()) { if (c == ' ') { if (previousWasASpace) { builder.append(" "); previousWasASpace = false; continue; } previousWasASpace = true; } else { previousWasASpace = false; } switch (c) { case '<': builder.append("<"); break; case '>': builder.append(">"); break; case '&': builder.append("&"); break; case '"': builder.append("""); break; case '\n': builder.append("<br>"); break; // We need Tab support here, because we print StackTraces as HTML case '\t': builder.append(" "); break; default: builder.append(c); } } String converted = builder.toString(); String str = "(?i)\\b((?:https?://|www\\d{0,3}[.]|[a-z0-9.\\-]+[.][a-z]{2,4}/)(?:[^\\s()<>]+|\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\))+(?:\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\)|[^\\s`!()\\[\\]{};:\'\".,<>?«»“”‘’e799bee5baa6e79fa5e98193e4b893e5b19e31333337386563]))"; Pattern patt = Pattern.compile(str); Matcher matcher = patt.matcher(converted); converted = matcher.replaceAll("<a href=\"$1\">$1</a>"); return converted; }

如果txt本身就是复html结构的话,复制txt后输出格式定义为html类型制.response.setContentType("text/html;charset=GB2312"); 如果没有html 格式。。 你转他zhidao干么 呢?

如果txt本身就是html结构的话,复制txt后输出格式定义为html类型.response.setContentType("text/html;charset=GB2312");

哈哈,我前年做了一个这样的小程序!

java 怎么把ppt转html 第1张

改后缀名。

apache 有个开源的项目,POI可以转换jacob 也可以调用word的vba生成html……当然还有更好的,但复杂 本回答由提问者推荐

java 怎么把ppt转html 第2张

Dispatch wordfile = Dispatch.invoke(wordacc,"Open",Dispatch.Method,new Object[] { ls_word, new Variant(false),new Variant(true) }, new int[1]).toDispatch();Dispatch.invoke(wordfile, "SaveAs", Dispatch.Method, new Object[] {ls_html, new Variant(8) }, new int[1]);Variant f = new Variant(false);// 编写 生成的htmlDispatch.call((Dispatch) wordfile, "Close", (Object) f);在执行Dispatch.invoke(wordfile, "SaveAs", Dispatch.Method, new Object[] {ls_html, new Variant(8) }, new int[1]); jacob.jarjacob-1.14-x86.dll jacob-1.14-x64.dll 这些的位置有什么要求抛出异常 路径绝对没有e5a48de588b6e799bee5baa6e997aee7ad9431333363393731错 com.jacob.com.ComFailException: Invoke of: SaveAsSource: Microsoft WordDescription: 这不是有效文件名。请试用下列方法: * 检查路径,确认键入无误。* 从文件和文件夹列表中选择文件。at com.jacob.com.Dispatch.invokev(Native Method)at com.jacob.com.Dispatch.invokev(Dispatch.java:858)at com.jacob.com.Dispatch.invoke(Dispatch.java:502) 本回答由提问者推荐