Skip to content

Commit cc340d7

Browse files
committed
Merge branch 'master' of https://github.com/chfw/pyexcel-xlsx
2 parents 17394c4 + 9b942df commit cc340d7

File tree

5 files changed

+56
-5
lines changed

5 files changed

+56
-5
lines changed

pyexcel_xlsx/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,11 @@ def getSheet(self, nativeSheet):
6666
return XLSXSheet(nativeSheet)
6767

6868
def load_from_memory(self, file_content):
69-
return openpyxl.load_workbook(filename=StringIO(file_content))
69+
return openpyxl.load_workbook(filename=StringIO(file_content),
70+
data_only=True)
7071

7172
def load_from_file(self, filename):
72-
return openpyxl.load_workbook(filename)
73+
return openpyxl.load_workbook(filename=filename, data_only=True)
7374

7475
def sheetIterator(self):
7576
return self.native_book

test.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
nosetests --with-cov --with-doctest --doctest-extension=.rst tests README.rst
1+
nosetests --with-cov --cov pyexcel_xlsx --cov tests --with-doctest --doctest-extension=.rst tests README.rst

test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
nosetests --with-cov --with-doctest --doctest-extension=.rst tests README.rst
1+
nosetests --with-cov --cov pyexcel_xlsx --cov tests --with-doctest --doctest-extension=.rst tests README.rst

tests/test-fixtures/test8.xlsx

9.04 KB
Binary file not shown.

tests/test_bug_fixes.py

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
This file keeps all fixes for issues found
44
55
"""
6-
76
import os
87
import pyexcel as pe
98
import pyexcel.ext.xls
109
import pyexcel.ext.xlsx
10+
from textwrap import dedent
1111
import datetime
1212
from pyexcel.ext.xlsx import get_columns
1313
from pyexcel.sheets.matrix import _excel_column_index
@@ -66,3 +66,53 @@ def test_pyexcel_issue_5(self):
6666
print(s[0,0])
6767
assert s[0,0] == datetime.datetime(2015, 11, 11, 11, 12, 0)
6868
assert s2[0,0] == datetime.datetime(2015, 11, 11, 11, 12, 0)
69+
70+
def test_pyexcel_issue_8_with_physical_file(self):
71+
"""pyexcel issue #8
72+
73+
formular got lost
74+
"""
75+
tmp_file = "issue_8_save_as.xlsx"
76+
s = pe.load(os.path.join("tests",
77+
"test-fixtures",
78+
"test8.xlsx"))
79+
s.save_as(tmp_file)
80+
s2 = pe.load(tmp_file)
81+
assert str(s) == str(s2)
82+
content = dedent("""
83+
Sheet Name: CNY
84+
+----------+----------+------+---+--------+
85+
| 01/09/13 | 02/09/13 | 1000 | 5 | 13.890 |
86+
+----------+----------+------+---+--------+
87+
| 02/09/13 | 03/09/13 | 2000 | 6 | 33.330 |
88+
+----------+----------+------+---+--------+
89+
| 03/09/13 | 04/09/13 | 3000 | 7 | 58.330 |
90+
+----------+----------+------+---+--------+""").strip("\n")
91+
assert str(s2) == content
92+
os.unlink(tmp_file)
93+
94+
def test_pyexcel_issue_8_with_memory_file(self):
95+
"""pyexcel issue #8
96+
97+
formular got lost
98+
"""
99+
tmp_file = "issue_8_save_as.xlsx"
100+
f = open(os.path.join("tests",
101+
"test-fixtures",
102+
"test8.xlsx"),
103+
"rb")
104+
s = pe.load_from_memory('xlsx', f.read())
105+
s.save_as(tmp_file)
106+
s2 = pe.load(tmp_file)
107+
assert str(s) == str(s2)
108+
content = dedent("""
109+
Sheet Name: CNY
110+
+----------+----------+------+---+--------+
111+
| 01/09/13 | 02/09/13 | 1000 | 5 | 13.890 |
112+
+----------+----------+------+---+--------+
113+
| 02/09/13 | 03/09/13 | 2000 | 6 | 33.330 |
114+
+----------+----------+------+---+--------+
115+
| 03/09/13 | 04/09/13 | 3000 | 7 | 58.330 |
116+
+----------+----------+------+---+--------+""").strip("\n")
117+
assert str(s2) == content
118+
os.unlink(tmp_file)

0 commit comments

Comments
 (0)