def to_location(self, key):
     if isinstance(key, tuple) and len(key) == 2:
         col, row = key
         if isinstance(col, basestring):
             col = column_name_to_index(col)
         if isinstance(col, (int, long)) and isinstance(row, (int, long)):
             return col, row
         return None
     elif isinstance(key, basestring):
         return cell_name_to_coordinates(key)
     return None
Beispiel #2
0
 def colIndex(self):
     return column_name_to_index(self.plainColumnName)
def _asColumnReference(columnName, worksheetInfo):
    worksheetInfo.append(columnName)
    columnReference = FLColumnReference(worksheetInfo)
    if column_name_to_index(columnReference.plainColumnName):
        return columnReference
Beispiel #4
0
def _asColumnReference(columnName, worksheetInfo):
    worksheetInfo.append(columnName)
    columnReference = FLColumnReference(worksheetInfo)
    if column_name_to_index(columnReference.plainColumnName):
        return columnReference
Beispiel #5
0
    def testColumnNameTo(self):
        "test column_name_to_index"
        self.assertEquals(column_name_to_index("A"), 1, "incorrect conversion"  )
        self.assertEquals(column_name_to_index("S"), 19, "incorrect conversion"  )
        self.assertEquals(column_name_to_index("Z"), 26, "incorrect conversion"  )
        self.assertEquals(column_name_to_index("AA"), 27, "incorrect conversion"  )
        self.assertEquals(column_name_to_index("aa"), 27, "incorrect conversion"  )
        self.assertEquals(column_name_to_index("AZ"), 52, "incorrect conversion"  )
        self.assertEquals(column_name_to_index("aZ"), 52, "incorrect conversion"  )
        self.assertEquals(column_name_to_index("BA"), 53, "incorrect conversion"  )
        self.assertEquals(column_name_to_index("Ba"), 53, "incorrect conversion"  )
        self.assertEquals(column_name_to_index("mjJ"), 9058, "incorrect conversion"  )
        self.assertEquals(column_name_to_index("MJJ"), 9058, "incorrect conversion"  )
        self.assertEquals(column_name_to_index("ZZZ"), 18278, "incorrect conversion")

        self.assertIsNone(column_name_to_index("AAAA"), "invalid column not None")
        self.assertIsNone(column_name_to_index("HELLO3"), "invalid column not None")
        self.assertIsNone(column_name_to_index("SHEET"), "invalid column not None")
        self.assertIsNone(column_name_to_index("@"), "invalid column not None")
        self.assertIsNone(column_name_to_index("33"), "invalid column not None")
        self.assertIsNone(column_name_to_index("FXSHRXX"), "invalid column not None (column too large for 32 bit int)")