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>
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
기초 정리 - 1문자 (String) 숫자 (Number) 불린 (Boolean) null undefined 심볼 (Symbol) 큰정수 (BigInt) 따옴표로 묶어 있어야 함 Not-A-Number - 숫자 데이터 / 숫자로 표...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.