diff --git a/.moban.d/custom_README.rst.jj2 b/.moban.d/custom_README.rst.jj2 index 92002e5..42b8805 100644 --- a/.moban.d/custom_README.rst.jj2 +++ b/.moban.d/custom_README.rst.jj2 @@ -1,7 +1,8 @@ {%extends 'README.rst.jj2' %} {%block description%} -**{{name}}** is a tiny wrapper library to write data in xlsx and xlsm fromat using libxlsxwriter. You are likely to use it with `pyexcel `__. +**{{name}}** is a tiny wrapper library to write data in xlsx and xlsm format +using libxlsxwriter. You are likely to use it with `pyexcel `__. {%endblock%} @@ -61,3 +62,6 @@ Let's assume we have data as the following. {%block read_from_memory_via_pyexcel %} {%endblock%} + +{% block pyexcel_write_to_memory%} +{% endblock %} \ No newline at end of file diff --git a/README.rst b/README.rst index ca67d4f..204fe86 100644 --- a/README.rst +++ b/README.rst @@ -33,7 +33,8 @@ pyexcel-libxlsxw - Let you focus on data, instead of xlsx format .. image:: https://readthedocs.org/projects/pyexcel-libxlsxw/badge/?version=latest :target: http://pyexcel-libxlsxw.readthedocs.org/en/latest/ -**pyexcel-libxlsxw** is a tiny wrapper library to write data in xlsx and xlsm fromat using libxlsxwriter. You are likely to use it with `pyexcel `__. +**pyexcel-libxlsxw** is a tiny wrapper library to write data in xlsx and xlsm format +using libxlsxwriter. You are likely to use it with `pyexcel `__. Support the project ================================================================================ @@ -198,23 +199,6 @@ Here is the sample code: >>> sheet.save_as("another_file.xlsx") -Writing to a StringIO instance -******************************************************************************** - -You need to pass a StringIO instance to Writer: - -.. code-block:: python - - >>> data = [ - ... [1, 2, 3], - ... [4, 5, 6] - ... ] - >>> io = StringIO() - >>> sheet = pe.Sheet(data) - >>> io = sheet.save_to_memory("xlsx", io) - >>> # then do something with io - >>> # In reality, you might give it to your http response - >>> # object for downloading License diff --git a/tests/base.py b/tests/base.py index 73ea2bf..7250e47 100644 --- a/tests/base.py +++ b/tests/base.py @@ -5,17 +5,6 @@ from nose.tools import eq_ -def create_sample_file1(file): - data = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", 1.1, 1] - table = [] - table.append(data[:4]) - table.append(data[4:8]) - table.append(data[8:12]) - pyexcel.save_as( - array=table, dest_file_name=file, library="pyexcel-libxlsxw" - ) - - class PyexcelHatWriterBase: """ Abstract functional test for hat writers diff --git a/tests/test_stringio.py b/tests/test_stringio.py index a5502fa..ef43fc8 100644 --- a/tests/test_stringio.py +++ b/tests/test_stringio.py @@ -1,6 +1,5 @@ import pyexcel - from nose.tools import eq_ diff --git a/tests/test_writer.py b/tests/test_writer.py index 956db41..b40d2fa 100644 --- a/tests/test_writer.py +++ b/tests/test_writer.py @@ -1,4 +1,5 @@ import os +from datetime import date, time, datetime from base import PyexcelWriterBase, PyexcelHatWriterBase from pyexcel_xls import get_data @@ -8,13 +9,29 @@ class TestNativeXLWriter: + def setUp(self): + self.testfile = "xlwriter.xlsx" + def test_write_book(self): self.content = { "Sheet1": [[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3]], "Sheet2": [[4, 4, 4, 4], [5, 5, 5, 5], [6, 6, 6, 6]], "Sheet3": [[u"X", u"Y", u"Z"], [1, 4, 7], [2, 5, 8], [3, 6, 9]], } - self.testfile = "xlwriter.xlsx" + writer = xlsx.XLSXWriter(self.testfile, "xlsx") + writer.write(self.content) + writer.close() + content = get_data(self.testfile) + for key in content.keys(): + content[key] = list(content[key]) + eq_(content, self.content) + + def test_write_dates(self): + self.content = { + "date": [[date(2020, 10, 11)]], + "time": [[time(11, 22, 11)]], + "datetime": [[datetime(2020, 11, 11, 12, 12, 12)]], + } writer = xlsx.XLSXWriter(self.testfile, "xlsx") writer.write(self.content) writer.close()