[. NET] to create a very simple document converter,. net Converter
Create a simple document converter-use the Spire. Office component
[Blogger] Anti-bone Aberdeen [original] http://www.cnblogs.com/liqingwen/p/6024827.html
Collation
Previously, the article "do not talk about" Hello Word "at the beginning and read all the poems: Introduction to the Word operation component-Spire. Doc" briefly introduced how to use Spire. Doc. This article describes how to create a simple document converter.
Directory
- Introduction to Spire. Office
- Library Reference
- Interface Preview
- Code snippet
Introduction to Spire. Office
1 // create document Object 2 var Document = new document (); 3 4 // load document 5 Document. loadFromFile ("file name containing path"); // example: document. saveToFile ("sampleworkflow", FileFormat. PDF); 6 // save the file 7 document. saveToFile ("path containing file names", "file format type to be converted"); 8 9 // open the file and preview 10 processes. start ("file name containing path ");
There are many file format types supported here, And FileFormat enumeration.
1 public enum FileFormat 2 {3 // 4 // Summary: 5 // Microsoft Word 97-2003 Binary Document. 6 Doc = 0, 7 // 8 // Abstract: 9 // Microsoft Word 97-2003 Binary Document or Template. 10 Dot = 1, 11 // 12 // Summary: 13 // Microsoft Word 2007 Document. 14 Docx = 2, 15 // 16 // Abstract: 17 // Microsoft Word 2010 Document 18 Docx2010 = 3, 19 // 20 // Abstract: 21 // Microsoft Word 2013 Document 22 Docx2013 = 4, 23 // 24 // Summary: 25 // Microsoft Word 2007 Template format. 26 Dotx = 5, 27 // 28 // Abstract: 29 // Microsoft Word 2010 Template format. 30 Dotx2010 = 6, 31 // 32 // Abstract: 33 // Microsoft Word 2013 Template format. 34 Dotx2013 = 7, 35 // 36 // Abstract: 37 // Microsoft Word 2007 macro enabled file format. 38 Docm = 8, 39 // 40 // Summary: 41 // Microsoft Word 2010 macro enabled file format. 42 Docm2010 = 9, 43 // 44 // Summary: 45 // Microsoft Word 2013 macro enabled file format. 46 Docm2013 = 10, 47 // 48 // Summary: 49 // Microsoft Word 2007 macro enabled template format. 50 Dotm = 11, 51 // 52 // Summary: 53 // Microsoft Word 2010 macro enabled template format. 54 Dotm2010 = 12, 55 // 56 // Abstract: 57 // Microsoft Word 2013 macro enabled template format. 58 Dotm2013 = 13, 59 // 60 // Abstract: 61 // PDF format 62 PDF = 14, 63 // 64 // Abstract: 65 // Rtf format 66 Rtf = 15, 67 // 68 // Abstract: 69 // Xml file format. 70 Xml = 16, 71 // 72 // Abstract: 73 // Text file format. 74 Txt = 17, 75 // 76 // Abstract: 77 // Html format. 78 Html = 18, 79 // 80 // Abstract: 81 // XPS format 82 XPS = 19, 83 // 84 // Abstract: 85 // EPub format 86 EPub = 20, 87 // 88 // Abstract: 89 // WordprocessingML format 90 WordML = 21, 91 // 92 // Abstract: 93 // Word xml format. 94 WordXml = 22, 95 // 96 // Abstract: 97 // The document is in the Word 6 or Word 95 format. spire. doc does not currently 98 // support loading such documents. 99 DocPre97 = 23,100 // 101 // Abstract: 102 // Instructs Spire. doc to recognize the format automatically.103 Auto = 24104}
It's just some beginner's entry-level code. It looks like nothing to say.
Demo: http://git.oschina.net/liqingwen/OfficeConverter
Portal
Don't talk about "Hello Word" at the beginning. Read all poems in vain: Introduction to the Word operation component-Spire. Doc