Asp. netword

Source: Internet
Author: User

Asp. netword

This document describes how to use asp.net to preview Word documents online. Share it with you for your reference. The specific implementation method is as follows:

Implementation Method: Convert the office document to html and then browse it online in the browser

1. first introduce the office library in the com component, and then introduce the dll of word in the Assembly extension.

2. Set the embedded interoperability type of Microsoft. Office. Interop. Word to false,

3. Main Code:
Copy codeThe Code is as follows: using System;
Using System. Collections. Generic;
Using System. Linq;
Using System. Web;
Using Microsoft. Office. Core;
Using Word = Microsoft. Office. Interop. Word;
Namespace Wolfy. OfficePreview
{
Public class Office2HtmlHelper
{
/// <Summary>
/// Convert Word to Html
/// </Summary>
/// <Param name = "path"> path of the document to be converted </param>
/// <Param name = "savePath"> Save path converted to html </param>
/// <Param name = "wordFileName"> name of the file converted to html </param>
Public static void Word2Html (string path, string savePath, string wordFileName)
{
Word. ApplicationClass word = new Word. ApplicationClass ();
Type wordType = word. GetType ();
Word. Documents docs = word. Documents;
Type docsType = docs. GetType ();
Word. document doc = (Word. document) docsType. invokeMember ("Open", System. reflection. bindingFlags. invokeMethod, null, docs, new Object [] {(object) path, true, true });
Type docType = doc. GetType ();
String strSaveFileName = savePath + wordFileName + ". html ";
Object saveFileName = (object) strSaveFileName;
DocType. InvokeMember ("SaveAs", System. Reflection. BindingFlags. InvokeMethod, null, doc, new object [] {saveFileName, Word. WdSaveFormat. wdFormatFilteredHTML });
DocType. InvokeMember ("Close", System. Reflection. BindingFlags. InvokeMethod, null, doc, null );
WordType. InvokeMember ("Quit", System. Reflection. BindingFlags. InvokeMethod, null, word, null );
}
}
}
Call:
Copy codeThe Code is as follows: Office2HtmlHelper. word2Html (MapPath ("/Doc/analysis of the seo (((.doc"), MapPath ("/Html/"), "Analysis of a website's SEO Policy (external links )");

I hope this article will help you design your asp.net program.


Aspnet is similar to Baidu Library Online Preview word implementation

What is the purpose of Online Preview? If it is to prevent users from downloading, it is necessary to make it the same as Baidu Library. If you look at the web page, you can simply open it on the web page.
The Source Code cannot be provided to you, involving unit information. It can only tell you how to implement it: Use the virtual printing technology to print word into an image, convert it to swf, or convert word to pdf, and then convert the pdf to swf with pdfswf.exe. After converting to swf, use flexpager to browse. There are many materials on the Internet. You need to pay attention to this problem. The Document Style conversion is prone to major problems. We recommend that you use word to print it as an image, the disadvantage is that the file size is large but simple.

Aspnet supports online office Preview

This code can be written to convert EXCEL and WORD into HTML pages, and then show that there are a lot of code on the Internet. You can search for it.
Let's see if it can help you.
Hi.baidu.com/..466596

Www.cnblogs.com/..0.html

Related Article

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.