tostring not defined in

Issue #503 resolved
Zahir Koradia
created an issue

save() call breaks because of this. Need to add an import for tostring, most likely at line 37.

Comments (7)

  1. Zahir Koradia reporter

    I was essentially trying to make a copy of a large sheet, eventually editing cell contents in the loop. This is what I was running.

    input_file = args[0]
    read_wb = load_workbook(input_file, data_only = True)
    read_sheet = read_wb.worksheets[0]
    write_wb = Workbook(optimized_write = True)
    write_sheet = write_wb.create_sheet()
    sheet_num = 0
    for read_sheet in read_wb.worksheets:
        sheet_num += 1
        print "Sheet: %s" % (sheet_num)
        write_sheet = write_wb.create_sheet()           
        row_num = 0
        for row in read_sheet.rows:
            row_num += 1
            print "Row: %s" % (row_num)
            write_row = []
            for cell in row:
                write_cell = WriteOnlyCell(ws = write_sheet, value = cell.value)
                write_cell.comment = self.clone_comment(cell.comment)

    PS: Tips on providing better tests welcome :)

  2. Charlie Clark

    A unit test would call the relevant function directly (in this case _write_worksheets() but it can be quite difficult to set up the relevant parts for that.

    Can you test with 2.3 and see if the problems persist? The code there is slightly less tightly-coupled so the errors may have been fixed in it.

    If you're copying then you're probably best off editing in place and save it with a different name (if it fits in memory). Otherwise it's probably best to combine read-only and write-only modes.

  3. Zahir Koradia reporter

    Confirmed: The bug is fixed in 2.3.

    I have been editing in place so far and have now hit the memory bottleneck and hence the attempt at using dump_spreadsheet, which I see is deprecated in 2.3.

    Can you explain the difference between 2.3 and 2.4 branches?

  4. Charlie Clark

    2.3 is in beta (it has some huge changes in it) and now essentially feature complete but I wanted to start work on the next set of changes. At the moment there is little difference in the code but that will change over time.

  5. Log in to comment