Example #1
0
def xlsxwrite_exchangerate_results(dt_exrt_n_dc_exchangerates):
  fpath = dtfs.get_appsroot_abspath_for_filename_w_tstamp('exchange_rates_test.xlsx')
  workbook = xlsxwriter.Workbook(fpath)
  worksheet = workbook.add_worksheet()
  cellref = 'B4'
  worksheet.write(cellref, 'Seq')
  cellref = tblfs.move_cell_along_columns(cellref, 1)
  worksheet.write(cellref, 'Data')
  cellref = tblfs.move_cell_along_columns(cellref, 1)
  worksheet.write(cellref, 'valor câmbio')
  cellref = tblfs.move_cell_along_columns(cellref, 1)
  worksheet.write(cellref, 'data câmbio')
  cellref = tblfs.move_cell_along_tableau(cellref, -3, 1)
  for i, dt_exrt_n_dc in enumerate(dt_exrt_n_dc_exchangerates):
    pdate, exchange_rate, data_cotacao = dt_exrt_n_dc
    seq = i + 1
    worksheet.write(cellref, seq)
    cellref = tblfs.move_cell_along_columns(cellref, 1)
    worksheet.write(cellref, pdate)
    cellref = tblfs.move_cell_along_columns(cellref, 1)
    worksheet.write(cellref, exchange_rate)
    cellref = tblfs.move_cell_along_columns(cellref, 1)
    worksheet.write(cellref, data_cotacao)
    cellref = tblfs.move_cell_along_tableau(cellref, -3, 1)
  workbook.close()
Example #2
0
def adhoc_test2():
    cellref = 'A3'
    ncolumns = 4
    next_cellref = tblfs.move_cell_along_columns(cellref, ncolumns)
    print('cellref', cellref, 'move', ncolumns, 'results in', next_cellref)
    cellref = next_cellref
    ncolumns = -4
    next_cellref = tblfs.move_cell_along_columns(cellref, ncolumns)
    print('cellref', cellref, 'move', ncolumns, 'results in', next_cellref)
    ncolumns = 7
    nrows = 3
    next_cellref = tblfs.move_cell_along_tableau(cellref, ncolumns, nrows)
    print('cellref', cellref, 'move ncolumns', ncolumns, 'move nrows', nrows,
          'results in', next_cellref)
    cellref = next_cellref
    ncolumns = -7
    nrows = -3
    next_cellref = tblfs.move_cell_along_tableau(cellref, ncolumns, nrows)
    print('cellref', cellref, 'move ncolumns', ncolumns, 'move nrows', nrows,
          'results in', next_cellref)
    # cellref = next_cellref; ncolumns = 34
    # next_cellref = move_cell_along_columns(cellref, ncolumns)
    cellref = 'A3'
    ncolumns = 26 + 4
    next_cellref = tblfs.move_cell_along_columns(cellref, ncolumns)
    print('cellref', cellref, 'move', ncolumns, 'results in', next_cellref)
    cellref = 'A3'
    ncolumns = 26 * 26 + 26 + 4
    next_cellref = tblfs.move_cell_along_columns(cellref, ncolumns)
    print('cellref', cellref, 'move', ncolumns, 'results in', next_cellref)
    cell_letters = 'D'
    n = tblfs.convert_columnletters_to_number_recursively(cell_letters)
    cell_letters = 'AA'
    n = tblfs.convert_columnletters_to_number_recursively(cell_letters)
    print(cell_letters, '=>', n)
    cell_letters = tblfs.convert_number_to_columnletters_recursively(n)
    print(n, '=>', cell_letters)
    cell_letters = 'CB'
    n = tblfs.convert_columnletters_to_number_recursively(cell_letters)
    print(cell_letters, '=>', n)
    cell_letters = tblfs.convert_number_to_columnletters_recursively(n)
    print(n, '=>', cell_letters)
    '''
Example #3
0
  def test_move_thru_tableau(self):
    cellref = 'a5'; ncolumns = 2; nrows = 3
    expected_cellref = 'c8'.upper()
    returned_cellref = tblfs.move_cell_along_tableau(cellref, ncolumns, nrows)
    self.assertEqual(expected_cellref, returned_cellref)
    cellref = returned_cellref; ncolumns = -2; nrows = -3
    expected_cellref = 'a5'.upper()
    returned_cellref = tblfs.move_cell_along_tableau(cellref, ncolumns, nrows)
    self.assertEqual(expected_cellref, returned_cellref)

    cellref = 'a5'; ncolumns = -1; nrows = 3
    self.assertRaises(IndexError, tblfs.move_cell_along_tableau, cellref, ncolumns, nrows)
    cellref = 'a5'; ncolumns = 3; nrows = -8
    self.assertRaises(IndexError, tblfs.move_cell_along_tableau, cellref, ncolumns, nrows)

    cellref = 'a5'; ncolumns = 0; nrows = 0
    expected_cellref = cellref.upper()
    returned_cellref = tblfs.move_cell_along_tableau(cellref, ncolumns, nrows)
    self.assertEqual(expected_cellref, returned_cellref)
Example #4
0
 def generate_xlsx(self):
     workbook = xlsxwriter.Workbook(self.wb_filepath)
     self.worksheet = workbook.add_worksheet()
     self.cellref = 'C2'
     self.worksheet.write(self.cellref, 'Preços Históricos')
     self.cellref = 'A5'
     for histpriceitem in self.histprices:
         self.add_row_to_worksheet(histpriceitem)
         self.cellref = tblfs.move_cell_along_tableau(self.cellref, -7, 1)
     print('Closing ', self.wb_filepath)
     workbook.close()
Example #5
0
def adhoc_test5():
    # 2 forward
    cell_letters = 'zead'
    returned_number = tblfs.convert_columnletters_to_number_recursively_entrance(
        cell_letters)
    print(cell_letters, ' to number =>', returned_number)
    returned_cell_letters = tblfs.convert_number_to_columnletters_recursively(
        returned_number)
    print(returned_number, ' back to letters =>', returned_cell_letters)

    cell_letters = 'zead'
    returned_number = tblfs.convert_columnletters_to_number_nonrecursively(
        cell_letters)
    print(cell_letters, ' nonrec to number =>', returned_number)
    returned_cell_letters = tblfs.convert_number_to_columnletters_nonrecursively(
        returned_number)
    print(returned_number, ' nonrec back to letters =>', returned_cell_letters)

    cellref = 'b5'
    ncolumns = -1
    nrows = 3
    next_cellref = tblfs.move_cell_along_tableau(cellref, ncolumns, nrows)
    print(cellref, ' next_cellref =>', next_cellref)