Python generates a huge Excel table Xlsxwriter__python

Source: Internet
Author: User
Originally I used XLWT to generate Excel, the resulting suffix named xls, but because the data is too much to report a: Valueerror:row index (65536) not a int in range (65536) error reason: generated in XLWT XLS files can support up to 65536 rows of data. But the data I've been working on will probably be near 25W data. So I found xlsxwriter this module, which generated a file suffix named. xlsx, which can support up to 1048576 rows of data, 16384 columns of data, my God, who else. Just use it. Write a simple usage here #coding: utf-8 import xlsxwriter workbook = Xlsxwriter. Workbook (' demo1.xlsx ') #创建一个excel文件 worksheet = workbook. Add_worksheet (U ' Sheet1 ') #在文件中创建一个名为TEST的sheet, no name defaults to Sheet1 worksheet. Set_column (' a:a ',) #设置第一列宽度为20像素 bold = workbook. Add_format ({' Bold ': True}) #设置一个加粗的格式对象 worksheet. Write (' A1 ', ' HELLO ') #在A1单元格写上HELLO worksheet. Write (' A2 ', ' World ', bold) #在A2上写上WORLD, and is set to bold worksheet. Write (' B2 ', U ' Chinese test ', bold) #在B2上写上中文加粗 worksheet. Write (2, 0, 35,5) #使用行列的方式写上数字32, worksheet. Write (3, 0, 35.5) #使用行列的时候第一行起始为0, so 2, 0 represents the first column of the third row, equivalent to A4 worksheet. Write (4, 0, ' =sum (A3:A4) ') #写上excel公式 Workbook.close ()
Reference to: http://blog.csdn.net/su377486/article/details/51175568

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.