Turn the word document to HTML with Java

xiaoxiao2021-03-06  38

The use of the package is downloaded here. Http://danadler.com/jacob/, write jacob.jar, jacob.dll's path to the ClassPath environment variable, below is the program I debugged: import com.jacob.com. * Import com.jacob.activex. *; import java.io. *; // get the specified directory All DOC file names public class wordtohtml {// ---------------- -------------------------------------------------- ------------ // Method Prototype: Change (String paths) // function Description: Translate all the DOC files below the specified directory into HTML and store it in the same directory // input parameters: string: String // Output parameters: None // Return value: None // Other description: Recursive // ​​------------------------------ ------------------------------------------------ Public Static Void change (String Paths, String SavePaths) {file d = new file (path); // Get list of all files and directories under the current folder File Lists [] = D.ListFiles (); string pathss = new string (" "); For (int i = 0; i

Boolean Flag = false; "Visible", new variant (false)); // Setting Word Not visible Object Docs = App.getProperty ("Documents"). Todispatch (); Object Doc = dispatch.invoke (DOCS, "open", dispatch.method, new object [] {infile, new variant (false), new variant (true)}, new int [1]). Todispatch (); // Open Word file dispatch.invoke (DOC, "Saveas", Dispatch.Method, New Object [] {TPFILE, New Variant (8)}, new int [1]); // Save to temporary file Variant f = new variant (false) as HTML format; Dispatch.call (DOC, "Close", F); FLAG = true;} catch (exception e) {E.PrintStackTrace ();} finally {app.invoke ("quit", new variant [] {};} System.out.println ("Transformation!");}} Else {system.out.print ("folder"); pathss = paths; // Go to the next directory Pathss = Pathss Lists [i] .Getname ( ) "//"; // recursively traversed all directories Change (pathss, savepaths);}}} // ----------------------- ------------------------------------------- ---------- // Method prototype: main (string [] args) // function description: main file // input parameter: None // Output parameter: None // Return value: None // Description: No // --------------------------------------------- --------------------------------- public static void main (string "args) {string paths = new String "E: // project //"); string savepath = new string ("d: // javapro /////////////////////////////////////////////////////////////////>

转载请注明原文地址:https://www.9cbs.com/read-77607.html

New Post(0)