Generate a Word document in the client with JavaScript or VBScript

zhaozj2021-02-16  56

Hey! It's hard to get away from Microsoft's days!

The younger brother is now doing a project, although you will not use Java, but because of the people's hand is not enough, I and a Java programmer, two people ran to XXX from the head. Because it is an XXX system, the user hates Microsoft's stuff (except for office, huh, huh ... As for why! Maybe it is too good for Microsoft's Dongdong, people think that the developer is too low!).

Because the user requests the system to generate the function of the system, I am arranged to be responsible for the work of generating a Word document with Java (because is novice, there is no experience! It seems to be very simple), 晃 晃, 是 是No found a stuff (绝 绝), at this time, I met ITSYH brother on this BBS, ITSYH brother told me at http://www.itpub.net/ I saw the post of the Java generated document, so I called! I fly, I really found the content of this (unfortunately! I am happy), I have a boss to use Jakarta's POI to solve the problem of generating a Word document with Java in the server, so I just Flying to http://jakarta.apache.org/poi/index.html, the result is really ok! I have been busy with one, so I started watching POI documents, I see it! Look! Finally, I was stupid.

Because the HSSF module function of Excel is very good in POI, the Word's HDF feature is still in the development process! Below this text jakarta confusion brought me (We are looking for developers !!! If you are interested in helping with HDF familiarize yourself with the source code and just start coding. Make sure you read the guidelines for getting involved) , Let's finally give up this Poi, so I thought it would be so complicated in the client generation!

I finally took one night, under the enthusiastic teachings of colleagues, I finally completed the code work that generated the Word document with JavaScript or VBScript (Hey! Because we didn't use Word, and a big loss. ! Huh, it is equal to studying Word a night), although there is a problem with the browser security warning, but it is not bad.

Note: Clients need offices

Below I will give you a reference, I hope everyone can use it later.

For Word documents, the features I use the text-type form area, all regions are defined in the future, that is, the name I want to replace. (Replacement length can be done!)

VBScript

Code: