admin管理员组文章数量:1332361
I have my students submit their Microsoft Word assignments to a ColdFusion 10 server. I'd like to write an error checker to check for mon mistakes like not having a page number in the header, the name of the school on the title page, their name on the title page, etc. I specify a lot of APA rules. Example: The phrase "Running head:" must be in the header section of page 1 but not the rest of the paper. I assign a point value to each rule.
Ideally, this error checker would run when they submit the assignment and tell them immediately. That might require using
parser.parseFromString(str, "text/xml");
But as an alternate, if I could write a program that I run to check for errors, that could help automate my grading. In other words, using Microsoft Access or Visual Studio. But I don't want to do that because then I'd have to have Visual Studio on the server and I don't think that's going to be feasible.
The last option would be to download all the papers off the server and run a program locally, which is one step better than grading everything manually.
I have my students submit their Microsoft Word assignments to a ColdFusion 10 server. I'd like to write an error checker to check for mon mistakes like not having a page number in the header, the name of the school on the title page, their name on the title page, etc. I specify a lot of APA rules. Example: The phrase "Running head:" must be in the header section of page 1 but not the rest of the paper. I assign a point value to each rule.
Ideally, this error checker would run when they submit the assignment and tell them immediately. That might require using
parser.parseFromString(str, "text/xml");
But as an alternate, if I could write a program that I run to check for errors, that could help automate my grading. In other words, using Microsoft Access or Visual Studio. But I don't want to do that because then I'd have to have Visual Studio on the server and I don't think that's going to be feasible.
The last option would be to download all the papers off the server and run a program locally, which is one step better than grading everything manually.
Share Improve this question edited Feb 2, 2013 at 0:46 Peter Boughton 112k32 gold badges123 silver badges177 bronze badges asked Feb 1, 2013 at 21:27 Phillip SennPhillip Senn 47.7k91 gold badges261 silver badges378 bronze badges 12- 1 What is the question here? – Aaron Kurtzhals Commented Feb 1, 2013 at 21:29
- 5 Phillip - NO worries! Many people, like myself, e here for assistance; however, there are some that live on judgements no matter where you go! Ignore the hecklers. ;) This is why you are allowed to mark ments as Offensive/Not Constructive (just hover to the left of the ment and you will find the icon.) – Alberto Ponte Commented Feb 1, 2013 at 21:34
- 1 Lol how is this "lazy"? I'd called it efficient – Ian Commented Feb 1, 2013 at 21:43
- 1 I seriously question the language prehension powers of the people that closed this question, and whether they are fit to do the jobs they have appointed themselves to do. The question is very clear, which is evidenced by the fact IT HAD ALREADY BEEN ANSWERED by the time the close vote had been made. Voting to reopen. – Adam Cameron Commented Feb 2, 2013 at 8:45
- 2 POI is great for Excel, but the Word package is less mature. From what you have described, you are probably better off with VBA (given that is feasible in your case). – Leigh Commented Feb 6, 2013 at 23:08
3 Answers
Reset to default 2I did this a few years back using VBA, refer to this article. Here is an excerpt that parses each paragraph of a document:
Public Sub ParseLines()
Dim singleLine As Paragraph
Dim lineText As String
For Each singleLine In ActiveDocument.Paragraphs
lineText = singleLine.Range.Text
'// parse the text here...
Next singleLine
End Sub
I know you already found an answer, but I thought Id throw in Apache POI to extract the data from the word document. I know you can get the headers of the pages like so
fis = createObject("java","java.io.FileInputStream").init(ExpandPath('./mydoc.docx'));
document = createObject("java","org.apache.poi.xwpf.usermodel.XWPFDocument").init(fis);
fis.close();
policy = document.getHeaderFooterPolicy();
firstHeader = policy.getFirstPageHeader().getText();
defaultHeader = policy.getDefaultHeader().getText();
I know this is only the header portion of your request. There is a way to get the even and odd page headers too looking at the documentation.
APACHE POI
Try out:
http://docxextractor.riaforge/
I extracts all clear and some of the formatting
Disclaimer: I wrote it
本文标签: javascriptProgrammatically reading a Microsoft Word documentStack Overflow
版权声明:本文标题:javascript - Programmatically reading a Microsoft Word document - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742319357a2452469.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论