1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Python] The class FPDF of library fpdf has no attribute 'table'

Discussão em 'Python' iniciado por Stack, Outubro 25, 2024 às 12:32.

  1. Stack

    Stack Membro Participativo

    I'm trying to create a table in Python using the FPDF library. The following code gives me an error: 'FPDF' object has no attribute 'table'. I don't know how to solve it. I will be grateful for your help.

    Code:

    import fpdf
    from fpdf import FPDF

    pdf = FPDF()

    TABLE_Data = (('Etap' , 'Czas rozpoczecia' , 'Czas trwania'),
    ('Wychladzanie pieca' , 'IDLE_start' , ''),
    ('NIF temp = 1200C' , 'IDLE_step1' , 'IDLE_time_step1'),
    ('Przycisk DROP' , 'IDLE_step2' , 'IDLE_time_step2'),
    ('DROP' , 'IDLE_step3' , 'IDLE_time_step3'),
    ('Preciki - START' , 'IDLE_step4' , 'IDLE_time_step4'),
    ('Preciki - STOP' , 'IDLE_step5' , 'IDLE_time_step5'),
    ('V = 15 m/min' , 'IDLE_step6' , 'IDLE_time_step6'),
    ('V = 50 m/min' , 'IDLE_step7' , 'IDLE_time_step7'),
    ('Srednica w tolerancji' , 'IDLE_step8' , 'IDLE_time_good'),
    ('Predkosc robocza' , 'IDLE_end' , 'IDLE_time_end')
    )
    pdf.add_page()

    pdf.set_font('Helvetica', 'b', 18)

    with pdf.table() as table:
    for data_row in TABLE_Data:
    row = table.row()
    for datum in data_row:
    row.cell(datum)


    pdf.output('table.pdf')


    I was looking for answers on the forums. The only information was regarding: pdf.add_page() and pdf.set_font(), but both options are declared in my example.

    Continue reading...

Compartilhe esta Página