当前位置: 首页>>代码示例>>Python>>正文


Python xlwt.XFStyle方法代码示例

本文整理汇总了Python中xlwt.XFStyle方法的典型用法代码示例。如果您正苦于以下问题:Python xlwt.XFStyle方法的具体用法?Python xlwt.XFStyle怎么用?Python xlwt.XFStyle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在xlwt的用法示例。


在下文中一共展示了xlwt.XFStyle方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: set_style

# 需要导入模块: import xlwt [as 别名]
# 或者: from xlwt import XFStyle [as 别名]
def set_style(name, height, bold=False):
    style = xlwt.XFStyle()  # 初始化样式

    font = xlwt.Font()  # 为样式创建字体
    font.name = name  # 'Times New Roman'
    font.bold = bold
    font.color_index = 4
    font.height = height

    # borders= xlwt.Borders()
    # borders.left= 6
    # borders.right= 6
    # borders.top= 6
    # borders.bottom= 6

    style.font = font
    # style.borders = borders

    return style 
开发者ID:Maicius,项目名称:UniversityRecruitment-sSurvey,代码行数:21,代码来源:AnalysisData.py

示例2: set_style

# 需要导入模块: import xlwt [as 别名]
# 或者: from xlwt import XFStyle [as 别名]
def set_style(name, height, bold=False):
    # 设置字体
    style = xlwt.XFStyle()
    font = xlwt.Font()
    font.name = name
    font.bold = bold
    font.color_index = 4
    font.height = height
    style.font = font
    # 设置边框
    borders = xlwt.Borders()
    # 细实线:1,小粗实线:2,细虚线:3,中细虚线:4,大粗实线:5,双线:6,细点虚线:7
    # 大粗虚线:8,细点划线:9,粗点划线:10,细双点划线:11,粗双点划线:12,斜点划线:13
    borders.left = 1
    borders.right = 1
    borders.top = 1
    borders.bottom = 1
    style.borders = borders

    return style


# 写Excel 
开发者ID:jarvisqi,项目名称:nlp_learning,代码行数:25,代码来源:db_excel.py

示例3: set_excel_style

# 需要导入模块: import xlwt [as 别名]
# 或者: from xlwt import XFStyle [as 别名]
def set_excel_style(name, height, bold=False):
    """Set excel style.
    """
    style = xlwt.XFStyle() # 初始化样式
    font = xlwt.Font() # 为样式创建字体
    font.name = name # 例如'Times New Roman'
    font.bold = bold
    font.color_index = 4
    font.height = height
    if bold:
        borders = xlwt.Borders()
        borders.left = 6
        borders.right = 6
        borders.top = 6
        borders.bottom = 6
        style.borders = borders
    style.font = font
    return style 
开发者ID:Decalogue,项目名称:chat,代码行数:20,代码来源:mytools.py

示例4: _convert_to_style

# 需要导入模块: import xlwt [as 别名]
# 或者: from xlwt import XFStyle [as 别名]
def _convert_to_style(cls, style_dict, num_format_str=None):
        """
        converts a style_dict to an xlwt style object
        Parameters
        ----------
        style_dict : style dictionary to convert
        num_format_str : optional number format string
        """
        import xlwt

        if style_dict:
            xlwt_stylestr = cls._style_to_xlwt(style_dict)
            style = xlwt.easyxf(xlwt_stylestr, field_sep=',', line_sep=';')
        else:
            style = xlwt.XFStyle()
        if num_format_str is not None:
            style.num_format_str = num_format_str

        return style 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:21,代码来源:excel.py

示例5: set_style

# 需要导入模块: import xlwt [as 别名]
# 或者: from xlwt import XFStyle [as 别名]
def set_style(self):
        '''
        设置excel样式
        '''
        self.sheet.col(1).width = 256 * 30
        self.sheet.col(2).width = 256 * 15
        self.sheet.col(3).width = 256 * 20
        self.sheet.col(4).width = 256 * 20
        self.sheet.col(5).width = 256 * 60
        self.sheet.col(6).width = 256 * 15
        self.sheet.col(9).width = 256 * 15
        self.sheet.row(0).height_mismatch = True
        self.sheet.row(0).height = 20 * 20
        self.basic_style = xlwt.XFStyle()
        al = xlwt.Alignment()
        # 垂直对齐
        al.horz = al.HORZ_CENTER
        # 水平对齐
        al.vert = al.VERT_CENTER
        # 换行
        al.wrap = al.WRAP_AT_RIGHT
        # 设置边框
        borders = xlwt.Borders()
        borders.left = 6
        borders.right = 6
        borders.top = 6
        borders.bottom = 6

        self.basic_style.alignment = al
        self.basic_style.borders = borders 
开发者ID:CyrusRenty,项目名称:CNKI-download,代码行数:32,代码来源:GetPageDetail.py

示例6: _convert_to_style

