import list to excel
Question: I want to import the python list to excel. My example code is:

    
    
    import win32com.client as win32
    
    excel = win32.gencache.EnsureDispatch('Excel.Application')
    excel.Visible = 1
    wb = excel.Workbooks.Add()
    ws = wb.Worksheets("Sheet1")
    
    list1 =("a","b","c","c","c","c","c","c","c","c")
    
    ws.Range("B1:B10").Value = list1
    

How I have to change the list1 type to use the code ws.Range("B1:B10").Value =
list1? What kind of list can use in excel file?


Answer: It looks like this [post](http://stackoverflow.com/questions/5014261/python-
excel-writing-to-multiple-cells-takes-time) may do what you need by wrapping
your range statement in a function like:

    
    
    def writeLinesToExcel(ws,lines): 
        ws.Range("A1:"+chr(len(lines)+96).upper()+str(len(lines[0]))).Value=lines
    

Then you can call `writeLineToExcel(ws,list1)`. You can also use things like
[["a"],["b"]] apparently... Based on your question, I'm not sure this appears
to be working for you. If your data is simple enough, you could just use a
loop,

    
    
    def writeRowsToExcel(ws,col,rows): 
    
        for i,l in enumerate(rows):
            ws.Cells(col,i)= l
    

then call `writeRowsToExcel(ws, col, rows)`. Other
[posts](http://stackoverflow.com/questions/21478946/writing-array-to-excel-in-
python-with-win32com) suggest this will be slow and to use other libraries
like `xlwt`.

