return XLSXSheetWriter(self.native_book, self.native_book.create_sheet(), name) def close(self): """ This call actually save the file """ self.native_book.save(filename=self.file) READERS.update({ "xlsm": XLSXBook, "xlsx": XLSXBook }) WRITERS.update({ "xlsm": XLSXWriter, "xlsx": XLSXWriter }) def save_data(afile, data, file_type=None, **keywords): if isstream(afile) and file_type is None: file_type='xlsx' write_data(afile, data, file_type=file_type, **keywords) def get_data(afile, file_type=None, **keywords): if isstream(afile) and file_type is None: file_type='xlsx' return read_data(afile, file_type=file_type, **keywords)
def write(self, sheet_dicts): if self.keywords.get('single_sheet_in_book', False): keys = list(sheet_dicts.keys()) sheet = self.create_sheet(keys[0]) sheet.write_array(sheet_dicts[keys[0]]) sheet.close() else: import json self.f.write(json.dumps(sheet_dicts)) def create_sheet(self, name): return JsonSheetWriter(self.f, name) def close(self): TextWriter.close(self) WRITERS.update({ "simple": TextWriter, "plain": TextWriter, "grid": TextWriter, "pipe": TextWriter, "orgtbl": TextWriter, "rst": TextWriter, "mediawiki": TextWriter, "latex": TextWriter, "latex_booktabs": TextWriter, "json": JsonWriter })
def close(self): """ This call actually save the file """ self.wb.save(self.file) READERS.update({ "xls": XLBook, "xlsm": XLBook, "xlsx": XLBook }) WRITERS.update({ "xls": XLWriter }) def get_data(afile, file_type=None, **keywords): if isstream(afile) and file_type is None: file_type='xls' return read_data(afile, file_type=file_type, **keywords) def save_data(afile, data, file_type=None, **keywords): if isstream(afile) and file_type is None: file_type='xls' write_data(afile, data, file_type=file_type, **keywords)
encoding=encoding) def create_sheet(self, name): """Create a xlwt writer""" return XLSheetWriter(self.wb, None, name) def close(self): """ This call actually save the file """ self.wb.save(self.file) READERS.update({"xls": XLBook, "xlsm": XLBook, "xlsx": XLBook}) WRITERS.update({"xls": XLWriter}) def get_data(afile, file_type=None, **keywords): if isstream(afile) and file_type is None: file_type = 'xls' return read_data(afile, file_type=file_type, **keywords) def save_data(afile, data, file_type=None, **keywords): if isstream(afile) and file_type is None: file_type = 'xls' write_data(afile, data, file_type=file_type, **keywords) __VERSION__ = "0.0.8"