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 #102 from jdufresne/line-endings
Browse files Browse the repository at this point in the history
Convert all files to conventional Unix line endings
  • Loading branch information
cjw296 committed Aug 22, 2017
2 parents d811e09 + dddb93d commit b7ebd6b
Show file tree
Hide file tree
Showing 12 changed files with 452 additions and 452 deletions.
54 changes: 27 additions & 27 deletions examples/image_chg_col_wid.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
# This demonstrates the effect of changing the column width
# when inserting a picture/image.

import xlwt
w = xlwt.Workbook()
ws = w.add_sheet('Image')

ws.write(0, 2, "chg wid: none")
ws.insert_bitmap('python.bmp', 2, 2)

ws.write(0, 4, "chg wid: after")
ws.insert_bitmap('python.bmp', 2, 4)
ws.col(4).width = 20 * 256

ws.write(0, 6, "chg wid: before")
ws.col(6).width = 20 * 256
ws.insert_bitmap('python.bmp', 2, 6)

ws.write(0, 8, "chg wid: after")
ws.insert_bitmap('python.bmp', 2, 8)
ws.col(5).width = 8 * 256

ws.write(0, 10, "chg wid: before")
ws.col(10).width = 8 * 256
ws.insert_bitmap('python.bmp', 2, 10)

w.save('image_chg_col_wid.xls')
# This demonstrates the effect of changing the column width
# when inserting a picture/image.

import xlwt
w = xlwt.Workbook()
ws = w.add_sheet('Image')

ws.write(0, 2, "chg wid: none")
ws.insert_bitmap('python.bmp', 2, 2)

ws.write(0, 4, "chg wid: after")
ws.insert_bitmap('python.bmp', 2, 4)
ws.col(4).width = 20 * 256

ws.write(0, 6, "chg wid: before")
ws.col(6).width = 20 * 256
ws.insert_bitmap('python.bmp', 2, 6)

ws.write(0, 8, "chg wid: after")
ws.insert_bitmap('python.bmp', 2, 8)
ws.col(5).width = 8 * 256

ws.write(0, 10, "chg wid: before")
ws.col(10).width = 8 * 256
ws.insert_bitmap('python.bmp', 2, 10)

w.save('image_chg_col_wid.xls')
50 changes: 25 additions & 25 deletions examples/numbers_demo.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
#!/usr/bin/env python
# -*- coding: windows-1251 -*-
# Copyright (C) 2005 Kiseliov Roman

from xlwt import *

w = Workbook()
ws = w.add_sheet('Hey, Dude')

ws.write(0, 0, 1)
ws.write(1, 0, 1.23)
ws.write(2, 0, 12345678)
ws.write(3, 0, 123456.78)

ws.write(0, 1, -1)
ws.write(1, 1, -1.23)
ws.write(2, 1, -12345678)
ws.write(3, 1, -123456.78)

ws.write(0, 2, -17867868678687.0)
ws.write(1, 2, -1.23e-5)
ws.write(2, 2, -12345678.90780980)
ws.write(3, 2, -123456.78)

w.save('numbers.xls')
#!/usr/bin/env python
# -*- coding: windows-1251 -*-
# Copyright (C) 2005 Kiseliov Roman

from xlwt import *

w = Workbook()
ws = w.add_sheet('Hey, Dude')

ws.write(0, 0, 1)
ws.write(1, 0, 1.23)
ws.write(2, 0, 12345678)
ws.write(3, 0, 123456.78)

ws.write(0, 1, -1)
ws.write(1, 1, -1.23)
ws.write(2, 1, -12345678)
ws.write(3, 1, -123456.78)

ws.write(0, 2, -17867868678687.0)
ws.write(1, 2, -1.23e-5)
ws.write(2, 2, -12345678.90780980)
ws.write(3, 2, -123456.78)

w.save('numbers.xls')
120 changes: 60 additions & 60 deletions examples/panes2.py
Original file line number Diff line number Diff line change
@@ -1,60 +1,60 @@
#!/usr/bin/env python
# -*- coding: ascii -*-
# portions Copyright (C) 2005 Kiseliov Roman

import xlwt

