How to use the openpyxl.utils.cell.get_column_letter function in openpyxl

To help you get started, we’ve selected a few openpyxl examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kun-zhou / latex2excel / latex2excel.py View on Github external
curLine = line

            # Striping away all the special characters in the table
            curLine = re.sub(r"\\cmidrule{.*?}", '', curLine)
            curLine = re.sub(r"\\midrule", '', curLine)
            curLine = re.sub(r"\\toprule", '', curLine)
            curLine = re.sub(r"\\bottomrule", '', curLine)
            curLine = re.sub(r"\\hline", '', curLine)
            curLine = re.sub(r"\\cline{.*?}", '', curLine)
            curLine = curLine.replace("\n", '')
            curLine = curLine.rstrip().split("&")

            # looping through all cells in the current row
            for item in curLine:
                item = item.strip()
                curLoc = utils.cell.get_column_letter(col) + str(row)
                if 'multicolumn' in item:
                    match = re.search(r'\\multicolumn{(.*?)}{(.*?)}{(.*)}', item)
                    text = match.group(3)
                    span2 = 1  # This provides a default in case not nested
                    if 'multirow' in text:
                        match2 = re.search(r'\\multirow{(.*)}{(.*)}{(.*)}', text)
                        if not match2:
                            match2 = re.search(r'\\multirow{(.*)}\[.*\]{(.*)}{(.*)}', text)
                        span2 = int(match2.group(1))
                        # align = match.group(2)
                        text = match2.group(3)
                    span = int(match.group(1))
                    align = match.group(2)
                    try:
                        text = int(text)
                    except:
github psychopy / psychopy / psychopy / data / utils.py View on Github external
def _getExcelCellName(col, row):
    """Returns the excel cell name for a row and column (zero-indexed)

    >>> _getExcelCellName(0,0)
    'A1'
    >>> _getExcelCellName(2,1)
    'C2'
    """
    # BEWARE - openpyxl uses indexing at 1, to fit with Excel
    return "%s%i" % (get_column_letter(col + 1), row + 1)
github bluecatlabs / gateway-workflows / Community / zone_exporter / exporter.py View on Github external
def set_column_width(sheet, start_column, widthes):
    start_column_idx = column_index_from_string(start_column)

    for index in range(len(widthes)):
        column_letter = get_column_letter(start_column_idx + index)
        sheet.column_dimensions[column_letter].width = widthes[index]
github JBEI / edd / server / edd / describe / parsers.py View on Github external
def header_desc(cell_content, col_index):
    col_letter = get_column_letter(col_index + 1)
    return f'"{cell_content}" (col {col_letter})'
github JBEI / edd / server / edd / describe / parsers.py View on Github external
def warn_for_unsupported_meta_types(self):
        column_layout = self.column_layout
        importer = self.importer

        unsupported_value_columns = [
            col_index
            for col_index, meta_pk in column_layout.col_index_to_line_meta_pk.items()
            if meta_pk in self.unsupported_line_meta_types_by_pk
        ]
        if unsupported_value_columns:
            line_meta_types = self.cache.line_meta_types
            unsupported_values = []
            for col_index in unsupported_value_columns:
                meta_pk = column_layout.get_line_meta_pk(col_index)
                meta_type = line_meta_types[meta_pk]
                col_letter = get_column_letter(col_index + 1)
                unsupported_values.append(f'"{meta_type.type_name}" (col {col_letter})')

            importer.add_warning(
                IGNORED_INPUT_CATEGORY,
                UNSUPPORTED_LINE_METADATA,
                ", ".join(unsupported_values),
            )
github bluecatlabs / gateway-workflows / Community / network_exporter / exporter.py View on Github external
def set_column_width(sheet, start_column, widthes):
    start_column_idx = column_index_from_string(start_column)

    for index in range(len(widthes)):
        column_letter = get_column_letter(start_column_idx + index)
        sheet.column_dimensions[column_letter].width = widthes[index]
github bluecatlabs / gateway-workflows / Community / zone_exporter / exporter.py View on Github external
def add_auto_filters(sheet, start_column, start_row, length):
    start_column_idx = column_index_from_string(start_column)
    end_column  = get_column_letter(start_column_idx + length - 1)
    filter_range = start_column + str(start_row) +  ':' + end_column + str(start_row)
    sheet.auto_filter.ref = filter_range
github bluecatlabs / gateway-workflows / Community / network_exporter / exporter.py View on Github external
def add_auto_filters(sheet, start_column, start_row, length):
    start_column_idx = column_index_from_string(start_column)
    end_column  = get_column_letter(start_column_idx + length - 1)
    filter_range = start_column + str(start_row) +  ':' + end_column + str(start_row)
    sheet.auto_filter.ref = filter_range