Skip to content
This repository has been archived by the owner on May 4, 2020. It is now read-only.

Commit

Permalink
Merge pull request #77 from lelit/master
Browse files Browse the repository at this point in the history
Fix #76: support Python 3, returning a bytes value instead of a str one
  • Loading branch information
cjw296 committed Feb 17, 2016
2 parents b36b8dd + 276e033 commit 44f5acc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
16 changes: 14 additions & 2 deletions tests/test_biff_records.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
# coding:utf-8

from io import BytesIO
import unittest

from xlwt import BIFFRecords
import xlwt

class TestSharedStringTable(unittest.TestCase):
def test_shared_string_table(self):
expected_result = b'\xfc\x00\x11\x00\x01\x00\x00\x00\x01\x00\x00\x00\x03\x00\x01\x1e\x04;\x04O\x04'
string_record = BIFFRecords.SharedStringTable(encoding='cp1251')
string_record = xlwt.BIFFRecords.SharedStringTable(encoding='cp1251')
string_record.add_str(u'Оля')
self.assertEqual(expected_result, string_record.get_biff_record())

class TestIntersheetsRef(unittest.TestCase):
def test_intersheets_ref(self):
book = xlwt.Workbook()
sheet_a = book.add_sheet('A')
sheet_a.write(0, 0, 'A1')
sheet_a.write(0, 1, 'A2')
sheet_b = book.add_sheet('B')
sheet_b.write(0, 0, xlwt.Formula("'A'!$A$1&'A'!$A$2"))
out = BytesIO()
book.save(out)
2 changes: 1 addition & 1 deletion xlwt/BIFFRecords.py
Original file line number Diff line number Diff line change
Expand Up @@ -2383,7 +2383,7 @@ def get(self):
header = pack("<HHH", self._REC_ID, 6 * krefs + 2, nrefs)
res.append(header)
res.extend([pack("<HHH", *r) for r in chunk])
return ''.join(res)
return b''.join(res)

class SupBookRecord(BiffRecord):
"""
Expand Down

0 comments on commit 44f5acc

Please sign in to comment.