Create excel file, Insert image, Draw Bar Graphs in excel files in python using xlsxwriter

Write Data to excel file:

import xlsxwriter# Create an new Excel file and add a worksheet.workbook = xlsxwriter.Workbook('test.xlsx')
worksheet = workbook.add_worksheet() # Sheet1
worksheet = workbook.add_worksheet(‘WorkLog’) # WorkLog
worksheet.write(0, 0, ‘MicroPyramid’)
worksheet.write(‘A1’, ‘MicroPyramid’)

Insert Image to Excel File:

worksheet.insert_image('B5', 'logo.png')
worksheet.insert_image(2, 4', 'logo.png')

Draw Charts in the excel Sheet:

chart = workbook.add_chart({'type': 'column'})
# Write some data to add to plot on the chart.
data = [
[5, 10, 15, 20, 25],
worksheet.write_column('A1', data[0])
# Configure the charts. In simplest case we just add some data series.
chart.add_series({'values': '=Sheet1!$A$1:$A$5'})
# Insert the chart into the worksheet.
worksheet.insert_chart('A7', chart)



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store