Python XLSXWRITE可以创建的列数是否有限制?

时间:2016-04-20 02:39:52

标签: python xlsxwriter

我创建了一个Python脚本,该脚本使用sql_command块从包含56列的SQL服务器表中读取

...
    db_cursor.execute(sql_command)
    rows = db_cursor.fetchall()
    worksheet.set_column('A:A',11)       #[BRAND] [varchar](10) NULL,
...
    worksheet.set_column('BD:BD',11)       #[NEWBUSINESS_RENEWAL] [varchar](1) NULL
...
    worksheet.write('A1','BRAND', Headerfm)
...
    worksheet.write('BD1','NEWBUSINESS_RENEWAL', Headerfm)

此时我在行上使用for循环并写入行和列

    for Brand, ...NEWBUSINESS_RENEWAL in (rows)  
        worksheet.write(xlrow, xlcol, BRAND, Cellfm2)
        worksheet.write(xlrow, xlcol + 1, SUBCOMPANY, Cellfm1) 
...
        worksheet.write(xlrow, xlcol + 55, NEWBUSINESS_RENEWAL, Cellfm1)
        xlrow += 1
    workbook.close()

然后抛出错误或消息         Traceback(最近一次调用最后一次):   文件" D:\ Cognos_Testing \ Esri \ python \ xlsexport_v2.py",第282行,in     品牌,分公司,GROUP_,覆盖范围,POLICY_NUMBER,POLICY_INFORCE_DATE,POLICY_START_DATE,POLICY_END_DATE,POLCOUNT,RISKCOUNT,SUM_INSURED,注册,制造商,型号YEAR_MANUFACTURED,区县,邮政编码,STATE_,STREET_NUMBER,STREET_NAME,STREET_SUFFIX,STREET_OTHERDETAILS,GEOCODED_TOWN,GEOCODED_POSTCODE,GEOCODED_STATE ,GEOCODED_STREET_NAME,INSURED_NAME,INSURED_HOMEPHONE,INSURED_WORKPHONE,INSURED_MOBEPHONE,INSURED_OTHERPHONE,INSURED_EMAIL,SECOND_INSURED_NAME,SECOND_INSURED_HOMEPHONE,SECOND_INSURED_WORKPHONE,SECOND_INSURED_MOBEPHONE,SECOND_INSURED_EMAIL,AGENCY_NAME,经纪人,FLOOD_FLAG,FLOOD_PREMIUM,FLOOD_COVERAGE,FLOOD_RISK_CONTENTS,FLOOD_RISK_BUILDING,BUSHFIRE_RATING,禁运YEAR_CONSTRUCTED,CONSTRUCTION_TYPE,ROOF_TYPE,WALLTYPE (行)中的FLOORTYPE,UNIT_FLAG,HH_HIGH_RISK_AREA_FLAG,POLICY_STATUS,POLICY_PAID,NEWBUSINESS_RENEWAL: ValueError:要解压缩的值太多

1 个答案:

答案 0 :(得分:2)

似乎在没有回答问题的情况下解决了作者的问题,但是文档says" XlsxWriter支持Excel的工作表限制 1,048,576行16,384列"