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


Python xlwt.easyxf方法代码示例

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


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

示例1: __init__

# 需要导入模块: import xlwt [as 别名]
# 或者: from xlwt import easyxf [as 别名]
def __init__(self, path, engine=None, encoding=None, mode='w',
                 **engine_kwargs):
        # Use the xlwt module as the Excel writer.
        import xlwt
        engine_kwargs['engine'] = engine

        if mode == 'a':
            raise ValueError('Append mode is not supported with xlwt!')

        super(_XlwtWriter, self).__init__(path, mode=mode, **engine_kwargs)

        if encoding is None:
            encoding = 'ascii'
        self.book = xlwt.Workbook(encoding=encoding)
        self.fm_datetime = xlwt.easyxf(num_format_str=self.datetime_format)
        self.fm_date = xlwt.easyxf(num_format_str=self.date_format) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:18,代码来源:excel.py

示例2: _convert_to_style

# 需要导入模块: import xlwt [as 别名]
# 或者: from xlwt import easyxf [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

示例3: _convert_to_style

# 需要导入模块: import xlwt [as 别名]
# 或者: from xlwt import easyxf [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

示例4: print_header_titles

# 需要导入模块: import xlwt [as 别名]
# 或者: from xlwt import easyxf [as 别名]
def print_header_titles(self, ws, _p, data, row_position, xlwtlib, _xs):
        cell_format = _xs['bold'] + _xs['fill_blue'] + _xs['borders_all']
        cell_style = xlwtlib.easyxf(cell_format)
        cell_style_center = xlwtlib.easyxf(cell_format + _xs['center'])

        c_specs = [
            ('fy', 1, 0, 'text', _('Fiscal Year'), None, cell_style_center),
            ('af', 1, 0, 'text', _('Accounts Filter'),
             None, cell_style_center),
            ('df', 1, 0, 'text', _p.filter_form(data) == 'filter_date' and _(
                'Dates Filter') or _('Periods Filter'), None,
             cell_style_center),
            ('pf', 1, 0, 'text',  _('Partners Filter'),
             None, cell_style_center),
            ('tm', 1, 0, 'text',  _('Target Moves'), None, cell_style_center),
            ('ib', 1, 0, 'text',  _('Initial Balance'),
             None, cell_style_center),
            ('coa', 1, 0, 'text', _('Chart of Account'),
             None, cell_style_center),
        ]
        row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
        row_position = self.xls_write_row(
            ws, row_position, row_data, row_style=cell_style)
        return row_position 
开发者ID:iw3hxn,项目名称:LibrERP,代码行数:26,代码来源:partners_balance_xls.py

示例5: from_data

# 需要导入模块: import xlwt [as 别名]
# 或者: from xlwt import easyxf [as 别名]
def from_data(self, fields, rows):
        workbook = xlwt.Workbook()
        worksheet = workbook.add_sheet('Sheet 1')

        for i, fieldname in enumerate(fields):
            worksheet.write(0, i, fieldname)
            worksheet.col(i).width = 8000 # around 220 pixels

        style = xlwt.easyxf('align: wrap yes')

        for row_index, row in enumerate(rows):
            for cell_index, cell_value in enumerate(row):
                if isinstance(cell_value, basestring):
                    cell_value = re.sub("\r", " ", cell_value)
                if cell_value is False: cell_value = None
                worksheet.write(row_index + 1, cell_index, cell_value, style)

        fp = StringIO()
        workbook.save(fp)
        fp.seek(0)
        data = fp.read()
        fp.close()
        return data 
开发者ID:iw3hxn,项目名称:LibrERP,代码行数:25,代码来源:main.py

示例6: _generate_excel

