當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。