O'Reilly logo

Automate it! - Recipes to upskill your business by Chetan Giridhar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Building charts within Excel sheets

Excel sheets are capable of building a variety of charts, including line chart, bar chart, and pie charts among others that help us depict trends and visualize data.

Getting ready

For this recipe, we will use the same xlsxwriter module and use methods defined in the module to build charts.

How to do it...

  1. In this example, we will write a column in an Excel file that is filled with numbers. We can take the values in all the cells and construct a line chart:
     import xlsxwriter workbook = xlsxwriter.Workbook('chart_line.xlsx') worksheet = workbook.add_worksheet() data = [10, 40, 50, 20, 10, 50] worksheet.write_column('A1', data) chart = workbook.add_chart({'type': 'line'}) chart.add_series({'values': '=Sheet1!$A$1:$A$6'}) ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required