Skip to content

Commit

Permalink
Documentation Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
westonganger committed Feb 12, 2019
1 parent da45e5a commit cb9edc7
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 41 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# CHANGELOG

## v1.0.1 - UNRELEASED
* [#34](https://github.com/westonganger/rodf/pull/34) - Add ability to add many rows or cells at once
* [#29](https://github.com/westonganger/rodf/pull/29) - Remove ActiveSupport dependency in favor of `dry-inflector`
* [#21](https://github.com/thiagoarrais/rodf/pull/21) - Allow more attributes for the `data_style` method
* [#19](https://github.com/westonganger/rodf/issues/19) - Changes to Date/Time handling
Expand Down
84 changes: 43 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,26 +48,61 @@ RODF::Spreadsheet.file("my-spreadsheet.ods") do |spreadsheet|
end
```

Bunches are also possible:
Adding many rows or cells at once is supported as well:

```ruby
require 'rodf'

RODF::Spreadsheet.file("my-spreadsheet.ods") do
table 'My first table from Ruby' do
row do
add_cells ['ID', 'Name']
end

add_rows([
[1, 'Alice'],
[2, { value: 'Bob', color: '#ff0000'}],
[3, 'Carol']
])

row do
add_cells ['ID', 'Name']
end
end
end
```

## Procedural style

The declarative style shown above is just syntatic sugar. A more procedural
style can also be used. Like so:

```ruby
require 'rodf'

ss = RODF::Spreadsheet.new
t = ss.table 'My first table from Ruby'
r = t.row
c = r.cell 'Hello, rODF world!'

# two methods to write to file
ss.write_to 'my-spreadsheet.ods'
# or
File.write('my-spreadsheet.ods', ss.bytes) # you can send your data in Rails over HTTP using the bytes method
end
```

Both styles can be mixed and matched at will:

```ruby
require 'rodf'

ss = RODF::Spreadsheet.new
ss.table 'My first table from Ruby' do
row do
cell 'Hello, rODF world!'
end
end

ss.write_to 'my-spreadsheet.ods'
```

Styling and formatting is also possible:

```ruby
Expand Down Expand Up @@ -126,41 +161,6 @@ RODF::Spreadsheet.file("my-spreadsheet.ods") do
end
```

## Procedural style

The declarative style shown above is just syntatic sugar. A more procedural
style can also be used. Like so:

```ruby
require 'rodf'

ss = RODF::Spreadsheet.new
t = ss.table 'My first table from Ruby'
r = t.row
c = r.cell 'Hello, rODF world!'

# two methods to write to file
ss.write_to 'my-spreadsheet.ods'
# or
File.write('my-spreadsheet.ods', ss.bytes) # you can send your data in Rails over HTTP using the bytes method
end
```

Both styles can be mixed and matched at will:

```ruby
require 'rodf'

ss = RODF::Spreadsheet.new
ss.table 'My first table from Ruby' do
row do
cell 'Hello, rODF world!'
end
end

ss.write_to 'my-spreadsheet.ods'
```

## Columns Types

Available columns types are:
Expand Down Expand Up @@ -207,6 +207,8 @@ property :table,


## Credits
Created by Thiago Arrais [(@thiagoarrais)](https://github.com/thiagoarrais)
Currently Maintained by [@westonganger](https://github.com/westonganger) for simplified ODS spreadsheet creation in the [spreadsheet_architect](https://github.com/westonganger/spreadsheet_architect) gem

Originally Created by [@thiagoarrais](https://github.com/thiagoarrais)

Created & Maintained by [Weston Ganger](https://westonganger.com) [(@westonganger)](https://github.com/westonganger) to support simplified ODS spreadsheet making in the [spreadsheet_architect](https://github.com/westonganger/spreadsheet_architect) gem

0 comments on commit cb9edc7

Please sign in to comment.