[英]Display word file content in textarea using javascript
我正在嘗試在textarea中顯示word文件的內容,但它給了我這樣的輸出
vm.uploadDoc = function () {
var file = document.getElementById("docFile").files[0];
var fileReader = new FileReader();
fileReader.onload = function(fileLoadedEvent){
var textFromFileLoaded = fileLoadedEvent.target.result;
document.getElementById("inputTextToSave").value = textFromFileLoaded;
};
fileReader.readAsText(file, "UTF-8");
};
我想顯示word文件的實際內容。 我在這里做錯了什么?
您可以嘗試此代碼。
<html>
<head><title>snook.ca load document</title>
<script language="JavaScript">
<!--//
function loadworddoc(){
var doc = new ActiveXObject("Word.Application"); // creates the word object
doc.Visible=false; // doesn't display Word window
doc.Documents.Open("C:\\My Documents\\file.doc"); // specify path to document
//copy the content from my word document and throw it into my variable
var txt;
txt = doc.Documents("C:\\My Documents\\file.doc").Content;
document.all.myarea.value = txt;
doc.quit(0); // quit word (very important or you'll quickly chew up memory!)
}
//-->
</script>
</head>
<body>
<p><input type=button onClick="loadworddoc();" value="Load">
<p><textarea name=myarea cols=50 rows=5>nothing here yet</textarea>
</body>
</html>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.