# 需要导入模块: import xlwt [as 别名]
# 或者: from xlwt import XFStyle [as 别名]
def _convert_to_style(cls, style_dict, num_format_str=None):
        """
        converts a style_dict to an xlwt style object
        Parameters
        ----------
        style_dict: style dictionary to convert
        num_format_str: optional number format string
        """
        import xlwt

        if style_dict:
            xlwt_stylestr = cls._style_to_xlwt(style_dict)
            style = xlwt.easyxf(xlwt_stylestr, field_sep=',', line_sep=';')
        else:
            style = xlwt.XFStyle()
        if num_format_str is not None:
            style.num_format_str = num_format_str

        return style 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:21,代码来源:excel.py

示例7: export2xls

# 需要导入模块: import xlwt [as 别名]
# 或者: from xlwt import XFStyle [as 别名]
def export2xls(self):
        import xlwt
        font0 = xlwt.Font()
        font0.bold = True
        font0.height = 300
        print((font0.height))

        style0 = xlwt.XFStyle()
        style0.font = font0

        style1 = xlwt.XFStyle()
        style1.num_format_str = 'D-MMM-YY'

        wb = xlwt.Workbook()
        ws = wb.add_sheet('A Test Sheet')

        ws.write(0, 0, 'Test', style0)
        ws.write(2, 0, 1)
        ws.write(2, 1, 1)
        ws.write(2, 2, xlwt.Formula("A3+B3"))

        wb.save('datasheet.xls')
        os.system("gnumeric datasheet.xls") 
开发者ID:jjgomera,项目名称:pychemqt,代码行数:25,代码来源:pump.py

示例8: create_simple_xls

# 需要导入模块: import xlwt [as 别名]
# 或者: from xlwt import XFStyle [as 别名]
def create_simple_xls(self, **kw):
        font0 = xlwt.Font()
        font0.name = 'Times New Roman'
        font0.colour_index = 2
        font0.bold = True

        style0 = xlwt.XFStyle()
        style0.font = font0

        style1 = xlwt.XFStyle()
        style1.num_format_str = 'D-MMM-YY'

        wb = xlwt.Workbook(**kw)
        ws = wb.add_sheet('A Test Sheet')

        ws.write(0, 0, 'Test', style0)
        ws.write(1, 0, datetime(2010, 12, 5), style1)
        ws.write(2, 0, 1)
        ws.write(2, 1, 1)
        ws.write(2, 2, xlwt.Formula("A3+B3"))
        return wb, ws 
开发者ID:alexfeng,项目名称:InternationalizationScript-iOS,代码行数:23,代码来源:test_simple.py

示例9: title_style

# 需要导入模块: import xlwt [as 别名]
# 或者: from xlwt import XFStyle [as 别名]
def title_style():
    '''
    '''
    style = xlwt.XFStyle()
    style.font = base_xls.font(bold=True, colour=0x0A)
    style.alignment = base_xls.alignment(horz=0x02)
    style.borders = base_xls.borders(line=0x01)
    style.pattern = base_xls.pattern(solid_pattern=0x01, fore_colour=0x1F)
    return style 
开发者ID:Scemoon,项目名称:lpts,代码行数:11,代码来源:lptxls.py

示例10: build_result

# 需要导入模块: import xlwt [as 别名]
# 或者: from xlwt import XFStyle [as 别名]
def build_result(self, coupon_descr_list):
        stk_wb = xlwt.Workbook()
        myfont = xlwt.Font()
        mystyle = xlwt.XFStyle()
        mystyle.font = myfont
        sheet_name = str(date.today())
        sheet = stk_wb.add_sheet(sheet_name, cell_overwrite_ok=True)

        for index, item in enumerate(coupon_descr_list):
            self._write_decision_data(item, index*5, sheet)
            self._write_selected_data(item, index*5, sheet)

        stk_wb.save('../output/funda_rotation_{}'.format(sheet_name) + '.xls') 
开发者ID:licxcx,项目名称:stockbot,代码行数:15,代码来源:funda_rotation.py

示例11: xlformat_factory

# 需要导入模块: import xlwt [as 别名]
# 或者: from xlwt import XFStyle [as 别名]
def xlformat_factory(format):
    """
    copy the format, perform any overrides, and attach an xlstyle instance
    copied format is returned
    """

    #if we have created an excel format already using this format,
    #don't recreate it; mlab.FormatObj override has to make objs with
    #the same props hash to the same value
    key = hash(format)
    fmt_ = xlformat_factory.created_formats.get(key)
    if fmt_ is not None:
        return fmt_

    format = copy.deepcopy(format)

    xlstyle = excel.XFStyle()
    if isinstance(format, mlab.FormatPercent):
       zeros = ''.join(['0']*format.precision)
       xlstyle.num_format_str = '0.%s%%;[RED]-0.%s%%'%(zeros, zeros)
       format.scale = 1.
    elif isinstance(format, mlab.FormatFloat):
        if format.precision>0:
            zeros = ''.join(['0']*format.precision)
            xlstyle.num_format_str = '#,##0.%s;[RED]-#,##0.%s'%(zeros, zeros)
        else:
            xlstyle.num_format_str = '#,##;[RED]-#,##'
    elif isinstance(format, mlab.FormatInt):
        xlstyle.num_format_str = '#,##;[RED]-#,##'
    else:
        xlstyle = None

    format.xlstyle = xlstyle

    xlformat_factory.created_formats[ key ] = format

    return format 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:39,代码来源:exceltools.py