w = xlwt.Workbook()
sheets = [w.add_sheet('sheet ' + str(sheetx+1)) for sheetx in range(7)]
ws1, ws2, ws3, ws4, ws5, ws6, ws7 = sheets
for sheet in sheets:
for i in range(0x100):
sheet.write(i // 0x10, i % 0x10, i)

H = 1
V = 2
HF = H + 2
VF = V + 2

ws1.panes_frozen = True
ws1.horz_split_pos = H
ws1.horz_split_first_visible = HF

ws2.panes_frozen = True
ws2.vert_split_pos = V
ws2.vert_split_first_visible = VF

ws3.panes_frozen = True
ws3.horz_split_pos = H
ws3.vert_split_pos = V
ws3.horz_split_first_visible = HF
ws3.vert_split_first_visible = VF

H = 10
V = 12
HF = H + 2
VF = V + 2

ws4.panes_frozen = False
ws4.horz_split_pos = H * 12.75 # rows
ws4.horz_split_first_visible = HF

ws5.panes_frozen = False
ws5.vert_split_pos = V * 8.43 # rows
ws5.vert_split_first_visible = VF

ws6.panes_frozen = False
ws6.horz_split_pos = H * 12.75 # rows
ws6.horz_split_first_visible = HF
ws6.vert_split_pos = V * 8.43 # cols
ws6.vert_split_first_visible = VF

ws7.split_position_units_are_twips = True
ws7.panes_frozen = False
ws7.horz_split_pos = H * 250 + 240 # twips
ws7.horz_split_first_visible = HF
ws7.vert_split_pos = V * 955 + 410 # twips
ws7.vert_split_first_visible = VF

w.save('panes2.xls')
#!/usr/bin/env python
# -*- coding: ascii -*-
# portions Copyright (C) 2005 Kiseliov Roman

import xlwt

w = xlwt.Workbook()
sheets = [w.add_sheet('sheet ' + str(sheetx+1)) for sheetx in range(7)]
ws1, ws2, ws3, ws4, ws5, ws6, ws7 = sheets
for sheet in sheets:
for i in range(0x100):
sheet.write(i // 0x10, i % 0x10, i)

H = 1
V = 2
HF = H + 2
VF = V + 2

ws1.panes_frozen = True
ws1.horz_split_pos = H
ws1.horz_split_first_visible = HF

ws2.panes_frozen = True
ws2.vert_split_pos = V
ws2.vert_split_first_visible = VF

ws3.panes_frozen = True
ws3.horz_split_pos = H
ws3.vert_split_pos = V
ws3.horz_split_first_visible = HF
ws3.vert_split_first_visible = VF

H = 10
V = 12
HF = H + 2
VF = V + 2

ws4.panes_frozen = False
ws4.horz_split_pos = H * 12.75 # rows
ws4.horz_split_first_visible = HF

ws5.panes_frozen = False
ws5.vert_split_pos = V * 8.43 # rows
ws5.vert_split_first_visible = VF

ws6.panes_frozen = False
ws6.horz_split_pos = H * 12.75 # rows
ws6.horz_split_first_visible = HF
ws6.vert_split_pos = V * 8.43 # cols
ws6.vert_split_first_visible = VF

ws7.split_position_units_are_twips = True
ws7.panes_frozen = False
ws7.horz_split_pos = H * 250 + 240 # twips
ws7.horz_split_first_visible = HF
ws7.vert_split_pos = V * 955 + 410 # twips
ws7.vert_split_first_visible = VF

w.save('panes2.xls')

28 changes: 14 additions & 14 deletions examples/zoom_magnification.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import xlwt
book = xlwt.Workbook()
for magn in (0, 60, 100, 75, 150):
for preview in (False, True):
sheet = book.add_sheet('magn%d%s' % (magn, "np"[preview]))
if preview:
sheet.preview_magn = magn
else:
sheet.normal_magn = magn
sheet.page_preview = preview
for rowx in range(100):
sheet.write(rowx, 0, "Some text")
book.save("zoom_magnification.xls")
import xlwt
book = xlwt.Workbook()
for magn in (0, 60, 100, 75, 150):
for preview in (False, True):
sheet = book.add_sheet('magn%d%s' % (magn, "np"[preview]))
if preview:
sheet.preview_magn = magn
else:
sheet.normal_magn = magn
sheet.page_preview = preview
for rowx in range(100):
sheet.write(rowx, 0, "Some text")
book.save("zoom_magnification.xls")

48 changes: 24 additions & 24 deletions tests/test_biff_records.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
# coding:utf-8

from io import BytesIO
import unittest

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 = 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)
# coding:utf-8

from io import BytesIO
import unittest

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 = 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)
82 changes: 41 additions & 41 deletions tests/test_bitmaps.py
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
# -*- coding: utf-8 -*-

import sys
import os
import unittest
import filecmp
from datetime import datetime

from utils import in_tst_dir, in_tst_output_dir

import xlwt

class TestBitmaps(unittest.TestCase):
def test_create_bitmap_from_memory(self):
book = xlwt.Workbook()
sheet = book.add_sheet('bitmap test')

with open ("tests/python.bmp", "rb") as bmpfile:
bmpdata = bmpfile.read()
sheet.insert_bitmap_data(bmpdata, 1, 1)

book.save(in_tst_output_dir('bitmaps.xls'))

self.assertTrue(filecmp.cmp(in_tst_dir('bitmaps.xls'),
in_tst_output_dir('bitmaps.xls'),
shallow=False))

def test_create_bitmap_from_file(self):
book = xlwt.Workbook()
sheet = book.add_sheet('bitmap test')

sheet.insert_bitmap("tests/python.bmp", 1, 1)

book.save(in_tst_output_dir('bitmaps.xls'))

self.assertTrue(filecmp.cmp(in_tst_dir('bitmaps.xls'),
in_tst_output_dir('bitmaps.xls'),
shallow=False))

if __name__=='__main__':
unittest.main()
# -*- coding: utf-8 -*-

import sys
import os
import unittest
import filecmp
from datetime import datetime

from utils import in_tst_dir, in_tst_output_dir

import xlwt

class TestBitmaps(unittest.TestCase):
def test_create_bitmap_from_memory(self):
book = xlwt.Workbook()
sheet = book.add_sheet('bitmap test')

with open ("tests/python.bmp", "rb") as bmpfile:
bmpdata = bmpfile.read()
sheet.insert_bitmap_data(bmpdata, 1, 1)

book.save(in_tst_output_dir('bitmaps.xls'))

self.assertTrue(filecmp.cmp(in_tst_dir('bitmaps.xls'),
in_tst_output_dir('bitmaps.xls'),
shallow=False))

def test_create_bitmap_from_file(self):
book = xlwt.Workbook()
sheet = book.add_sheet('bitmap test')

sheet.insert_bitmap("tests/python.bmp", 1, 1)

book.save(in_tst_output_dir('bitmaps.xls'))

self.assertTrue(filecmp.cmp(in_tst_dir('bitmaps.xls'),
in_tst_output_dir('bitmaps.xls'),
shallow=False))

if __name__=='__main__':
unittest.main()

0 comments on commit b7ebd6b

Please sign in to comment.