def main(): wb = Workbook() # Creates a connection with a new workbook Range('A1').value = 'Foo 1' print Range('A1').value # 'Foo 1' Range('A1').value = [['Foo 1', 'Foo 2', 'Foo 3'], [10.0, 20.0, 30.0]] print Range('A1').table.value # or: Range('A1:C2').value # [['Foo 1', 'Foo 2', 'Foo 3'], [10.0, 20.0, 30.0]] print Sheet(1).name # 'Sheet1' chart = Chart.add(source_data=Range('A1').table)
def test_add_keywords(self): name = 'My Chart' chart_type = ChartType.xlLine Range('A1').value = chart_data chart = Chart.add(chart_type=chart_type, name=name, source_data=Range('A1').table) chart_actual = Chart(name) name_actual = chart_actual.name chart_type_actual = chart_actual.chart_type assert_equal(name, name_actual) if sys.platform.startswith('win'): assert_equal(chart_type, chart_type_actual) else: assert_equal(kw.line_chart, chart_type_actual)
def test_add_properties(self): name = 'My Chart' chart_type = ChartType.xlLine Range('Sheet2', 'A1').value = chart_data chart = Chart.add('Sheet2') chart.chart_type = chart_type chart.name = name chart.set_source_data(Range('Sheet2', 'A1').table) chart_actual = Chart('Sheet2', name) name_actual = chart_actual.name chart_type_actual = chart_actual.chart_type assert_equal(name, name_actual) if sys.platform.startswith('win'): assert_equal(chart_type, chart_type_actual) else: assert_equal(kw.line_chart, chart_type_actual)
from xlwings import Workbook, Sheet, Range, Chart wb = Workbook(r'C:\Users\mih\Desktop\Stock_Screener\Proj1.xlsx') Range('A1').value = 'Two 2' print Range('A1').value Range('A1').value = [['Too 1', 'Foo 2', 'Foo 3'], [10.0, 20.0, 40.0]] Range('A1').table.value # or: Range('A1:C2').value Sheet(1).name chart = Chart.add(source_data=Range('A1').table) wb.save("C:\Users\mih\Desktop\Stock_Screener\Proj1.xlsx")
import xlwings from xlwings import Workbook, Sheet, Range, Chart # Creates a connection with a new workbook # wb = Workbook() wb = Workbook.caller() Range('A1').value = 'Foo 1' print Range('A1').value Range('A1').value = [['Foo 1', 'Foo 2', 'Foo 3'], [10.0, 20.0, 30.0]] print Range('A1').table.value # or: Range('A1:C2').value print Sheet(1).name chart = Chart.add(source_data=Range('A1').table) # to open excel template # from xlwings import Workbook # Workbook.open_template()