davidgohel / ReporteRs

Note that ReporteRs has been removed from CRAN the 16th of July 2018 and is not maintained anymore. please migrate to officer.
244 stars 44 forks source link

Question: How to replace FlexTables ? #154

Closed behrica closed 7 years ago

behrica commented 8 years ago

I understood from here: http://davidgohel.github.io/ReporteRs/articles/bookmarks.html

that addFlexTable() cannot replace content of a bookmark.

But it is not clear to me, if I can do something else to achieve this.

I read about 'deleteBookmarkNextContent', but it is a bit danegrous, if in certain situations the content after the bookmarks is not what I want to delete.

Can I use addParagraph somewhoe to replace a full paragraph (which then contains a Flextable) ?

davidgohel commented 8 years ago

Hi,

I will try to make a better vignette soon with more examples.

maschere commented 7 years ago

Hi,

I am facing the same challenge. I need to update captioned figures and tables (identified by a bookmark) in a large word document. For figures this works flawlessly with pot and pot_img and addParagraph. Maybe a pot_flextable function might be another way to go about updating FlexTables? Or are there other plans to support this task?

davidgohel commented 7 years ago

Hi

From here, it says:

When used with addFlexTable, content (table) will be added after the paragraph containing the bookmark.

You can use deleteBookmarkNextContent(bookmark = 'bookmark_id') to delete the content after a bookmark (a table in your case), then using addFlexTable(..., bookmark = 'bookmark_id') and the FlexTable will be added.

The replacement is a two step process:

  1. Delete the content that need to be replaced
  2. Insert the FlexTable (after the paragraph containing the bookmark)