GUIDE.md in rspreadsheet-0.0.1 vs GUIDE.md in rspreadsheet-0.0.2
- old
+ new
@@ -1,26 +1,37 @@
-Examplex of more advanced syntax follows:
+## Examples of advanced syntax
+Examples of more advanced syntax follows
+
```ruby
require 'rspreadsheet'
-book = Rspreadsheet::Workbook.new
-sheet book.create_worksheet 'Top icecreams'
+book = Rspreadsheet.new
+sheet = book.create_worksheet 'Top icecreams'
sheet[0,0] = 'My top 5'
-sheet[0,0].format.size = 15
-sheet[0,0].format.weight = bold
-p sheet[0,0].format.bold # => true
+p sheet[0,0].class # => String
+p sheet[0,0] # => "My top 5"
-# These are all the same cells
+# These are all the same values - alternative syntax
p sheet.A1
-p sheet.row(0).cell(0)
-p sheet.rows[0][0]
-p sheet.rows[0].cells[0]
-p sheet.cells[0,0]
-p sheet.cell(0,0)
+p sheet[0,0]
+p sheet.cells[0,0].value
+p sheet.rows[0].cells[0].value
+# How to inspect/manipulate the Cell object
+sheet.cells[0,0] # => Rspreadsheet::Cell
+sheet.cells[0,0].format
+sheet.cells[0,0].format.size = 15
+sheet.cells[0,0].format.weight = bold
+p sheet.cells[0,0].format.bold? # => true
+
+# There are the same assigmenents
+sheet.A1 = value
+sheet[0,0]= value
+sheet.cells[0,0].value = value
+
p sheet.A1.class # => Rspreadsheet::Cell
# build the top ten list
(1..5).each { |i| sheet[i,0] = i }
sheet.columns[0].format.bold = true
@@ -29,5 +40,10 @@
sheet.columns[1][1..3].format.color = :red
book.save
```
+## Conventions
+ * with numeric coordinates row always comes before col as in [row,col]
+ * with alphanumerical col always comes before row as in F12
+ * Shorter syntax worksheet[x,y] returns value, longer syntax worksheet.cells[x,y] return cell objects. This allows to work conviniently with values using short syntax and access the cell object if needed (for formatting for example).
+