FramesΒΆ

Frames are vertical containers in which content is being aligned according to their height. That is, within Frames:

  • Variables do not overwrite existing cell values as they do without Frames.

  • Table formatting is applied to all data rows.

To use Frames, insert <frame> into row 1 of your Excel template wherever you want a new dyanmic column to start. Row 1 will be removed automatically when creating the report. Frames go from one <frame> to the next <frame> or the right border of the used range.

How Frames behave is best demonstrated with an example: The following screenshot defines two frames. The first one goes from column A to column E and the second one goes from column F to column I.

You can define and format tables by formatting exactly

  • one header and

  • one data row

as shown in the screenshot:

../_images/frame_template.png

Running the following code:

from xlwings.reports import create_report
import pandas as pd

df1 = pd.DataFrame([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
df2 = pd.DataFrame([[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15]])

data = dict(df1=df1, df2=df2)

create_report('my_template.xlsx',
              'my_report.xlsx',
              **data)

will generate this report:

../_images/frame_report.png