def test_create_chart_w_multiple_ranges(self): ranges = [ pyoo.SheetAddress(0, 0, 2, 3), pyoo.SheetAddress(10, 10, 2, 3) ] with self.create_chart(ranges=ranges) as chart: self.assertEqual(['$A$1:$C$2', '$K$11:$M$12'], list(map(str, chart.ranges)))
def create_chart(self, name=None, position=None, ranges=None, **kwargs): self.__class__._chart_index += 1 name = name or 'Chart %d' % self.__class__._chart_index position = position or pyoo.SheetPosition(0, 0, 1000, 1000) ranges = ranges or pyoo.SheetAddress(0, 0, 2, 3) yield self.sheet.charts.create(name, position, ranges, **kwargs) del self.sheet.charts[name]
def test_range_text(self): address = pyoo.SheetAddress(0, 1, 2, 3) self.assertEqual('$B$1:$D$2', pyoo.text_type(address)) self.assertIsInstance(pyoo.text_type(address), pyoo.text_type)
def test_ranges_str(self): address = pyoo.SheetAddress(0, 1, 2, 3) self.assertEqual(b'$B$1:$D$2', str(address)) self.assertIsInstance(str(address), str)
def test_cell_text(self): address = pyoo.SheetAddress(0, 1) self.assertEqual(u'$B$1', pyoo.text_type(address)) self.assertIsInstance(pyoo.text_type(address), pyoo.text_type)
def test_cell_str(self): address = pyoo.SheetAddress(0, 1) self.assertEqual(b'$B$1', str(address)) self.assertIsInstance(str(address), str)
def test_replace_col_count(self): address = pyoo.SheetAddress(0, 1, 2, 3) self.assertEqual('$B$1:$B$2', str(address.replace(col_count=1)))
def test_replace_row(self): address = pyoo.SheetAddress(0, 1, 2, 3) self.assertEqual('$B$2:$D$3', str(address.replace(row=1)))
def test_replace_col(self): address = pyoo.SheetAddress(0, 1, 2, 3) self.assertEqual('$C$1:$E$2', str(address.replace(col=2)))
def test_range_formula_row_and_col_abs(self): address = pyoo.SheetAddress(0, 1, 2, 3) self.assertEqual('$B$1:$D$2', address.formula(row_abs=True, col_abs=True))
def test_range_formula_col_abs(self): address = pyoo.SheetAddress(0, 1, 2, 3) self.assertEqual('$B1:$D2', address.formula(col_abs=True))
def test_range_formula(self): address = pyoo.SheetAddress(0, 1, 2, 3) self.assertEqual('B1:D2', address.formula())
def test_cell_formula_row_and_col_abs(self): address = pyoo.SheetAddress(0, 1) self.assertEqual('$B$1', address.formula(row_abs=True, col_abs=True))
def test_cell_formula(self): address = pyoo.SheetAddress(0, 1) self.assertEqual('B1', address.formula())