def test_xlsx_to_reader(self): import xlsxwriter write_wb = xlsxwriter.Workbook() ws = write_wb.add_worksheet('Foo') ws.write(0, 0, 'bar') wb = xlsx_to_reader(write_wb) sh = wb.sheet_by_name('Foo') assert sh.cell_value(rowx=0, colx=0) == 'bar'
def from_nested_iters(cls, data): """Builds an XlrdSheetData from nested iterables. param data: is nested iterables representing data for each cell. For example, `[('A1', 'B1'), ('A2', 'B2')]` represents two rows and two columns of data. """ workbook = Workbook(BytesIO()) sheet = workbook.add_worksheet('test') for row, row_data in enumerate(data): for column, cell_data in enumerate(row_data): sheet.write(row, column, cell_data) return XlrdSheetData(xlsx_to_reader(workbook).sheet_by_index(0))
def generate_report(self): wb = Workbook(BytesIO()) ws = wb.add_worksheet(CarDealerSheet.sheet_name) CarDealerSheet(wb, worksheet=ws) book = xlsx_to_reader(wb) return book.sheet_by_name('Dealership Summary')
def generate_report(self, reportcls=CarSheet): wb = Workbook(BytesIO()) ws = wb.add_worksheet(reportcls.sheet_name) reportcls(wb, worksheet=ws) book = xlsx_to_reader(wb) return book.sheet_by_name('Car Info')