Export data to excel using RhinoPython / GHPython

Hi all,

I am working on a quite straightforward python script which is supposed to create a .xls file and write something in it. I run this script in both RhinoPython and GHPython, but got following error:

Message: sequence item 0: expected bytes or byte array, str found

  line 86, in get_biff_record, "C:\Users\XXXXXXX\Downloads\xlwt-1.1.2\xlwt\BIFFRecords.py"
  line 622, in _Workbook__sst_rec, "C:\Users\XXXXXXX\Downloads\xlwt-1.1.2\xlwt\Workbook.py"
  line 696, in save, "C:\Users\XXXXXXX\Downloads\xlwt-1.1.2\xlwt\Workbook.py"
  line 6, in <module>, "C:\Users\XXXXXXX\AppData\Local\Temp\TempScript.py"
  line 660, in get_biff_data, "C:\Users\XXXXXXX\Downloads\xlwt-1.1.2\xlwt\Workbook.py"

Here is my script:

import xlwt

wb = xlwt.Workbook()
sheet = wb.add_sheet("TestSheet")

The last line wb.save("Test.xls") triggers error. This script runs well in other environment like cmd and Aptana Studio… I wonder is there any problem with settings or installation?


Hi Dou,

Is XLWT compatible with IronPython?

You might search for another library that can write Excel files and that is compatible with IronPython. Of course, you can easily write a common-delimited file (CSV) with Python - Excel reads these too…

– D

Hi Dale,

XLWT can be successfully imported. Anyway, let me try CSV, seems much easier. Thanks!


where can i find the method to install a xls library for python


Would csv format be sufficient for you? It is very easy to write csv files using the import csv built in library in Ironpython in Rhino. I think the most popular Excel libraries only work in Cpython, not Ironpython.

You can also use clr for a dotNet experience but I have no knowledge of that…