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


Python cell.get_column_letter方法代码示例

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


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

示例1: save_spreadsheet

# 需要导入模块: from openpyxl import cell [as 别名]
# 或者: from openpyxl.cell import get_column_letter [as 别名]
def save_spreadsheet(filename, data_sample):
    
    wb = Workbook()
    ws = wb.active

    rowIndex = 1
    for rows in data_sample:
        colIndex = 1 
        for field in rows:
            colIndex2 = get_column_letter(colIndex)
            ws.cell('%s%s'%(colIndex2, rowIndex)).value = field
            colIndex +=1
        rowIndex += 1
    
    wb.save(filename)

## Stage 4 end

# --------------------------------------

## Stage 5 begin 
开发者ID:katychuang,项目名称:python-data-sci-basics,代码行数:23,代码来源:my_utils.py

示例2: render_xlsx

# 需要导入模块: from openpyxl import cell [as 别名]
# 或者: from openpyxl.cell import get_column_letter [as 别名]
def render_xlsx(self, outfd, data):
        wb = Workbook(optimized_write = True)
        ws = wb.create_sheet()
        ws.title = 'Timeline Output'
        header = ["Time", "Type", "Item", "Details", "Reason"]
        ws.append(header)
        total = 1
        for line in data:
            coldata = line.split("|")
            ws.append(coldata)
            total += 1
        wb.save(filename = self._config.OUTPUT_FILE)

        if self._config.HIGHLIGHT != None:
            wb = load_workbook(filename = self._config.OUTPUT_FILE)
            ws = wb.get_sheet_by_name(name = "Timeline Output")
            for col in xrange(1, len(header) + 1):
                ws.cell("{0}{1}".format(get_column_letter(col), 1)).style.font.bold = True
            for row in xrange(2, total + 1):
                for col in xrange(2, len(header)):
                    if ws.cell("{0}{1}".format(get_column_letter(col), row)).value in self.suspicious.keys():
                        self.fill(ws, row, len(header) + 1, self.suspicious[ws.cell("{0}{1}".format(get_column_letter(col), row)).value]["color"])
                        ws.cell("{0}{1}".format(get_column_letter(col + 1), row)).value = self.suspicious[ws.cell("{0}{1}".format(get_column_letter(col), row)).value]["reason"]
                    
            wb.save(filename = self._config.OUTPUT_FILE) 
开发者ID:504ensicsLabs,项目名称:DAMM,代码行数:27,代码来源:timeliner.py

示例3: fill

# 需要导入模块: from openpyxl import cell [as 别名]
# 或者: from openpyxl.cell import get_column_letter [as 别名]
def fill(self, ws, row, max = 6, color = "RED"):
        for col in xrange(1, max): 
            ws.cell("{0}{1}".format(get_column_letter(col), row)).style.fill.fill_type = Fill.FILL_SOLID
            ws.cell("{0}{1}".format(get_column_letter(col), row)).style.fill.start_color.index = colors.get(color, "RED") 
开发者ID:504ensicsLabs,项目名称:DAMM,代码行数:6,代码来源:timeliner.py

示例4: write_cells

# 需要导入模块: from openpyxl import cell [as 别名]
# 或者: from openpyxl.cell import get_column_letter [as 别名]
def write_cells(self, cells, sheet_name=None, startrow=0, startcol=0):
        # Write the frame cells using openpyxl.
        from openpyxl.cell import get_column_letter

        sheet_name = self._get_sheet_name(sheet_name)

        if sheet_name in self.sheets:
            wks = self.sheets[sheet_name]
        else:
            wks = self.book.create_sheet()
            wks.title = sheet_name
            self.sheets[sheet_name] = wks

        for cell in cells:
            colletter = get_column_letter(startcol + cell.col + 1)
            xcell = wks.cell("%s%s" % (colletter, startrow + cell.row + 1))
            xcell.value = _conv_value(cell.val)
            style = None
            if cell.style:
                style = self._convert_to_style(cell.style)
                for field in style.__fields__:
                    xcell.style.__setattr__(field,
                                            style.__getattribute__(field))

            if isinstance(cell.val, datetime.datetime):
                xcell.style.number_format.format_code = self.datetime_format
            elif isinstance(cell.val, datetime.date):
                xcell.style.number_format.format_code = self.date_format

            if cell.mergestart is not None and cell.mergeend is not None:
                cletterstart = get_column_letter(startcol + cell.col + 1)
                cletterend = get_column_letter(startcol + cell.mergeend + 1)

                wks.merge_cells('%s%s:%s%s' % (cletterstart,
                                               startrow + cell.row + 1,
                                               cletterend,
                                               startrow + cell.mergestart + 1))

                # Excel requires that the format of the first cell in a merged
                # range is repeated in the rest of the merged range.
                if style:
                    first_row = startrow + cell.row + 1
                    last_row = startrow + cell.mergestart + 1
                    first_col = startcol + cell.col + 1
                    last_col = startcol + cell.mergeend + 1

                    for row in range(first_row, last_row + 1):
                        for col in range(first_col, last_col + 1):
                            if row == first_row and col == first_col:
                                # Ignore first cell. It is already handled.
                                continue
                            colletter = get_column_letter(col)
                            xcell = wks.cell("%s%s" % (colletter, row))
                            for field in style.__fields__:
                                xcell.style.__setattr__(
                                    field, style.__getattribute__(field)) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:58,代码来源:excel.py


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