-
Notifications
You must be signed in to change notification settings - Fork 268
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tables with headings and filled cells - ignore header lines for background fill of data rows #1111
Comments
Hi @4lexRed, |
Hi @andersonhc Yet, I did recon that the problems basic question is: In my personal opinion (aka my formatting style) heading-rows do not count. [had a quick look into Excel's table formats templates and it might be that I am the only one who thinks there should be a non filled row after the heading] I suggested the keyword cell_fill_consider_heading_lines with a default setting to False, Yet, introducing three So choose whichever way you recon better. |
Hi @4lexRed @Lucas-C , just stumbeld on this enhancement request, as I am having same problem. Want to fill the second data row, as the header line is also filled. Especially in case of just two data lines, this looks confusing with the current behaviour. Thanks for all the work in this great library! |
Hey @kaufmann-jan Are you interested in submitting a PR adding the options on the |
Hi @andersonhc , yes I could do this |
I opened a quick PR that would allow ANY custom cell-filling logic: #1117 Maybe that's enough to solve your issues? |
Hi 😊 Without feedback I'm planning on merging this PR in a few days. |
Hi @Lucas-C ,
|
Thank you for the feedback @kaufmann-jan! I added two new enum values
What do you think? |
Yes, I agree on both naming and behaviour! |
Alright, thanks! PR #1117 is now merged! Closing this issue now |
Intent
If I have a table with a header-styling and filled cells via
cell_fill_mode="ROWS"
.The first line of the data rows is filled with color. The second line of the data rows is not filled. Third line is filled again (and so on)
I want this first data line to be without filling - the second row filled - the third row not filled (and so on).
See pictures at the end of the text for examples
Describe the solution you'd like
Add a keyword to
pdf.table()
function called cell_fill_consider_heading_lines with the possible options True or False.If true, the amount of heading rows gets subtracted from the temporary row index number.
Possible Code Changes
in the file
table.py
change the line 351to
Additional context
If the table get the keyword
cell_fill_mode="ROWS"
, then the classTableCellFillMode
methodshould_fill_cell
is called to see if the cell should be filled or not.The method only has a look if the row-index is even or odd and fills the cell if it is odd (row-index % 2).
Current behavior:
We have 1 heading line. The heading line number is 0 -> the first data line has the number 1 -> is odd and the cell gets filled.
We have 2 heading lines. The heading lines numbers are 0 and 1 -> the first data line has the number 2 -> is even and the cell does not get filled.
We have 3 heading line(s). The heading lines numbers are 0, 1 and 2 -> the first data line has the number 3 -> is odd and the cell gets filled.
To get my wanted behavior it is crucial that the row-index number depends on the value of the keyword
num_heading_rows
.Wanted behavior:
We have 1 heading line. The heading line number is irrelevant -> the first data line has the number 0 -> is "even" and does not get filled.
We have 2 heading lines. The heading line numbers are irrelevant -> the first data line has the number 0 -> is "even" and does not get filled.
We have 3 heading line(s). The heading line numbers are irrelevant -> the first data line has the number 0 -> is "even" and does not get filled.
PS: I'd render a pull request with an , but I am too new to github and have no clue how to do that
Screenshots of my pdf file - current look and wanted look (with the fix)


The text was updated successfully, but these errors were encountered: