@@ -62,47 +62,39 @@ Write to an xlsx file
6262 ... from StringIO import StringIO
6363 ... else :
6464 ... from io import BytesIO as StringIO
65- >>> from pyexcel_xlsx import OrderedDict
65+ >>> from pyexcel_io import OrderedDict
6666
6767Here's the sample code to write a dictionary to an xlsx file::
6868
69- >>> from pyexcel_xlsx import XLSXWriter
69+ >>> from pyexcel_xlsx import store_data
7070 >>> data = OrderedDict() # from collections import OrderedDict
7171 >>> data.update({"Sheet 1": [[1, 2, 3], [4, 5, 6]]})
7272 >>> data.update({"Sheet 2": [["row 1", "row 2", "row 3"]]})
73- >>> writer = XLSXWriter("your_file.xlsx")
74- >>> writer.write(data)
75- >>> writer.close()
73+ >>> store_data("your_file.xlsx", data)
7674
7775Read from an xlsx file
7876**********************
7977
8078Here's the sample code::
8179
82- >>> from pyexcel_xlsx import XLSXBook
83-
84- >>> book = XLSXBook("your_file.xlsx")
85- >>> # book.sheets() returns a dictionary of all sheet content
86- >>> # the keys represents sheet names
87- >>> # the values are two dimensional array
80+ >>> from pyexcel_xlsx import load_data
81+ >>> data = load_data("your_file.xlsx")
8882 >>> import json
89- >>> print(json.dumps(book.sheets() ))
83+ >>> print(json.dumps(data ))
9084 {"Sheet 1": [[1, 2, 3], [4, 5, 6]], "Sheet 2": [["row 1", "row 2", "row 3"]]}
9185
9286Write an xlsx to memory
9387*************************
9488
9589Here's the sample code to write a dictionary to an xlsx file::
9690
97- >>> from pyexcel_xlsx import XLSXWriter
91+ >>> from pyexcel_xlsx import store_data
9892 >>> data = OrderedDict()
9993 >>> data.update({"Sheet 1": [[1, 2, 3], [4, 5, 6]]})
10094 >>> data.update({"Sheet 2": [[7, 8, 9], [10, 11, 12]]})
10195 >>> io = StringIO()
102- >>> writer = XLSXWriter(io)
103- >>> writer.write(data)
104- >>> writer.close()
105- >>> # do something witht the io
96+ >>> store_data(io, data)
97+ >>> # do something with the io
10698 >>> # In reality, you might give it to your http response
10799 >>> # object for downloading
108100
@@ -115,8 +107,8 @@ Continue from previous example::
115107 >>> # This is just an illustration
116108 >>> # In reality, you might deal with xlsx file upload
117109 >>> # where you will read from requests.FILES['YOUR_XLSX_FILE']
118- >>> book = XLSXBook(None, io.getvalue() )
119- >>> print(json.dumps(book.sheets() ))
110+ >>> data = load_data(io )
111+ >>> print(json.dumps(data ))
120112 {"Sheet 1": [[1, 2, 3], [4, 5, 6]], "Sheet 2": [[7, 8, 9], [10, 11, 12]]}
121113
122114
@@ -169,7 +161,7 @@ You got to wrap the binary content with stream to get xlsx working::
169161 >>> xlsxfile = "another_file.xlsx"
170162 >>> with open(xlsxfile, "rb") as f:
171163 ... content = f.read()
172- ... r = pe.get_book(file_type="xlsx", content =content)
164+ ... r = pe.get_book(file_type="xlsx", file_content =content)
173165 ... print(r)
174166 ...
175167 Sheet Name: Sheet 1
0 commit comments