示例12: export

# 需要导入模块: import xlwt [as 别名]
# 或者: from xlwt import XFStyle [as 别名]
def export(request):
    if request.method == "GET":
        asset_list = models.Assets.objects.all()
        bt = ['ID','主机名','外网地址','内网地址','系统类型','机房','ServerID','GameID','角色','创建时间','更新时间','是否启用','备注']
        wb = xlwt.Workbook(encoding='utf-8')
        sh = wb.add_sheet("主机详情",cell_overwrite_ok=True)
        dateFormat = xlwt.XFStyle()
        dateFormat.num_format_str = 'yyyy/mm/dd'
        for i in range(len(bt)):
            sh.write(0,i,bt[i])
        for i in range(len(asset_list)):
            sh.write(i + 1, 0, asset_list[i].id)
            sh.write(i + 1, 1, asset_list[i].hostname)
            sh.write(i + 1, 2, asset_list[i].wip)
            sh.write(i + 1, 3, asset_list[i].lip)
            sh.write(i + 1, 4, asset_list[i].system_type)
            for idc in asset_list[i].idc_set.all():
                sh.write(i + 1, 5, idc.name)
            sh.write(i + 1, 6, asset_list[i].serverid)
            sh.write(i + 1, 7, asset_list[i].gameid)
            for g in asset_list[i].hostgroup_set.all():
                sh.write(i + 1, 8, g.name)
            sh.write(i + 1, 9, asset_list[i].ctime,dateFormat)
            sh.write(i + 1, 10, asset_list[i].utime,dateFormat)
            sh.write(i + 1, 11, asset_list[i].get_online_status_display())
            sh.write(i + 1, 12, asset_list[i].memo)
        response = HttpResponse(content_type='application/vnd.ms-excel')
        response['Content-Disposition'] = 'attachment; filename=asset' + time.strftime('%Y%m%d', time.localtime(
                time.time())) + '.xls'
        wb.save(response)

        return response 
开发者ID:cc0411,项目名称:devops,代码行数:34,代码来源:views.py

示例13: export_users_xls

# 需要导入模块: import xlwt [as 别名]
# 或者: from xlwt import XFStyle [as 别名]
def export_users_xls(request):
    response = HttpResponse(content_type='application/ms-excel')
    response['Content-Disposition'] = 'attachment; filename="customers.xls"'

    wb = xlwt.Workbook(encoding='utf-8')
    ws = wb.add_sheet('Customers')

    # Sheet header, first row
    row_num = 0

    font_style = xlwt.XFStyle()
    font_style.font.bold = True

    columns = ['Nome', 'Sobrenome', 'E-mail', 'Nascimento', 'Criado em']

    for col_num in range(len(columns)):
        ws.write(row_num, col_num, columns[col_num], font_style)

    # Sheet body, remaining rows
    default_style = xlwt.XFStyle()

    rows = Customer.objects.all().values_list('first_name',
                                              'last_name',
                                              'email',
                                              'birthday',
                                              'created')
    for row, rowdata in enumerate(rows):
        row_num += 1
        for col, val in enumerate(rowdata):
            if isinstance(val, datetime):
                val = val.strftime('%d/%m/%Y %H:%M')
            elif isinstance(val, date):
                val = val.strftime('%d/%m/%Y')
            ws.write(row_num, col, val, default_style)

    wb.save(response)
    return response 
开发者ID:rg3915,项目名称:django-experience,代码行数:39,代码来源:views.py

示例14: cell_style

# 需要导入模块: import xlwt [as 别名]
# 或者: from xlwt import XFStyle [as 别名]
def cell_style():
    '''
    '''
    style = xlwt.XFStyle()
    style.font = base_xls.font(bold=True, colour=0x08)
    style.alignment = base_xls.alignment(horz=0x01)
    style.borders = base_xls.borders(line=0x01)
    style.pattern = base_xls.pattern(solid_pattern=0x01, fore_colour=0x2B)
    return style 
开发者ID:Scemoon,项目名称:lpts,代码行数:11,代码来源:lptxls.py

示例15: info_style

# 需要导入模块: import xlwt [as 别名]
# 或者: from xlwt import XFStyle [as 别名]
def info_style():
    '''
    '''
    style = xlwt.XFStyle()
    style.font = base_xls.font(bold=True, colour=0x08)
    style.alignment = base_xls.alignment()
    style.alignment.wrap = 1
    style.borders = base_xls.borders(line=0x01)
    style.pattern = base_xls.pattern(solid_pattern=0x00, fore_colour=0x2A)
    return style 
开发者ID:Scemoon,项目名称:lpts,代码行数:12,代码来源:lptxls.py


注:本文中的xlwt.XFStyle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。