学Python,用RPA

艺赛旗RPA2020.1版本 正在免费下载使用中,欢迎下载使用

www.i-search.com.cn/index.html?from=line1

--------2、生成图表并插入到excel---------------

创建一个柱状图(line chart)

chart_col = workbook.add_chart({‘type’: ‘line’})

配置第一个系列数据

chart_col.add_series({
# 这里的sheet1是默认的值,因为我们在新建sheet时没有指定sheet名
# 如果我们新建sheet时设置了sheet名,这里就要设置成相应的值
‘name’: ‘=Sheet1!$B1,categories:=Sheet1!1', 'categories': '=Sheet1!A2:2:A7,values:=Sheet1!7', 'values': '=Sheet1!B2:2:B$7’,
‘line’: {‘color’: ‘red’},
})

配置第二个系列数据

chart_col.add_series({
‘name’: ‘=Sheet1!$C1,categories:=Sheet1!1', 'categories': '=Sheet1!A2:2:A7,values:=Sheet1!7', 'values': '=Sheet1!C2:2:C$7’,
‘line’: {‘color’: ‘yellow’},
})

配置第二个系列数据(用了另一种语法)

chart_col.add_series({

‘name’: [‘Sheet1’, 0, 2],

‘categories’: [‘Sheet1’, 1, 0, 6, 0],

‘values’: [‘Sheet1’, 1, 2, 6, 2],

‘line’: {‘color’: ‘yellow’},

})

设置图表的title 和 x,y轴信息

chart_col.set_title({‘name’: ‘The xxx site Bug Analysis’})
chart_col.set_x_axis({‘name’: ‘Test number’})
chart_col.set_y_axis({‘name’: ‘Sample length (mm)’})

设置图表的风格

chart_col.set_style(1)

把图表插入到worksheet并设置偏移

worksheet.insert_chart(‘A10’, chart_col, {‘x_offset’: 25, ‘y_offset’: 10})

workbook.close()

RPA折线图写入表格

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-05-03
  • 2022-01-02
  • 2021-05-15
  • 2022-01-02
  • 2021-12-12
  • 2022-12-23
猜你喜欢
  • 2021-12-22
  • 2022-01-02
  • 2021-05-13
  • 2022-12-23
  • 2021-05-04
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案