我正在尝试在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文件的实际内容。我在这里做错了什么?
答案 0 :(得分:0)
你可以尝试这段代码。
<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>