Display the word2007 document directly on the Web page

Source: Internet
Author: User
Tags xslt
Example address       code download In fact, it is easy to use the method of opening a word2007 document using C # in my last talk, but I can use XSLT to format it, however, because I don't know much about the ooxml format, Only analyzed the simplest of those tags, pictures, tables, etc. currently do not know how to format, there are XSLT Master can guide, the code is as follows, add more than one XML control on the page can, hey, incredibly still can pass W3  1static string  savname = string. Empty; 2 3 4protected void button1_click (Object sender, eventargs e)  5        { 6 7             if  (Fileupload1.hasfile)  8             { 9                 if  (fileupload1.postedfile.contenttype ==  "application/ Vnd.openxmlformats-officedocument.wordprocessingml.document ") 10                 {11          &nbSp;          savname = server.mappath ("/DocToDocx/ " + fileupload1.filename);12                     fileupload1.saveas (Savname);13                     // Conditional can be installed on the server office2007 direct document conversion to 2007 of previous DOC documents 14                     //converttodocx ();15                     dispplayonweb (); 16                 }17                 else18                 {19                     response.write ("Sorry, can only upload office2007 file with docx suffix");20                 }21             }22         }2324        //void converttodocx () 25         //{26        //     object filename = savname;27        //     object missing = type.missing;28        //     object isFalse = false;29         //    object istrue = true;30        //     Msword.applicationclass wordapp = new microsoft.office.interop.word.applicationclass (); 31         //    wordapp.visible = false;32         //    msword.document worddocument  = wordapp.documents.open (33        //         ref filename,//file name 34        //         ref isfalse,//If the file has errors are prompted to convert, we are running on the server, appear also can not see, there is no hint of 35         //        ref  isfalse,//is opened as read-only, we want to convert to it, not read only 36        //         ref&nbspWhether the isfalse,//is added to the most refined open file 37        //         ref missing,38        //         ref missing,39        //         ref isfalse,40        / /        ref missing,41         //        ref missing,42         //        ref  missing,43         //        ref missing,44         //        ref  Isfalse,45        //        ref istrue,46         //        ref missing,47         //        ref isfalse,48         //        ref  missing49        //        ); 5051        //    //convert a document directly using its conversion method 52         //    worddocument.convert ();5354         //    worddocument.save ();5556         //    worddocument.close (ref missing, ref missing,  ref missing);5758        //    wordapp.quit (ref missing, ref  missing, ref missing);59        //     wordapp = null;60        //}6162         void dispplayonweb () 63        {64             //string fileName =  Savname.substring (0, savname.lastindexof ('. '))  +  ". docx";65            using  ( Package package = package.open (savname, filemode.open, fileaccess.read)) 66             {67                 uri docxuri = new uri ("/word/document.xml",  urikind.relative);68                 packagepart docxpart = package. Getpart (Docxuri);6970                 xmldocument docxxml = new xmldocument ();71                 docxxml.load (Docxpart.getstream ());7273                 xml1.document =  docxXml;7475                 package. Close ();7677                 File.delete (Savname);78            }798081         }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.