We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e78cecf commit 21e8dadCopy full SHA for 21e8dad
README.md
@@ -134,6 +134,31 @@ end
134
doc.save('example-edited.docx')
135
```
136
137
+### Writing to tables
138
+
139
+``` ruby
140
+require 'docx'
141
142
+# Create a Docx::Document object for our existing docx file
143
+doc = Docx::Document.open('tables.docx')
144
145
+# Copy row of a table and then substitute text in a cell
146
+doc.tables.first.rows.first.then do |row|
147
+ new_row = row.copy
148
+ new_row.insert_after(row)
149
150
+ row.cells.first.then do |c|
151
+ c.paragraphs.each do |p|
152
+ p.each_text_run do |tr|
153
+ tr.substitute('_table_placeholder_', 'replacement value')
154
+ end
155
156
157
+end
158
159
+doc.save('tables-edited.docx')
160
+```
161
162
### Advanced
163
164
``` ruby
0 commit comments