# 需要导入模块: import xlwt [as 别名]
# 或者: from xlwt import easyxf [as 别名]
def _generate_excel(response, columns, headers, grads):
    import xlwt
    book = xlwt.Workbook(encoding='utf-8')
    sheet = book.add_sheet('Search Results')
    hdrstyle = xlwt.easyxf('font: bold on; pattern: pattern solid, fore_colour grey25; align: horiz centre')
    evenstyle = xlwt.easyxf('pattern: back_colour gray40')
    oddstyle = xlwt.easyxf('pattern: pattern sparse_dots, fore_colour grey25')
    
    # header row
    sheet.write(0, 0, 'Graduate Student Search Results', xlwt.easyxf('font: bold on, height 320'))
    sheet.row(0).height = 400
    for i,hdr in enumerate(headers):
        sheet.write(1, i, hdr, hdrstyle)
    
    # data rows
    for i,grad in enumerate(grads):
        style = [oddstyle, evenstyle][i%2]
        for j,column in enumerate(columns):
            sheet.write(i+2, j, getattribute(grad, column, html=False), style)
    
    # set column widths
    for i,c in enumerate(columns):
        wid = COLUMN_WIDTHS[c]
        sheet.col(i).width = wid
    
    count = len(grads)
    sheet.write(count+4, 0, 'Number of students: %i' % (count))
    sheet.write(count+5, 0, 'Report generated: %s' % (datetime.datetime.now()))
    
    book.save(response) 
开发者ID:sfu-fas,项目名称:coursys,代码行数:32,代码来源:search.py

示例7: get_xls_export

# 需要导入模块: import xlwt [as 别名]
# 或者: from xlwt import easyxf [as 别名]
def get_xls_export(self, context):
        datas = self._get_datas(context)
        output = io.BytesIO()
        export_header = (
            self.request.GET.get('export_xls_header', 'off') == 'on')

        model_name = self.opts.verbose_name
        book = xlwt.Workbook(encoding='utf8')
        sheet = book.add_sheet(
            u"%s %s" % (_(u'Sheet'), force_text(model_name)))
        styles = {'datetime': xlwt.easyxf(num_format_str='yyyy-mm-dd hh:mm:ss'),
                  'date': xlwt.easyxf(num_format_str='yyyy-mm-dd'),
                  'time': xlwt.easyxf(num_format_str='hh:mm:ss'),
                  'header': xlwt.easyxf('font: name Times New Roman, color-index red, bold on', num_format_str='#,##0.00'),
                  'default': xlwt.Style.default_style}

        if not export_header:
            datas = datas[1:]
        for rowx, row in enumerate(datas):
            for colx, value in enumerate(row):
                if export_header and rowx == 0:
                    cell_style = styles['header']
                else:
                    if isinstance(value, datetime.datetime):
                        cell_style = styles['datetime']
                    elif isinstance(value, datetime.date):
                        cell_style = styles['date']
                    elif isinstance(value, datetime.time):
                        cell_style = styles['time']
                    else:
                        cell_style = styles['default']
                sheet.write(rowx, colx, value, style=cell_style)
        book.save(output)

        output.seek(0)
        return output.getvalue() 
开发者ID:stormsha,项目名称:StormOnline,代码行数:38,代码来源:export.py

示例8: __init__

# 需要导入模块: import xlwt [as 别名]
# 或者: from xlwt import easyxf [as 别名]
def __init__(self, path, engine=None, encoding=None, **engine_kwargs):
        # Use the xlwt module as the Excel writer.
        import xlwt
        engine_kwargs['engine'] = engine
        super(_XlwtWriter, self).__init__(path, **engine_kwargs)

        if encoding is None:
            encoding = 'ascii'
        self.book = xlwt.Workbook(encoding=encoding)
        self.fm_datetime = xlwt.easyxf(num_format_str=self.datetime_format)
        self.fm_date = xlwt.easyxf(num_format_str=self.date_format) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:13,代码来源:excel.py

示例9: __init__

# 需要导入模块: import xlwt [as 别名]
# 或者: from xlwt import easyxf [as 别名]
def __init__(self, path, engine=None, **engine_kwargs):
        # Use the xlwt module as the Excel writer.
        import xlwt

        super(_XlwtWriter, self).__init__(path, **engine_kwargs)

        self.book = xlwt.Workbook()
        self.fm_datetime = xlwt.easyxf(num_format_str=self.datetime_format)
        self.fm_date = xlwt.easyxf(num_format_str=self.date_format) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:11,代码来源:excel.py

示例10: write

