When cells are merged, the rendered borders will be those of the first cell. If a column is made of three merged cells, the bottom border that will be seen will be the bottom border of the first cell in the column. From a user point of view, this is wrong, the bottom should be the one defined for cell 3. This function modify the border values to avoid that effect.
Note since version 0.9.7
that the function is called automatically
before rendering, user should not have to call this function anymore.
Examples
library(officer)
dat <- data.frame(a = 1:5, b = 6:10)
ft <- flextable(dat)
ft <- theme_box(ft)
ft <- merge_at(ft, i = 4:5, j = 1, part = "body")
ft <- hline(ft,
i = 5, part = "body",
border = fp_border(color = "red", width = 5)
)
print(ft)
#> <style></style>
#> <div class="tabwid"><style>.cl-5521f3d0{}.cl-551b3612{font-family:'DejaVu Sans';font-size:11pt;font-weight:bold;font-style:normal;text-decoration:none;color:rgba(0, 0, 0, 1.00);background-color:transparent;}.cl-551b361c{font-family:'DejaVu Sans';font-size:11pt;font-weight:normal;font-style:normal;text-decoration:none;color:rgba(0, 0, 0, 1.00);background-color:transparent;}.cl-551d6f7c{margin:0;text-align:right;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);padding-bottom:5pt;padding-top:5pt;padding-left:5pt;padding-right:5pt;line-height: 1;background-color:transparent;}.cl-551d88ea{width:0.75in;background-color:transparent;vertical-align: middle;border-bottom: 0.75pt solid rgba(102, 102, 102, 1.00);border-top: 0.75pt solid rgba(102, 102, 102, 1.00);border-left: 0.75pt solid rgba(102, 102, 102, 1.00);border-right: 0.75pt solid rgba(102, 102, 102, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-551d88f4{width:0.75in;background-color:transparent;vertical-align: middle;border-bottom: 0.75pt solid rgba(102, 102, 102, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0.75pt solid rgba(102, 102, 102, 1.00);border-right: 0.75pt solid rgba(102, 102, 102, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-551d88fe{width:0.75in;background-color:transparent;vertical-align: middle;border-bottom: 5pt solid rgba(255, 0, 0, 1.00);border-top: 0.75pt solid rgba(102, 102, 102, 1.00);border-left: 0.75pt solid rgba(102, 102, 102, 1.00);border-right: 0.75pt solid rgba(102, 102, 102, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}</style><table data-quarto-disable-processing='true' class='cl-5521f3d0'><thead><tr style="overflow-wrap:break-word;"><th class="cl-551d88ea"><p class="cl-551d6f7c"><span class="cl-551b3612">a</span></p></th><th class="cl-551d88ea"><p class="cl-551d6f7c"><span class="cl-551b3612">b</span></p></th></tr></thead><tbody><tr style="overflow-wrap:break-word;"><td class="cl-551d88f4"><p class="cl-551d6f7c"><span class="cl-551b361c">1</span></p></td><td class="cl-551d88f4"><p class="cl-551d6f7c"><span class="cl-551b361c">6</span></p></td></tr><tr style="overflow-wrap:break-word;"><td class="cl-551d88ea"><p class="cl-551d6f7c"><span class="cl-551b361c">2</span></p></td><td class="cl-551d88ea"><p class="cl-551d6f7c"><span class="cl-551b361c">7</span></p></td></tr><tr style="overflow-wrap:break-word;"><td class="cl-551d88ea"><p class="cl-551d6f7c"><span class="cl-551b361c">3</span></p></td><td class="cl-551d88ea"><p class="cl-551d6f7c"><span class="cl-551b361c">8</span></p></td></tr><tr style="overflow-wrap:break-word;"><td rowspan="2"class="cl-551d88fe"><p class="cl-551d6f7c"><span class="cl-551b361c">4</span></p></td><td class="cl-551d88ea"><p class="cl-551d6f7c"><span class="cl-551b361c">9</span></p></td></tr><tr style="overflow-wrap:break-word;"><td class="cl-551d88fe"><p class="cl-551d6f7c"><span class="cl-551b361c">10</span></p></td></tr></tbody></table></div>
ft <- fix_border_issues(ft)
print(ft)
#> <style></style>
#> <div class="tabwid"><style>.cl-5529d76c{}.cl-5524a5f8{font-family:'DejaVu Sans';font-size:11pt;font-weight:bold;font-style:normal;text-decoration:none;color:rgba(0, 0, 0, 1.00);background-color:transparent;}.cl-5524a602{font-family:'DejaVu Sans';font-size:11pt;font-weight:normal;font-style:normal;text-decoration:none;color:rgba(0, 0, 0, 1.00);background-color:transparent;}.cl-5526ca9a{margin:0;text-align:right;border-bottom: 0 solid rgba(0, 0, 0, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0 solid rgba(0, 0, 0, 1.00);border-right: 0 solid rgba(0, 0, 0, 1.00);padding-bottom:5pt;padding-top:5pt;padding-left:5pt;padding-right:5pt;line-height: 1;background-color:transparent;}.cl-5526e35e{width:0.75in;background-color:transparent;vertical-align: middle;border-bottom: 0.75pt solid rgba(102, 102, 102, 1.00);border-top: 0.75pt solid rgba(102, 102, 102, 1.00);border-left: 0.75pt solid rgba(102, 102, 102, 1.00);border-right: 0.75pt solid rgba(102, 102, 102, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-5526e368{width:0.75in;background-color:transparent;vertical-align: middle;border-bottom: 0.75pt solid rgba(102, 102, 102, 1.00);border-top: 0 solid rgba(0, 0, 0, 1.00);border-left: 0.75pt solid rgba(102, 102, 102, 1.00);border-right: 0.75pt solid rgba(102, 102, 102, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}.cl-5526e372{width:0.75in;background-color:transparent;vertical-align: middle;border-bottom: 5pt solid rgba(255, 0, 0, 1.00);border-top: 0.75pt solid rgba(102, 102, 102, 1.00);border-left: 0.75pt solid rgba(102, 102, 102, 1.00);border-right: 0.75pt solid rgba(102, 102, 102, 1.00);margin-bottom:0;margin-top:0;margin-left:0;margin-right:0;}</style><table data-quarto-disable-processing='true' class='cl-5529d76c'><thead><tr style="overflow-wrap:break-word;"><th class="cl-5526e35e"><p class="cl-5526ca9a"><span class="cl-5524a5f8">a</span></p></th><th class="cl-5526e35e"><p class="cl-5526ca9a"><span class="cl-5524a5f8">b</span></p></th></tr></thead><tbody><tr style="overflow-wrap:break-word;"><td class="cl-5526e368"><p class="cl-5526ca9a"><span class="cl-5524a602">1</span></p></td><td class="cl-5526e368"><p class="cl-5526ca9a"><span class="cl-5524a602">6</span></p></td></tr><tr style="overflow-wrap:break-word;"><td class="cl-5526e35e"><p class="cl-5526ca9a"><span class="cl-5524a602">2</span></p></td><td class="cl-5526e35e"><p class="cl-5526ca9a"><span class="cl-5524a602">7</span></p></td></tr><tr style="overflow-wrap:break-word;"><td class="cl-5526e35e"><p class="cl-5526ca9a"><span class="cl-5524a602">3</span></p></td><td class="cl-5526e35e"><p class="cl-5526ca9a"><span class="cl-5524a602">8</span></p></td></tr><tr style="overflow-wrap:break-word;"><td rowspan="2"class="cl-5526e372"><p class="cl-5526ca9a"><span class="cl-5524a602">4</span></p></td><td class="cl-5526e35e"><p class="cl-5526ca9a"><span class="cl-5524a602">9</span></p></td></tr><tr style="overflow-wrap:break-word;"><td class="cl-5526e372"><p class="cl-5526ca9a"><span class="cl-5524a602">10</span></p></td></tr></tbody></table></div>