append method breaks final xlsx file

Issue #1345 resolved
Oleksandr Romanets created an issue

from openpyxl import load_workbook

import os
basedir = '/home/user/projects/test_openpyxl'

template = os.path.join(basedir, 'test.xlsx')
wb_t = load_workbook(template)
wall_sheet = wb_t[u'2.1']
r = [1, 2, 3, 4, 5]

wall_sheet.append(r), 'testfileafterrun.xlsx'))

When updating from version 2.5.12 to 3.0.0 the code above started to break the final Excel file.

In Worksheet.append() the last row of sheet is identified as 1048577, however indicated sheet has only 5 rows.

Comments (5)

  1. CharlieC

    Well, unfortunately the file contains rows up to the maximum. `<x:row r="1048576" customFormat="false" ht="12.8" hidden="false" customHeight="true" outlineLevel="0" collapsed="false" />`

    But I can’t reproduce the error here.

  2. Oleksandr Romanets reporter

    Do you mean that after opening initial file, appending to the sheet ‘2.1’ a list of digits and saving as a new file, the latest file is opened via MS Office or LibreOffice correctly and the digits, supposed to be inserted to the sheet ‘2.1’, are in place of row 6 ?

  3. Oleksandr Romanets reporter

    Yep, it shall probably help. However the bug is how it (s._current_row) is identified.

  4. Log in to comment