# 需要导入模块: import xlwt [as 别名]
# 或者: from xlwt import easyxf [as 别名]
def write(self):
        sty = ''
        header_sty = xlwt.easyxf(sty + 'font: bold on; align: wrap on, vert centre, horiz center;')
        sty = xlwt.easyxf(sty)
        ws = self.workbook.add_sheet(self.sheet_name)

        titles = [_(u'Column'), _(u'Title')] + self.extension_titles
        for col, title in enumerate(titles):
            ws.write(0, col, title, style=header_sty)

        row = 1
        for column in self.board.columns:
            column = column()
            colname = _('Archived cards') if column.is_archive else column.get_title()
            for card in column.cards:
                card = card()
                ws.write(row, 0, colname, sty)
                ws.write(row, 1, card.get_title(), sty)
                card_extensions = dict(card.extensions)
                for col, key in enumerate(self.extensions, 2):
                    ext = card_extensions[key]()
                    write_extension_data(ext, ws, row, col, sty)
                row += 1
        for col in xrange(len(titles)):
            ws.col(col).width = 0x3000
        ws.set_panes_frozen(True)
        ws.set_horz_split_pos(1) 
开发者ID:Net-ng,项目名称:kansha,代码行数:29,代码来源:excel_export.py

示例11: print_title

# 需要导入模块: import xlwt [as 别名]
# 或者: from xlwt import easyxf [as 别名]
def print_title(self, ws, _p, row_position, xlwtlib, _xs):
        cell_style = xlwtlib.easyxf(_xs['xls_title'])
        report_name = ' - '.join([_p.report_name.upper(),
                                  _p.company.partner_id.name,
                                  _p.company.currency_id.name])
        c_specs = [
            ('report_name', 1, 0, 'text', report_name),
        ]
        row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
        row_position = self.xls_write_row(
            ws, row_position, row_data, row_style=cell_style)
        return row_position 
开发者ID:iw3hxn,项目名称:LibrERP,代码行数:14,代码来源:partners_balance_xls.py

示例12: print_header_data

# 需要导入模块: import xlwt [as 别名]
# 或者: from xlwt import easyxf [as 别名]
def print_header_data(self, ws, _p, data, row_position, xlwtlib, _xs,
                          initial_balance_text):
        cell_format = _xs['borders_all'] + _xs['wrap'] + _xs['top']
        cell_style = xlwtlib.easyxf(cell_format)
        cell_style_center = xlwtlib.easyxf(cell_format + _xs['center'])
        c_specs = [
            ('fy', 1, 0, 'text', _p.fiscalyear.name if _p.fiscalyear else '-',
             None, cell_style_center),
            ('af', 1, 0, 'text', _p.accounts(data) and ', '.join(
                [account.code for account in _p.accounts(data)]) or _('All'),
             None, cell_style_center),
        ]
        df = _('From') + ': '
        if _p.filter_form(data) == 'filter_date':
            df += _p.start_date if _p.start_date else u''
        else:
            df += _p.start_period.name if _p.start_period else u''
        df += ' ' + _('\nTo') + ': '
        if _p.filter_form(data) == 'filter_date':
            df += _p.stop_date if _p.stop_date else u''
        else:
            df += _p.stop_period.name if _p.stop_period else u''
        c_specs += [
            ('df', 1, 0, 'text', df, None, cell_style_center),
            ('tm', 1, 0, 'text', _p.display_partner_account(
                data), None, cell_style_center),
            ('pf', 1, 0, 'text', _p.display_target_move(
                data), None, cell_style_center),
            ('ib', 1, 0, 'text', initial_balance_text[
             _p.initial_balance_mode], None, cell_style_center),
            ('coa', 1, 0, 'text', _p.chart_account.name,
             None, cell_style_center),
        ]
        row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
        row_position = self.xls_write_row(
            ws, row_position, row_data, row_style=cell_style)
        return row_position 
开发者ID:iw3hxn,项目名称:LibrERP,代码行数:39,代码来源:partners_balance_xls.py

示例13: print_comparison_header

