How to use the pyexcel.Sheet function in pyexcel

To help you get started, we’ve selected a few pyexcel examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pyexcel / pyexcel / tests / test_django_related_functions.py View on Github external
def test_sheet_save_to_django_model(self):
        model = FakeDjangoModel()
        sheet = pe.Sheet(self.data, name_columns_by_row=0)
        sheet.save_to_django_model(model)
        assert model.objects.objs == self.result
github pyexcel / pyexcel / tests / test_bug_fixes.py View on Github external
def test_issue_125_using_key():
    test_file = "issue_125.xls"
    book = p.Book()
    book += p.Sheet([[1]], "A")
    book += p.Sheet([[2]], "B")
    book += p.Sheet([[3]], "C")

    custom_order = {"A": 1, "B": 3, "C": 2}
    book.sort_sheets(key=lambda x: custom_order[x])
    book.save_as(test_file)
    book2 = p.get_book(file_name=test_file)
    eq_(book2.sheet_names(), ["A", "C", "B"])
    os.unlink(test_file)
github pyexcel / pyexcel / tests / test_sheet_row.py View on Github external
def test_delete_indexed_row3(self):
        s = Sheet(self.data, "test")
        s.name_rows_by_column(0)
        del s.row["Row 0", "Row 1"]
        assert s.number_of_rows() == 2
        s.row["Row 1"]  # already deleted
github pyexcel / pyexcel / tests / test_stringio.py View on Github external
def test_save_sheet_to_sys_stdout():
    data = [[1]]
    sheet = pe.Sheet(data)
    stream = sheet.save_to_memory("csv", sys.stdout)
    eq_(stream.getvalue(), "1\r\n")
github pyexcel-renderers / pyexcel-handsontable / tests / test_book.py View on Github external
def test_book_in_jupyter_renderring(self):
        self.fake_uuid.side_effect = ['1', '2', '3', '4']
        self.dump_dict.return_value = DEFAULT_CONFIG
        book = pyexcel.Book()
        book += pyexcel.Sheet([[1]])
        book += pyexcel.Sheet([[2]], name='pyexcel sheet_1')
        book += pyexcel.Sheet([[3]], name='pyexcel sheet_2')
        actual = book.handsontable
        test_fixture = 'tests/fixtures/book.jupyter_notebook'
        with codecs.open(test_fixture, 'r', encoding='utf-8') as f:
            expected = f.read()
            self.customAssertMultiLineEqual(expected, actual)
github pyexcel-renderers / pyexcel-handsontable / tests / test_book.py View on Github external
def test_book_renderring(self):
        self.fake_uuid.side_effect = ['1', '2', '3', '4']
        self.dump_dict.return_value = DEFAULT_CONFIG
        book = pyexcel.Book()
        book += pyexcel.Sheet([[1]])
        book += pyexcel.Sheet([[2]])
        book += pyexcel.Sheet([[3]])
        book.save_as(self._test_file)
        self.compareTwoFiles(
            self._test_file,
            'tests/fixtures/book.handsontable.html')
github pyexcel / pyexcel / tests / test_sheet_column.py View on Github external
def test_set_indexed_row(self):
        s = Sheet(self.data, "test")
        s.name_columns_by_row(2)
        s.row[0] = [10000, 1, 11]
        assert s.row[0] == [10000, 1, 11]
github mangroveorg / datawinners / datawinners / blue / xlsform_utils.py View on Github external
def _add_supported_attributes_that_doesnt_exists(sheet):
    supported_attributes_that_doesnt_exists = list(set(XLSFORM_PREDEFINED_COLUMN_NAMES[sheet.name]) - set(sheet.colnames))
    additional_data = list()
    additional_data.append(supported_attributes_that_doesnt_exists)
    for row in sheet.rows():
        additional_data.append(['' for x in supported_attributes_that_doesnt_exists])

    additional_supported_attr_sheet = pe.Sheet(additional_data)
    sheet.column += additional_supported_attr_sheet
github pyexcel / pyexcel / examples / memoryfile / pyexcel_server.py View on Github external
def download():
    sheet = pe.Sheet(data)
    output = make_response(sheet.csv)
    output.headers["Content-Disposition"] = "attachment; filename=export.csv"
    output.headers["Content-type"] = "text/csv"
    return output