title: Is there a solution for xlsxwriter error in python
body: <p>I am working on analyzing data on python and export it to Excel so I used <code>xlwt</code> library in one file and another file used <code>xlsxwriter</code>. However, when using function <code>workbook.write()</code> with <code>xlsxwriter</code>, to assign the values to Excel, I got this weird error. Even though I scanned the Internet and Googled this error, and wrote the code correctly, I still couldn't find solution to this error. Furthermore, I would like to plot the curves in Excel (scatter plot) and I wasn't able to plot the curves.</p>
  
  <p>Does anyone can help me fix this error and how to plot graph in excel from python? I also installed the <code>openpyxl</code> library.</p>
  
  <p>I am using Pycharm as an editor for Python 3.7
  this is my code:</p>
  
  <pre class="lang-py prettyprint-override"><code>import cv2
  import numpy as np
  from skimage.feature import peak_local_max
  from skimage.morphology import watershed
  from scipy import ndimage
  import math
  import random as rand
  import matplotlib.pyplot as plt
  import pandas as pd
  import xlsxwriter
  # import openpyxl module
  import openpyxl
  from openpyxl.chart import ScatterChart, Reference, Series
  workbook = xlsxwriter.Workbook('image_analysis.xlsx')
  worksheet = workbook.add_worksheet()
  image = cv2.imread('D:\My work\MASTERS WORK\Sample H 4  1 2020\Sample H1\SampleH1_#2_72pxfor1cm_out.jpg')
  gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
  thresh = cv2.threshold(gray, 0, 255, cv2.THRESH_BINARY_INV+ cv2.THRESH_OTSU)[1]
  thresh=thresh/255
  cv2.imshow('thresh',thresh)
  cv2.waitKey(0)
  h,w =image.shape[:2]
  print('The dimensions of the image =',h,w)
  # Compute Euclidean distance from every binary pixel
  # to the nearest zero pixel then find peaks
  distance_map = ndimage.distance_transform_edt(thresh)
  local_max = peak_local_max(distance_map, indices=False, min_distance=20, labels=thresh)
  # Perform connected component analysis then apply Watershed
  markers = ndimage.label(local_max, structure=np.ones((3, 3)))[0]
  labels = watershed(-distance_map, markers, mask=thresh)
  # Iterate through unique labels
  n = 0
  Areas = []
  row = 2
  col = 0
  gamma = 2.6
  W =[]
  style = workbook.add_format({'bold': True, 'font_color': 'red'})
  workbook.write(0,col, "AREA",style)
  workbook.write(0,col+1, "Raduis",style)
  workbook.write(0,col+2, "Volume",style)
  workbook.write(0,col+3,  "Weight",style)
  workbook.write(0,col+4 ,  "Raduis(cm)",style)
  workbook.write(0,col+5 ,  "Weight(gm)",style)
  workbook.write(0,col+6 ,  "Sorted raduis",style)
  workbook.write(0,col+7 ,  "Sorted weight",style)
  workbook.write(0,col+8,  "Cumulative weight",style)
  workbook.write(0,col+9,  "% passing",style)
  workbook.write(0,col+10,  "Diameter (mm)",style)
  raduis=[]
  for item in Areas:
      r = ((item/math.pi)**0.5) # raduis is in cm units
      raduis.append(r)
      v = (4/3)*math.pi*r**3  # volume in cubic cm units and considered as sphere
      w = gamma*v # weight is in gram units
      workbook.write(row, col, item)
      workbook.write(row, col + 1, r)
      workbook.write(row, col + 2, v)
      workbook.write(row, col + 3, w)
      row += 1
  
      r=2
      s=[]
      for k in raduis:
          r2 = k/scale
          s.append(r2)
          workbook.write(r, col + 4, r2)
          weight = (4/3)*3.141592*2.6*r2**3
          workbook.write(r, col + 5, weight)
          W.append(weight)
          r+=1
  </code></pre>
  
  <p>But I got this error:</p>
  
  <blockquote>
    <p>File "D:/My work/My images/Watershed_seg.py", line 94, in 
        workbook.write(0,col, "AREA",style)
    AttributeError: 'Workbook' object has no attribute 'write'</p>
  </blockquote>