Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including exportword with all npm packages installed. Try it out:

var exportword = require("exportword")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

exportword v1.0.2

> exportfile is a fast and small JavaScript library. ## feature * the library can export a word which includes normal words,images and chars that building with [echarts](https://www.echartsjs.com/zh/api.html#echarts) ## params (exportElement, exportFileName, StringStyle,fileParams) #### exportElement * outermost element of all elements that you want to export #### exportFileName * the filename of export file * [the better choice of the file extension is doc](https://github.com/metanorma/html2doc/wiki/Why-not-docx%3F) ### StringStyle * the style must be string ``` `#main,#main1{ height: 200px; width:200px } .list{ background: blue; padding:10px } .img{ padding: 50px; } .list .page{ background: yellow; padding: 5px; height: 20px; }` title: the property of margin will not word in style, but you can replace with text-align ``` #### fileParams * the fileParams contain two params (margin,orientation) ``` margin: descibe the margin of exported word top: number (default: 1440, i.e. 2.54 cm) right: number (default: 1440) bottom: number (default: 1440) left: number (default: 1440) header: number (default: 720) footer: number (default: 720) gutter: number (default: 0) orientation: string (default: portrait) describe direction of words ``` ## use ``` For example: import exportFile from 'exportfile' exportFile({exportElement:'#id', exportFileName:'word.doc', StringStyle,fileParams:{margin:{top:50}}}) there is a samle in the project list: samle.html ``` ## at last (the most important) * the library is based on the [html-docx-js](https://github.com/evidenceprime/html-docx-js)

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free