def get_rows_to_write(worksheet):
    """Return all rows, and any cells that they contain"""
    rows = {}
    for (row, col), cell in worksheet._cells.items():
        rows.setdefault(row, []).append((col, cell))
    for row_idx in worksheet.row_dimensions:
        if row_idx not in rows:
            rows[row_idx] = []
    return sorted(rows.items())
