asp.net 개발 JS 로 워드 읽 기

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="js  word.aspx.cs" Inherits="js  word" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">

    <script language='javascript'>
        //  word      C:\\ 
        var os__localPath = "C:\\";
        //      
           var os__localFile = "defaultFileWord.htm";
           var os__xmlDom = new ActiveXObject("MSXML2.DOMDocument");
           var os__xmlFSO ;

           //          (             ).
           function os_SaveToLocal()
           {
            var _saveAs = "";
            if(arguments.length > 0)
             _saveAs = arguments[0] + "";
            else
             _saveAs = os__localFile;
            
            try
            {       
             if(os__xmlFSO == null)
              os__xmlFSO = new ActiveXObject("Scripting.FileSystemObject");  
          
            }
            catch(e){window.alert(e);}
           } 
          
           //Word   Html  
           function WorcChangeHtml()
           {
                var os_xmlFSO;
                //        
                var objUpFile = document.getElementById("updFile");
                //     Word       
                var UpFileValue = objUpFile.value;
                if(os__xmlFSO == null)
                  os__xmlFSO = new ActiveXObject("Scripting.FileSystemObject");     
                
                try
                {
                     if(UpFileValue == "")
                     {
                          alert('      Word  ');
                          objUpFile.focus();
                     }
                     else if(UpFileValue.indexOf(".doc") == -1)
                     {
                          alert('      Word   \r
Word '); objUpFile.focus(); } else if(!os__xmlFSO.FileExists(objUpFile.value)) { alert(' Word '); objUpFile.focus(); } else { var wdFormatHTML = 8; var objWord = new ActiveXObject("Word.Application"); objWord.Application.Visible = false; var objDoc = objWord.Documents.Open(UpFileValue); objDoc.SaveAs(os__localPath+os__localFile, wdFormatHTML); UpFileValue = ""; objDoc.Close(); objWord.Quit(); var GetHtml = GetLine(); var iBeginIndex = GetHtml.indexOf("<body"); var iEndIndex = GetHtml.lastIndexOf("</body>"); GetHtml = GetHtml.substring(iBeginIndex,iEndIndex+7).replace("<body","<div"); GetHtml = GetHtml.replace("</body>","</div>"); GetHtml = GetHtml.replace("lang=ZH-CN",""); GetHtml = GetHtml.replace("lang=EN-US",""); GetHtml = GetHtml.replace("style='mso-spacerun:yes'",""); GetHtml = GetHtml.replace("class=MsoNormal",""); var vTxtIdea= document.getElementById("txtIdea"); document.write(GetHtml) } } catch(e) { window.alert(e); } } // function GetLine() { var fso, txtfile, strValue; var ForReading = 1, ForWriting = 2; fso = new ActiveXObject("Scripting.FileSystemObject"); txtfile = fso.OpenTextFile(os__localPath+os__localFile, ForReading); while(!txtfile.AtEndOfStream) { strValue = strValue + txtfile.ReadLine(); } txtfile.Close(); return(strValue); } </script> <title> </title> </head> <body> <form id="form1" runat="server"> <input id="updFile" type="file" style="border-right: 1px solid; border-top: 1px solid; border-left: 1px solid; width: 77.46%; border-bottom: 1px solid; height: 26px" size="71"> <input style="border-right: #999999 1px solid; border-top: #999999 1px solid; font-size: 15pt; border-left: #999999 1px solid; width: 103px; border-bottom: #999999 1px solid; height: 28px" onclick="WorcChangeHtml()" runat="server" id="btnUpLoad" type="submit" value=" " name="btnUpLoad"> <textarea style="width: 88%; height: 412px" id="txtIdea" runat="server"></textarea> <br /> <br /> </form> </body> </html>

좋은 웹페이지 즐겨찾기