xlsx_composer 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eb4ddd7e108efe7858b8c3ef358a003e9a0b5d94f3be1500aacee95cd7c9c9ca
4
- data.tar.gz: ff4408f5e1a9edf7fdbcaf9eeb9d935cb6e907fdddb80e12e5310395e0fd0521
3
+ metadata.gz: e8a8b859d4ff8cf802aeb76d3e69f3393ed64663a7f849ed1b4a3792840b1970
4
+ data.tar.gz: 5ca4e3c5b0655a7c5afa666cb68a32396822606eddb18852478642a3565b24f4
5
5
  SHA512:
6
- metadata.gz: ac1e35c9a14f3d0a8ea9f6cf9f4b61b2d7cba0dee6d21885676a205f748c9d72ab735b04fb4af9bfb3b782865d2ee5b933e7b90505c1cb4b6ef28a917b09ffdc
7
- data.tar.gz: 1bf88f371a14a58e2160958fbf4518204d4c9ac724ec7460aedd4eef636edb11b66f6b3ba6e9909e1c08f1e4d405e794942b59aa57e5de2f1c0a12b0e62f77ca
6
+ metadata.gz: 697eac8a82072c7768bbf34d4d2aa4b28f9b2052e7cbdc1e88d419b100a7b34009e6530eaff8d2f37e27ce87f335aefa5f6e7bd89503d3a4d5aff97663458fb2
7
+ data.tar.gz: 72b044903424f8a6e5ec198d8966925c53612c92689b47d7d0dd4a576038bd66b27ccee4ecd0b1278ac9bdcb64db91e1c579a5f70eb18f85b9a673c27378bfae
data/CHANGELOG.md CHANGED
@@ -5,3 +5,8 @@
5
5
  - Cursor-based navigation helpers (`go_to`, `next_row`, `next_col`, etc.).
6
6
  - Built-in reusable formats and per-class custom formats via `add_format`.
7
7
  - Base composer class for worksheet templates.
8
+
9
+ ## [0.1.1] - 2026-02-06
10
+
11
+ - Fixed a missing argument in the `bold_rotation_ninety` format definition.
12
+ - Exposed `composer_worksheet` reader on `XlsxComposer::Base` to allow safe composition of multiple services writing to the same worksheet.
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # XlsxComposer
2
2
 
3
- **XlsxComposer** is a small Ruby library built on top of **WriteXLSX** that makes the creation of **complex and dynamic Excel spreadsheets** easier, more readable, and more maintainable.
3
+ **XlsxComposer** is a small Ruby library built on top of **WriteXLSX** that makes the creation of **complex and dynamic Excel spreadsheets** easier, more readable, and more maintainable through cursor-based navigation and composition.
4
4
 
5
5
  It does **not** try to replace WriteXLSX.
6
6
  Instead, it provides a higher-level abstraction focused on **navigation, composition, and formatting**, which are usually the hardest parts when spreadsheets stop being static.
@@ -118,6 +118,81 @@ end
118
118
  The same template works regardless of how many years the contract has.
119
119
 
120
120
 
121
+ ## Composing a worksheet using multiple templates
122
+
123
+ For more complex spreadsheets, it is common to split a single worksheet into
124
+ multiple logical sections, each one handled by a dedicated service or template.
125
+
126
+ XlsxComposer supports this by allowing multiple composers to write into the
127
+ same worksheet instance.
128
+
129
+ ### Orchestrating a worksheet
130
+
131
+ The main composer is responsible for creating the worksheet and coordinating
132
+ the order in which sections are written.
133
+
134
+ ```ruby
135
+ class ReportWorksheet < XlsxComposer::Base
136
+ def initialize(workbook, report)
137
+ @report = report
138
+ super(workbook: workbook)
139
+ end
140
+
141
+ def worksheet_name
142
+ "Report"
143
+ end
144
+
145
+ def run
146
+ write_header
147
+ write_summary
148
+ write_details
149
+ end
150
+
151
+ private
152
+
153
+ attr_reader :report
154
+
155
+ def write_header
156
+ HeaderSection.new(composer_worksheet, report).run
157
+ end
158
+
159
+ def write_summary
160
+ SummarySection.new(composer_worksheet, report).run
161
+ end
162
+
163
+ def write_details
164
+ DetailsSection.new(composer_worksheet, report).run
165
+ end
166
+ end
167
+ ```
168
+
169
+ ### Writing a section using an existing worksheet
170
+
171
+ Each section receives the same `XlsxComposer::Worksheet` instance and writes
172
+ to it using the same cursor-based API.
173
+
174
+ ```ruby
175
+ class HeaderSection < XlsxComposer::Base
176
+ def initialize(worksheet, report)
177
+ @report = report
178
+ super(worksheet: worksheet)
179
+ end
180
+
181
+ def run
182
+ go_to("1", "A")
183
+ write_row(["Report title"], bold)
184
+
185
+ next_row
186
+ write_row([report.title])
187
+ end
188
+
189
+ private
190
+
191
+ attr_reader :report
192
+ end
193
+ ```
194
+
195
+
121
196
  ## Formatting
122
197
 
123
198
  ### Built-in formats
@@ -27,6 +27,8 @@ module XlsxComposer
27
27
  end
28
28
  end
29
29
 
30
+ attr_reader :composer_worksheet
31
+
30
32
  def initialize(workbook: nil, worksheet: nil)
31
33
  raise ArgumentError, "Provide workbook: or worksheet:" if workbook.nil? && worksheet.nil?
32
34
 
@@ -50,8 +52,6 @@ module XlsxComposer
50
52
 
51
53
  private
52
54
 
53
- attr_reader :composer_worksheet
54
-
55
55
  def define_class_formats!
56
56
  self.class.extra_formats.each do |name, spec|
57
57
  args = spec.is_a?(Proc) ? instance_exec(&spec) : spec
@@ -10,7 +10,7 @@ module XlsxComposer
10
10
 
11
11
  def bold_percent = format(:percent_bold, bold: 1, num_format: "0%")
12
12
 
13
- def bold_rotation_ninety = format(bold: 1, rotation: 90, align: "vcenter")
13
+ def bold_rotation_ninety = format(:bold_rotation_ninety, bold: 1, rotation: 90, align: "vcenter")
14
14
 
15
15
  def thousands_mark = format(:thousands_mark, num_format: "#,##0")
16
16
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module XlsxComposer
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xlsx_composer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hugo Passos
@@ -94,5 +94,5 @@ required_rubygems_version: !ruby/object:Gem::Requirement
94
94
  requirements: []
95
95
  rubygems_version: 4.0.3
96
96
  specification_version: 4
97
- summary: A composition layer on top of WriteXLSX for dynamic spreadsheets
97
+ summary: A cursor-based composition layer on top of WriteXLSX for dynamic Excel spreadsheets
98
98
  test_files: []