How to use the pyexcel.save_book_as 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-xlsx / tests / test_multiple_sheets.py View on Github external
def _write_test_file(self, file):
        """
        Make a test file as:

        1,1,1,1
        2,2,2,2
        3,3,3,3
        """
        self.rows = 3
        pyexcel.save_book_as(bookdict=self.content, dest_file_name=file)
github pyexcel / pyexcel / tests / test_stringio.py View on Github external
def test_book_output_stringio(self):
        data = {"Sheet 1": [[1, 2, 3], [4, 5, 6]]}
        io = pe.save_book_as(dest_file_type="xlsm", bookdict=data)
        b = pe.load_book_from_memory("xlsm", io.getvalue())
        result = [1, 2, 3, 4, 5, 6]
        actual = list(b[0].enumerate())
        eq_(result, actual)
github pyexcel / pyexcel-ods / tests / test_multiple_sheets.py View on Github external
def _write_test_file(self, file):
        """
        Make a test file as:

        1,1,1,1
        2,2,2,2
        3,3,3,3
        """
        self.rows = 3
        pyexcel.save_book_as(bookdict=self.content, dest_file_name=file)
github pyexcel / pyexcel-ods3 / tests / test_multiple_sheets.py View on Github external
def _write_test_file(self, file):
        """
        Make a test file as:

        1,1,1,1
        2,2,2,2
        3,3,3,3
        """
        self.rows = 3
        pyexcel.save_book_as(bookdict=self.content, dest_file_name=file)
github pyexcel / pyexcel / tests / test_signature_fuction.py View on Github external
def test_get_book_from_memory_compatibility(self):
        content = _produce_ordered_dict()
        io = pe.save_book_as(dest_file_type="xls", bookdict=content)
        pe.get_book(content=io.getvalue(), file_type="xls")
github pyexcel-webwares / pyexcel-webio / pyexcel_webio / __init__.py View on Github external
:param initializers: a list of model
                             initialization functions.
        :param mapdicts: a list of explicit table column names
                         if your excel data sheets do not have
                         the exact column names
        :param keywords: additional keywords to
                         :meth:`pyexcel.Book.save_to_database`

        """
        params = self.get_params(**keywords)
        params['dest_session'] = session
        params['dest_tables'] = tables
        params['dest_initializers'] = initializers
        params['dest_mapdicts'] = mapdicts
        params['dest_auto_commit'] = auto_commit
        pe.save_book_as(**params)
github wind39 / spartacus / Spartacus / Utils.py View on Github external
self.v_open = True
            elif self.v_extension == "xlsx":
                if "xlsx" in v_supported_file_formats:
                    self.v_object = openpyxl.load_workbook(
                        self.v_filename, read_only=True
                    )
                    self.v_open = True
                else:
                    raise Spartacus.Utils.Exception(
                        "XLSX is not supported. Please install it with 'pip install Spartacus[xlsx]'."
                    )
            elif self.v_extension == "xls":
                if "xls" in v_supported_file_formats:
                    v_tmp_file = tempfile.NamedTemporaryFile(suffix=".xlsx")
                    v_tmp_file.file.close()
                    pyexcel.save_book_as(
                        file_name=self.v_filename, dest_file_name=v_tmp_file.name
                    )
                    self.v_object = openpyxl.load_workbook(
                        v_tmp_file.name, read_only=True
                    )
                    self.v_open = True
                else:
                    raise Spartacus.Utils.Exception(
                        "XLS is not supported. Please install it with 'pip install Spartacus[xls]'."
                    )
            else:
                raise Spartacus.Utils.Exception(
                    'File extension "{0}" not supported.'.format(self.v_extension)
                )
        except Spartacus.Utils.Exception as exc:
            raise exc
github mangroveorg / datawinners / datawinners / blue / xlsform_utils.py View on Github external
def convert_json_to_excel(json_as_dict, file_type='xlsx'):
    book_content = OrderedDict()
    for sheet_name in json_as_dict:
        book_content[sheet_name] = convert_json_record_to_array(
                                                                json_as_dict[sheet_name], 
                                                                sheet_name,
                                                                XLSFORM_PREDEFINED_COLUMN_NAMES.get(sheet_name),
                                                                XLSFORM_EXCLUDE_COLUMN_NAMES.get(sheet_name)
                                                                )
    excel_raw_stream = pe.save_book_as(dest_file_type=file_type, bookdict=book_content)

    return excel_raw_stream
github Thimxx / pyGenealogical-Tools / pyFS / pyfs_open_xlsx.py View on Github external
def __init__(self, filename, naming_convention = "father_surname", language = "en"):
        '''
        This contructor reads the output file from FS in xlsx format
        ''' #TODO: include further naming conventions
        self.correct_execution = True
        self.language = language
        if os.path.exists(filename):
            if (".xlsx" not in filename):
                #This file is not in xlsx format, we change it:
                pyexcel.save_book_as(file_name=filename, dest_file_name=filename + "x")
                filename = filename + "x"
        else:
            #The file does not exists, we create an error!
            logging.error(NOT_EXISTING_FILE + filename)
            self.correct_execution = False
        if (naming_convention not in naming_conventions):
            logging.error(NO_VALID_NAMING_CONVENTION)
            self.correct_execution = False
        self.naming_convention = naming_convention
        if self.correct_execution:
            self.loaded_data = load_workbook(filename, data_only=True)
            if (self.__locate_key_fields__()):
                self.profiles = []
                self.geni_profiles = []
                self.related_profiles = {}
                self.related_geni_profiles = []