How to use the pylightxl.database.index2address function in pylightxl

To help you get started, we’ve selected a few pylightxl 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 PydPiper / pylightxl / test / test_readxl.py View on Github external
def test_index2address(self):
        self.assertEqual(index2address(1, 1), 'A1')
        self.assertEqual(index2address(1000, 1), 'A1000')
        self.assertEqual(index2address(1048576, 1), 'A1048576')

        self.assertEqual(index2address(1, 26), 'Z1')
        self.assertEqual(index2address(1, 27), 'AA1')
        self.assertEqual(index2address(1, 53), 'BA1')
        self.assertEqual(index2address(1, 667), 'YQ1')
        self.assertEqual(index2address(1, 703), 'AAA1')
        self.assertEqual(index2address(1, 11496), 'PZD1')
        self.assertEqual(index2address(1, 11685), 'QGK1')
        self.assertEqual(index2address(1, 16384), 'XFD1')

        self.assertEqual(index2address(1048576, 16384), 'XFD1048576')
github PydPiper / pylightxl / test / test_readxl.py View on Github external
def test_index2address(self):
        self.assertEqual(index2address(1, 1), 'A1')
        self.assertEqual(index2address(1000, 1), 'A1000')
        self.assertEqual(index2address(1048576, 1), 'A1048576')

        self.assertEqual(index2address(1, 26), 'Z1')
        self.assertEqual(index2address(1, 27), 'AA1')
        self.assertEqual(index2address(1, 53), 'BA1')
        self.assertEqual(index2address(1, 667), 'YQ1')
        self.assertEqual(index2address(1, 703), 'AAA1')
        self.assertEqual(index2address(1, 11496), 'PZD1')
        self.assertEqual(index2address(1, 11685), 'QGK1')
        self.assertEqual(index2address(1, 16384), 'XFD1')

        self.assertEqual(index2address(1048576, 16384), 'XFD1048576')
github PydPiper / pylightxl / test / test_readxl.py View on Github external
def test_index2address_baddata(self):
        with self.assertRaises(ValueError) as e:
            index2address(row='', col=1)
            self.assertEqual(e, 'Error - Incorrect row ('') entry. Row must either be a int or float')
        with self.assertRaises(ValueError) as e:
            index2address(1, '')
            self.assertEqual(e, 'Error - Incorrect col ('') entry. Col must either be a int or float')
        with self.assertRaises(ValueError) as e:
            index2address(0, 0)
            self.assertEqual(e, 'Error - Row (0) and Col (0) entry cannot be less than 1')
github PydPiper / pylightxl / test / test_readxl.py View on Github external
def test_index2address(self):
        self.assertEqual(index2address(1, 1), 'A1')
        self.assertEqual(index2address(1000, 1), 'A1000')
        self.assertEqual(index2address(1048576, 1), 'A1048576')

        self.assertEqual(index2address(1, 26), 'Z1')
        self.assertEqual(index2address(1, 27), 'AA1')
        self.assertEqual(index2address(1, 53), 'BA1')
        self.assertEqual(index2address(1, 667), 'YQ1')
        self.assertEqual(index2address(1, 703), 'AAA1')
        self.assertEqual(index2address(1, 11496), 'PZD1')
        self.assertEqual(index2address(1, 11685), 'QGK1')
        self.assertEqual(index2address(1, 16384), 'XFD1')

        self.assertEqual(index2address(1048576, 16384), 'XFD1048576')
github PydPiper / pylightxl / test / test_readxl.py View on Github external
def test_index2address(self):
        self.assertEqual(index2address(1, 1), 'A1')
        self.assertEqual(index2address(1000, 1), 'A1000')
        self.assertEqual(index2address(1048576, 1), 'A1048576')

        self.assertEqual(index2address(1, 26), 'Z1')
        self.assertEqual(index2address(1, 27), 'AA1')
        self.assertEqual(index2address(1, 53), 'BA1')
        self.assertEqual(index2address(1, 667), 'YQ1')
        self.assertEqual(index2address(1, 703), 'AAA1')
        self.assertEqual(index2address(1, 11496), 'PZD1')
        self.assertEqual(index2address(1, 11685), 'QGK1')
        self.assertEqual(index2address(1, 16384), 'XFD1')

        self.assertEqual(index2address(1048576, 16384), 'XFD1048576')
