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

[Python] Transfer a table with double cells from excel to pdf

Discussão em 'Python' iniciado por Stack, Setembro 28, 2024 às 14:13.

  1. Stack

    Stack Membro Participativo

    Here's the script itself:

    def merge_cells(section):
    merged_section = [section[0], section[1]] # Сохраняем заголовки
    for i in range(2, len(section), 2):
    if i + 1 < len(section):
    main_row = section
    secondary_row = section[i + 1]
    merged_row = []
    for j in range(len(main_row)):
    if j >= 5 and secondary_row[j] == '':
    merged_row.append(main_row[j])
    else:
    merged_row.append(f"{main_row[j]}\n{secondary_row[j]}".strip())
    merged_section.append(merged_row)
    return merged_section


    But it combines cells from column 1 to 12, and I need to combine cells from columns 6 to 11 in the PDF.

    Here is the list itself:

    section = [
    ['DO 33-48(=24V) signal distribution', '', '', '', '', '', '', '', '', '', ''],
    ['Cable number', 'Wire number', 'Terminal/device number', 'Terminal number', 'Circuit', 'Matching device', 'Parameter type', 'Signal name', 'Tag', 'Logical channel number', 'Module number Channel number', 'Note'],
    ['', '', '3XT6', '1', '3. 6.1', '24V relay', 'SC', 'Enable', 'B1-10-1_ND_On', 'DO:33', 'A20:TU1', ''],
    ['', '', '3XT6', '2', '3.6.2', '', '', '', '', '', ''],
    ['', '', '3XT6', '3', '3. 6.3', '24V relay', 'SC', 'Disable', 'B1-10-1_ND_Off', 'DO:34', 'A20:TU2', ''],
    ['', '', '3XT6', '4', '3.6.4', '', '', '', '', '', ''],
    ['', '', '3XT6', '5', '3. 6.5', '24V relay', 'SC', 'Enable', 'B1-31_ND_On', 'DO:35', 'A20:TU3', ''],
    ['', '', '3XT6', '6', '3.6.6', '', '', '', '', '', ''],
    ['', '', '3XT6', '7', '3.6. 7', '24V relay', 'SC', 'Disable', 'B1-31_ND_Off', 'DO:36', 'A20:TU4', ''],
    ['', '', '3XT6', '8', '3.6. 8', '', '', '', '', '', ''],
    ['', '', '3XT6', '9', '3.6.9', '24V relay', 'SC', 'On', 'B1-13 ND On', 'DO:37', 'A20:TU5', ''],
    ['', '', '3XT6', '10', '3. 6.10', '', '', '', '', '', ''],
    ['', '', '3XT6', '11', '3.6.11', '24V Relay', 'SC', 'Off', 'B1-13 ND Off', 'DO:38', 'A20:TU6', ''],
    ['', '', '3XT6', '12', '3.6. 12', '', '', '', '', '', ''],
    ['', '', '3XT6', '13', '3.6. 13', '24V relay', 'SC', 'Enable', 'B2-10-2_ND_On', 'DO:39', 'A20:TU7', ''],
    ['', '', '3XT6', '14', '3.6.14', '', '', '', '', '', '']
    ]


    Tried different options, but nothing worked.

    Continue reading...

Compartilhe esta Página