# 需要导入模块: import xlwt [as 别名]
# 或者: from xlwt import easyxf [as 别名]
def print_comparison_header(self, _xs, xlwtlib, row_position, _p, ws,
                                initial_balance_text):
        cell_format_ct = _xs['bold'] + _xs['fill_blue'] + _xs['borders_all']
        cell_style_ct = xlwtlib.easyxf(cell_format_ct)
        c_specs = [('ct', 7, 0, 'text', _('Comparisons'))]
        row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
        row_position = self.xls_write_row(
            ws, row_position, row_data, row_style=cell_style_ct)
        cell_format = _xs['borders_all'] + _xs['wrap'] + _xs['top']
        cell_style_center = xlwtlib.easyxf(cell_format)
        for index, params in enumerate(_p.comp_params):
            c_specs = [
                ('c', 2, 0, 'text', _('Comparison') + str(index + 1) +
                 ' (C' + str(index + 1) + ')')]
            if params['comparison_filter'] == 'filter_date':
                c_specs += [('f', 2, 0, 'text', _('Dates Filter') + ': ' +
                             _p.formatLang(params['start'], date=True) + ' - '
                             + _p.formatLang(params['stop'], date=True))]
            elif params['comparison_filter'] == 'filter_period':
                c_specs += [('f', 2, 0, 'text', _('Periods Filter') +
                             ': ' + params['start'].name + ' - ' +
                             params['stop'].name)]
            else:
                c_specs += [('f', 2, 0, 'text', _('Fiscal Year') +
                             ': ' + params['fiscalyear'].name)]
            c_specs += [('ib', 2, 0, 'text', _('Initial Balance') +
                         ': ' +
                         initial_balance_text[params['initial_balance_mode']])]
            row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
            row_position = self.xls_write_row(
                ws, row_position, row_data, row_style=cell_style_center)
        return row_position 
开发者ID:iw3hxn,项目名称:LibrERP,代码行数:34,代码来源:partners_balance_xls.py

示例14: print_account_totals

# 需要导入模块: import xlwt [as 别名]
# 或者: from xlwt import easyxf [as 别名]
def print_account_totals(self, _xs, xlwtlib, ws, row_start_account,
                             row_position, current_account, _p):
        cell_format = _xs['bold'] + _xs['fill'] + \
            _xs['borders_all'] + _xs['wrap'] + _xs['top']
        cell_style = xlwtlib.easyxf(cell_format)
        cell_style_decimal = xlwtlib.easyxf(
            cell_format + _xs['right'],
            num_format_str=report_xls.decimal_format)
        c_specs = [
            ('acc_title', 2, 0, 'text', current_account.name),
            ('code', 1, 0, 'text', current_account.code),
        ]
        for column in range(3, 7):
            # in case of one single comparison, the column 6 will contain
            # percentages
            if (_p.comparison_mode == 'single' and column == 6):
                total_diff = rowcol_to_cell(row_position, column - 1)
                total_balance = rowcol_to_cell(row_position, column - 2)
                account_formula = 'Round(' + total_diff + \
                    '/' + total_balance + '*100;0)'
            else:
                account_start = rowcol_to_cell(row_start_account, column)
                account_end = rowcol_to_cell(row_position - 1, column)
                account_formula = 'Round(SUM(' + \
                    account_start + ':' + account_end + ');2)'
            c_specs += [('total%s' % column, 1, 0, 'text', None,
                         account_formula, None, cell_style_decimal)]
        row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
        row_position = self.xls_write_row(
            ws, row_position, row_data, cell_style)
        return row_position + 1 
开发者ID:iw3hxn,项目名称:LibrERP,代码行数:33,代码来源:partners_balance_xls.py

示例15: _journal_title

# 需要导入模块: import xlwt [as 别名]
# 或者: from xlwt import easyxf [as 别名]
def _journal_title(self, o, ws, _p, row_pos, xlwt, _xs):
        cell_style = xlwt.easyxf(_xs['xls_title'])
        report_name = (10 * ' ').join([
            _p.company.name,
            _p.title(o)[0],
            _p.title(o)[1],
            _p._("Journal Overview") + ' - ' + _p.company.currency_id.name,
            ])
        c_specs = [
            ('report_name', 1, 0, 'text', report_name),
        ]
        row_data = self.xls_row_template(c_specs, [x[0] for x in c_specs])
        row_pos = self.xls_write_row(ws, row_pos, row_data, row_style=cell_style)
        return row_pos + 1 
开发者ID:iw3hxn,项目名称:LibrERP,代码行数:16,代码来源:nov_account_journal_xls.py


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