Skip to content

Commit a657cce

Browse files
committed
documentation update
1 parent 4e37d6c commit a657cce

File tree

2 files changed

+24
-13
lines changed

2 files changed

+24
-13
lines changed

README.rst

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ Write to an xls file
5252
.. testcode::
5353
:hide:
5454

55+
>>> import os
5556
>>> import sys
5657
>>> if sys.version_info[0] < 3:
5758
... from StringIO import StringIO
@@ -87,6 +88,7 @@ Here's the sample code:
8788
>>> print(json.dumps(data))
8889
{"Sheet 1": [[1, 2, 3], [4, 5, 6]], "Sheet 2": [["row 1", "row 2", "row 3"]]}
8990
91+
9092
Write an xls to memory
9193
********************************************************************************
9294

@@ -126,6 +128,8 @@ Pagination feature
126128

127129
Let's assume the following file is a huge xls file:
128130

131+
.. code-block:: python
132+
129133
>>> huge_data = [
130134
... [1, 21, 31],
131135
... [2, 22, 32],
@@ -144,16 +148,16 @@ And let's pretend to read partial data:
144148
.. code-block:: python
145149
146150
>>> partial_data = get_data("huge_file.xls", start_row=2, row_limit=3)
147-
>>> partial_data['huge']
148-
[[3, 23, 33], [4, 24, 34], [5, 25, 35]]
151+
>>> print(json.dumps(partial_data))
152+
{"huge": [[3, 23, 33], [4, 24, 34], [5, 25, 35]]}
149153
150154
And you could as well do the same for columns:
151155

152156
.. code-block:: python
153157
154158
>>> partial_data = get_data("huge_file.xls", start_column=1, column_limit=2)
155-
>>> partial_data['huge']
156-
[[21, 31], [22, 32], [23, 33], [24, 34], [25, 35], [26, 36]]
159+
>>> print(json.dumps(partial_data))
160+
{"huge": [[21, 31], [22, 32], [23, 33], [24, 34], [25, 35], [26, 36]]}
157161
158162
Obvious, you could do both at the same time:
159163

@@ -162,8 +166,13 @@ Obvious, you could do both at the same time:
162166
>>> partial_data = get_data("huge_file.xls",
163167
... start_row=2, row_limit=3,
164168
... start_column=1, column_limit=2)
165-
>>> partial_data['huge']
166-
[[23, 33], [24, 34], [25, 35]]
169+
>>> print(json.dumps(partial_data))
170+
{"huge": [[23, 33], [24, 34], [25, 35]]}
171+
172+
.. testcode::
173+
:hide:
174+
175+
>>> os.unlink("huge_file.xls")
167176

168177

169178
As a pyexcel plugin
@@ -183,6 +192,7 @@ Import it in your file to enable this plugin:
183192
184193
Please note only pyexcel version 0.0.4+ support this.
185194

195+
186196
Reading from an xls file
187197
********************************************************************************
188198

@@ -205,6 +215,7 @@ Here is the sample code:
205215
| row 1 | row 2 | row 3 |
206216
+-------+-------+-------+
207217
218+
208219
Writing to an xls file
209220
********************************************************************************
210221

@@ -214,8 +225,9 @@ Here is the sample code:
214225
215226
>>> sheet.save_as("another_file.xls")
216227
228+
217229
Reading from a IO instance
218-
================================================================================
230+
********************************************************************************
219231

220232
You got to wrap the binary content with stream to get xls working:
221233

@@ -243,7 +255,7 @@ You got to wrap the binary content with stream to get xls working:
243255
244256
245257
Writing to a StringIO instance
246-
================================================================================
258+
********************************************************************************
247259

248260
You need to pass a StringIO instance to Writer:
249261

@@ -323,5 +335,4 @@ Known Issues
323335

324336
>>> import os
325337
>>> os.unlink("your_file.xls")
326-
>>> os.unlink("huge_file.xls")
327338
>>> os.unlink("another_file.xls")

pyexcel_xls/xls.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def xldate_to_python_date(value):
6363

6464
class XLSheet(SheetReader):
6565
"""
66-
xls sheet
66+
xls, xlsx, xlsm sheet reader
6767
6868
Currently only support first sheet in the file
6969
"""
@@ -178,7 +178,7 @@ def _get_params(self):
178178

179179
class XLSheetWriter(SheetWriter):
180180
"""
181-
xls, xlsx and xlsm sheet writer
181+
xls sheet writer
182182
"""
183183
def set_sheet_name(self, name):
184184
"""Create a sheet
@@ -190,7 +190,7 @@ def write_row(self, array):
190190
"""
191191
write a row into the file
192192
"""
193-
for i in range(0, len(array)):
193+
for i in range(len(array)):
194194
value = array[i]
195195
style = None
196196
tmp_array = []
@@ -221,7 +221,7 @@ def write_row(self, array):
221221

222222
class XLSWriter(BookWriter):
223223
"""
224-
xls, xlsx and xlsm writer
224+
xls writer
225225
"""
226226
def __init__(self):
227227
BookWriter.__init__(self)

0 commit comments

Comments
 (0)