@@ -61,48 +61,40 @@ Write to an xls file
61
61
... from StringIO import StringIO
62
62
... else :
63
63
... from io import BytesIO as StringIO
64
- >>> from pyexcel.ext.xls import OrderedDict
64
+ >>> from pyexcel_io import OrderedDict
65
65
66
66
67
67
Here's the sample code to write a dictionary to an xls file::
68
68
69
- >>> from pyexcel_xls import XLWriter
69
+ >>> from pyexcel_xls import store_data
70
70
>>> data = OrderedDict() # from collections import OrderedDict
71
71
>>> data.update({"Sheet 1": [[1, 2, 3], [4, 5, 6]]})
72
72
>>> data.update({"Sheet 2": [["row 1", "row 2", "row 3"]]})
73
- >>> writer = XLWriter("your_file.xls")
74
- >>> writer.write(data)
75
- >>> writer.close()
73
+ >>> store_data("your_file.xls", data)
76
74
77
75
Read from an xls file
78
76
**********************
79
77
80
78
Here's the sample code::
81
79
82
- >>> from pyexcel_xls import XLBook
83
-
84
- >>> book = XLBook("your_file.xls")
85
- >>> # book.sheets() returns a dictionary of all sheet content
86
- >>> # the keys represents sheet names
87
- >>> # the values are two dimensional array
88
- >>> import json
89
- >>> print(json.dumps(book.sheets()))
80
+ >>> from pyexcel_xls import load_data
81
+ >>> data = load_data("your_file.xls")
82
+ >>> import json
83
+ >>> print(json.dumps(data))
90
84
{"Sheet 1": [[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]], "Sheet 2": [["row 1", "row 2", "row 3"]]}
91
85
92
86
Write an xls to memory
93
87
**********************
94
88
95
89
Here's the sample code to write a dictionary to an xls file::
96
90
97
- >>> from pyexcel_xls import XLWriter
91
+ >>> from pyexcel_xls import store_data
98
92
>>> data = OrderedDict()
99
93
>>> data.update({"Sheet 1": [[1, 2, 3], [4, 5, 6]]})
100
94
>>> data.update({"Sheet 2": [[7, 8, 9], [10, 11, 12]]})
101
95
>>> io = StringIO()
102
- >>> writer = XLWriter(io)
103
- >>> writer.write(data)
104
- >>> writer.close()
105
- >>> # do something witht the io
96
+ >>> writer = store_data(io, data)
97
+ >>> # do something with the io
106
98
>>> # In reality, you might give it to your http response
107
99
>>> # object for downloading
108
100
@@ -115,8 +107,8 @@ Continue from previous example::
115
107
>>> # This is just an illustration
116
108
>>> # In reality, you might deal with xls file upload
117
109
>>> # where you will read from requests.FILES['YOUR_XL_FILE']
118
- >>> book = XLBook(None, io.getvalue() )
119
- >>> print(json.dumps(book.sheets() ))
110
+ >>> data = load_data(io )
111
+ >>> print(json.dumps(data ))
120
112
{"Sheet 1": [[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]], "Sheet 2": [[7.0, 8.0, 9.0], [10.0, 11.0, 12.0]]}
121
113
122
114
@@ -169,7 +161,7 @@ You got to wrap the binary content with stream to get xls working::
169
161
>>> xlfile = "another_file.xls"
170
162
>>> with open(xlfile, "rb") as f:
171
163
... content = f.read()
172
- ... r = pe.get_book(file_type="xls", content =content)
164
+ ... r = pe.get_book(file_type="xls", file_content =content)
173
165
... print(r)
174
166
...
175
167
Sheet Name: Sheet 1
0 commit comments