33 This file keeps all fixes for issues found
44
55"""
6-
76import os
87import pyexcel as pe
98import pyexcel .ext .xls
109import pyexcel .ext .xlsx
10+ from textwrap import dedent
1111import datetime
1212from pyexcel .ext .xlsx import get_columns
1313from 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