Python xlsxwriter writing different rich text in the same cell

Source: Internet
Author: User

Recently to mark a large set of corpus, in order to facilitate labeling, the trigger word in the text of the position of red, in order to identify. The text of the same cell in the table that writes different Rich text is as follows:

Import Xlsxwriterworkbook = Xlsxwriter. Workbook (' tttt.xlsx ') worksheet = Workbook.add_worksheet () worksheet.set_column (' a:a ', ') #第一列宽度Format = Workbook.add _format ({' Font_name ': ' Kaiti ', ' font_size ': +, ' bold ': True}) #设置一个默认的格式RedFormat = Workbook.add_format ({' Font_name ': ' Kaiti ', ' font_size ': +, ' bold ': True, ' color ': ' red '} #在默认格式上加上颜色BlueFormat = Workbook.add_format ({' Font_name ': ' Kaiti ', ' font_size ': +, ' bold ': True, ' color ': ' Blue '} #在默认格式上加上颜色worksheet. write_rich_string (' A1 ', Format, ' This is ', Redformat, ' Red ', Blueformat, ' Blue ') #写入三种格式workbook. Close ()
#摘抄于: HTTPS://SEGMENTFAULT.COM/U/CHQBGE

The final result is

Python xlsxwriter writing different rich text in the same cell

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.