github PydPiper / pylightxl / test / test_readxl.py View on Github external
def test_index2address(self):
        self.assertEqual(index2address(1, 1), 'A1')
        self.assertEqual(index2address(1000, 1), 'A1000')
        self.assertEqual(index2address(1048576, 1), 'A1048576')

        self.assertEqual(index2address(1, 26), 'Z1')
        self.assertEqual(index2address(1, 27), 'AA1')
        self.assertEqual(index2address(1, 53), 'BA1')
        self.assertEqual(index2address(1, 667), 'YQ1')
        self.assertEqual(index2address(1, 703), 'AAA1')
        self.assertEqual(index2address(1, 11496), 'PZD1')
        self.assertEqual(index2address(1, 11685), 'QGK1')
        self.assertEqual(index2address(1, 16384), 'XFD1')

        self.assertEqual(index2address(1048576, 16384), 'XFD1048576')
github PydPiper / pylightxl / pylightxl / writexl.py View on Github external
'\r\n' \
                ''

    # location: row tag for xml_base
    # inserts: row_num (ex: 1), num_of_cr_tags (ex: 1:5), many_tag_cr
    xml_tag_row = '{many_tag_cr}\r\n'

    # location: c r tag for xml_tag_row
    # inserts: address, str_option (t="s" for sharedStrings or t="str" for formulas), tag_formula, val
    xml_tag_cr = '{tag_formula}{val}'

    ws_size = db.ws(sheet_name).size
    if ws_size == [0,0] or ws_size == [1,1]:
        sheet_size_address = 'A1'
    else:
        sheet_size_address = 'A1:' + index2address(ws_size[0],ws_size[1])

    many_tag_row = ''
    for rowID, row in enumerate(db.ws(sheet_name).rows, 1):
        many_tag_cr = ''
        tag_cr = False
        num_of_cr_tags_counter = 0
        for colID, val in enumerate(row, 1):
            address = index2address(rowID, colID)
            str_option = ''
            tag_formula = ''
            try:
                readin_formula = db.ws(sheet_name)._data[index2address(rowID, colID)]['f']
            except KeyError:
                readin_formula = ''

            if val != '':
github PydPiper / pylightxl / pylightxl / writexl.py View on Github external
# inserts: address, str_option (t="s" for sharedStrings or t="str" for formulas), tag_formula, val
    xml_tag_cr = '{tag_formula}{val}'

    ws_size = db.ws(sheet_name).size
    if ws_size == [0,0] or ws_size == [1,1]:
        sheet_size_address = 'A1'
    else:
        sheet_size_address = 'A1:' + index2address(ws_size[0],ws_size[1])

    many_tag_row = ''
    for rowID, row in enumerate(db.ws(sheet_name).rows, 1):
        many_tag_cr = ''
        tag_cr = False
        num_of_cr_tags_counter = 0
        for colID, val in enumerate(row, 1):
            address = index2address(rowID, colID)
            str_option = ''
            tag_formula = ''
            try:
                readin_formula = db.ws(sheet_name)._data[index2address(rowID, colID)]['f']
            except KeyError:
                readin_formula = ''

            if val != '':
                if type(val) is str and val[0] != '=':
                    str_option = 't="s"'
                    try:
                        # replace val with its sharedStrings index, note sharedString index does start at 0
                        val = db._sharedStrings.index(val)
                    except ValueError:
                        db._sharedStrings.append(val)
                        val = db._sharedStrings.index(val)
github PydPiper / pylightxl / pylightxl / writexl.py View on Github external
if ws_size == [0,0] or ws_size == [1,1]:
        sheet_size_address = 'A1'
    else:
        sheet_size_address = 'A1:' + index2address(ws_size[0],ws_size[1])

    many_tag_row = ''
    for rowID, row in enumerate(db.ws(sheet_name).rows, 1):
        many_tag_cr = ''
        tag_cr = False
        num_of_cr_tags_counter = 0
        for colID, val in enumerate(row, 1):
            address = index2address(rowID, colID)
            str_option = ''
            tag_formula = ''
            try:
                readin_formula = db.ws(sheet_name)._data[index2address(rowID, colID)]['f']
            except KeyError:
                readin_formula = ''

            if val != '':
                if type(val) is str and val[0] != '=':
                    str_option = 't="s"'
                    try:
                        # replace val with its sharedStrings index, note sharedString index does start at 0
                        val = db._sharedStrings.index(val)
                    except ValueError:
                        db._sharedStrings.append(val)
                        val = db._sharedStrings.index(val)

                if readin_formula != '':
                    str_option = 't="str"'
                    tag_formula = '{f}'.format(f=readin_formula)