title: win32com error - Internal error - the buffer length is not the sequence length encountered using dataframe.torecords()
body: <p>I am using the below code to copy my existing dataframe to an excel worksheet using the win32com.client . below is the code </p>
  
  <pre><code>    import win32com.client as win32,sys
      import pandas as pd
      excel_application = win32.Dispatch("Excel.Application")
      excel_application.Visible = True
      lta_df = pd.read_excel("C:/Temp/temp_lta.xlsx",sheetname=0,
                                      header=0,na_filter=False)
      lta_df["Updated"] = pd.to_datetime(lta_df["Updated"])
      workbook = excel_application.Workbooks.Open("C:/Temp/temp_lta.xlsx")
      ws= workbook.Sheets.Add(After=workbook.Sheets(workbook.Sheets.count))
      start_row= 1
      start_col = 5
      lta_df= lta_df.reset_index()
  
      ws.Range(ws.Cells(start_row,start_col),
       ws.Cells(start_row+len(lta_df.index)-1,start_col+len(lta_df.columns))
       ).Value =  lta_df.to_records(index=False)
  </code></pre>
  
  <p>I get the below error when I use to_records() </p>
  
  <pre><code>    Traceback (most recent call last):
  
        File "&lt;ipython-input-779-91e88023cb75&gt;", line 3, in &lt;module&gt;
          ).Value =  lta_df.to_records(index=False)
  
        File "C:\anaconda3\lib\site-packages\win32com\client\dynamic.py", line 565, in __setattr__
            self._oleobj_.Invoke(entry.dispid, 0, invoke_type, 0, value)
  
        TypeError: Internal error - the buffer length is not the sequence length!
  </code></pre>
  
  <p>what can be the solution for it. All the values are in str
  The same error is encountered when I use</p>
  
  <pre><code>      start_row = 1
        start_col = 1
        arr_temp = lta_df.values.copy(order="C")
        ws.Range(ws.Cells(start_row,start_col),
       ws.Cells(start_row+len(lta_df.index)-1,start_col+len(lta_df.columns))
       ).Value = arr_temp
  </code></pre>