def time_openpyxl_optimised():
 start_time = clock()
 workbook = openpyxl.workbook.Workbook(optimized_write=True)
 worksheet = workbook.create_sheet()
 for row in range((row_max // 2)):
  string_data = [('Row: %d Col: %d' % (row, col)) for col in range(col_max)]
  worksheet.append(string_data)
  num_data = [(row + col) for col in range(col_max)]
  worksheet.append(num_data)
 workbook.save('openpyxl_opt.xlsx')
 elapsed = (clock() - start_time)
 print_elapsed_time('openpyxl   (optimised)', elapsed)

def time_openpyxl_optimised ( ) : start_time = clock ( ) workbook = openpyxl . workbook . Workbook ( optimized_write = True ) worksheet = workbook . create_sheet ( ) for row in range ( ( row_max // 2 ) ) : string_data = [ ( 'Row: %d Col: %d' % ( row , col ) ) for col in range ( col_max ) ] worksheet . append ( string_data ) num_data = [ ( row + col ) for col in range ( col_max ) ] worksheet . append ( num_data ) workbook . save ( 'openpyxl_opt.xlsx' ) elapsed = ( clock ( ) - start_time ) print_elapsed_time ( 'openpyxl   (optimised)' , elapsed )
run openpyxl in optimised mode .