https://github.com/bagilevi/docx_builder
Compose docx file (Microsoft Word 2007) based on a template XML
https://github.com/bagilevi/docx_builder
Last synced: 14 days ago
JSON representation
Compose docx file (Microsoft Word 2007) based on a template XML
- Host: GitHub
- URL: https://github.com/bagilevi/docx_builder
- Owner: bagilevi
- Created: 2010-05-28T23:49:17.000Z (almost 15 years ago)
- Default Branch: master
- Last Pushed: 2010-05-28T23:53:44.000Z (almost 15 years ago)
- Last Synced: 2025-04-09T10:27:57.890Z (about 1 month ago)
- Language: Ruby
- Homepage:
- Size: 88.9 KB
- Stars: 46
- Watchers: 1
- Forks: 6
- Open Issues: 1
-
Metadata Files:
- Readme: README.textile
Awesome Lists containing this project
README
h1. DocX Builder
_DocX Builder_ is a small utility to help you compose a docx (Microsoft Word 2007) based on a template's XML.
The @slice_template.rb@ can be used separately for non-docx applications.
The steps:
# Create a docx file with _Microsoft Word_ or _OpenOffice.org_
# Unzip it (the docx file is actually a ZIP package)
# Create your template from @word/document.xml@
# Open the template and reformat it (I used RubyMine)
# Find the parts you need to generate programmatically, and mark them up with ... , see @example/plan_report_template.xml@
# Remove the formatting (compact the XML)
# Create your builder, see @example.rb@h2. The example explained
_____head______ _________area_______________________________________ _foot_
| | | |
| | ________goal________________________| |
| | | | |
| | | _______objective____| |
| | | | | |
| (Plan Name) | (Area Name) | (Goal Name) | (Objective Name) | |
_____________________________________________________________________________
XML DOCUMENTYou can assign a text to a placeholder:
template['head']['Plan Name'] = @plan.nameOr you can replace a slice with a string, that can be composed by multiplying that slice:
template['area'] =
@plan.areas.map do |area|area_slice = template['area'].clone
area_slice['Area Name'] = area.description
area_slice['goal'] = '...'
endSee @example.rb@