#!/usr/bin/python
# -*- coding:utf8 -*-
import xlwt
def write_data_to_excel():
print '开始生成'
wbk = xlwt.Workbook()
sheets = []
sheet = wbk.add_sheet('Sheet1',cell_overwrite_ok=True)
sheets.append(sheet)
for i in xrange(500):
print '正在生成:第'+str(i+1)+'条数据 . . .'
for j in xrange(769):
#计算第几个表
scount=j/256
#如果表的个数少于该有的个数,则新建
if(len(sheets) <= scount):
sheets.append(wbk.add_sheet('Sheet'+str(scount+1),cell_overwrite_ok=True))
#计算第几列,如果是256的倍数,序号应从0开始
col = j % 256
sheets[scount].write(i,col,str(j))
wbk.save('test.xls')
print '生成成功'
if __name__ == '__main__':
write_data_to_excel()