https://github.com/mjc-gh/simple-xls
Builds HTML tables thus allowing you to easily import data into Excel and the like.
https://github.com/mjc-gh/simple-xls
Last synced: 7 months ago
JSON representation
Builds HTML tables thus allowing you to easily import data into Excel and the like.
- Host: GitHub
- URL: https://github.com/mjc-gh/simple-xls
- Owner: mjc-gh
- Created: 2010-12-05T02:32:01.000Z (almost 15 years ago)
- Default Branch: master
- Last Pushed: 2012-02-29T16:34:41.000Z (over 13 years ago)
- Last Synced: 2025-03-15T08:33:34.723Z (7 months ago)
- Language: Ruby
- Homepage:
- Size: 102 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.markdown
Awesome Lists containing this project
README
# Simple XLS
This gem builds HTML tables which makes easy import data into Excel, OpenOffice and others applications of this nature. The HTML can also be used to respond to web requests as well.
## Example
xls = SimpleXLS.new ['header1','header2','header3']
xls.push [1,2,3]
xls.push [4,5]
xls.push [6,7,8]File.open('output.xls', 'w+') { |f| f.puts xls }
### Add Collectionxls = SimpleXLS.new ['a','b','c']
xls.add([[1,2,3], [4,5,6]])
xls.add([ { :a => 1, :b => 2, :c => 3}, { :a => 4, :b => 5, :c => 6}])
The `add` method will accept an array of arrays or an array of hashes. When hashes are used, it will attempt to extract the values from the `Hash` using the header values as keys (first trying as a `String` then again as a `Symbol`). Since the headers are enumerated, order is preseved.