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


Python workbook.Workbook方法代码示例

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


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

示例1: __init__

# 需要导入模块: from openpyxl import workbook [as 别名]
# 或者: from openpyxl.workbook import Workbook [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: __init__

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

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

        if self.mode == 'a':  # Load from existing workbook
            from openpyxl import load_workbook
            book = load_workbook(self.path)
            self.book = book
        else:
            # Create workbook object with default optimized_write=True.
            self.book = Workbook()

            if self.book.worksheets:
                try:
                    self.book.remove(self.book.worksheets[0])
                except AttributeError:

                    # compat - for openpyxl <= 2.4
                    self.book.remove_sheet(self.book.worksheets[0]) 
开发者ID:awslabs,项目名称:predictive-maintenance-using-machine-learning,代码行数:23,代码来源:excel.py

示例3: __init__

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

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

        # Create workbook object with default optimized_write=True.
        self.book = Workbook()

        # Openpyxl 1.6.1 adds a dummy sheet. We remove it.
        if self.book.worksheets:
            try:
                self.book.remove(self.book.worksheets[0])
            except AttributeError:

                # compat
                self.book.remove_sheet(self.book.worksheets[0]) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:19,代码来源:excel.py

示例4: render_xlsx

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

示例5: __init__

# 需要导入模块: from openpyxl import workbook [as 别名]
# 或者: from openpyxl.workbook import Workbook [as 别名]
def __init__(self, path, engine=None, **engine_kwargs):
        if not openpyxl_compat.is_compat(major_ver=self.openpyxl_majorver):
            raise ValueError('Installed openpyxl is not supported at this '
                             'time. Use {majorver}.x.y.'
                             .format(majorver=self.openpyxl_majorver))
        # Use the openpyxl module as the Excel writer.
        from openpyxl.workbook import Workbook

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

        # Create workbook object with default optimized_write=True.
        self.book = Workbook()

        # Openpyxl 1.6.1 adds a dummy sheet. We remove it.
        if self.book.worksheets:
            try:
                self.book.remove(self.book.worksheets[0])
            except AttributeError:

                # compat
                self.book.remove_sheet(self.book.worksheets[0]) 
开发者ID:nccgroup,项目名称:Splunking-Crime,代码行数:23,代码来源:excel.py

示例6: __init__

# 需要导入模块: from openpyxl import workbook [as 别名]
# 或者: from openpyxl.workbook import Workbook [as 别名]
def __init__(self, renderers_func, config):
        if not has_openpyxl:
            debug.error("You must install OpenPyxl 2.1.2 for xlsx format:\n\thttps://pypi.python.org/pypi/openpyxl")
        self._config = config
        self._columns = None
        self._text_cell_renderers_func = renderers_func
        self._text_cell_renderers = None
        self._wb = Workbook(optimized_write = True)
        self._ws = self._wb.create_sheet() 
开发者ID:virtualrealitysystems,项目名称:aumfor,代码行数:11,代码来源:xlsx.py

示例7: __init__

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

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

        # Create workbook object with default optimized_write=True.
        self.book = Workbook()
        # Openpyxl 1.6.1 adds a dummy sheet. We remove it.
        if self.book.worksheets:
            self.book.remove_sheet(self.book.worksheets[0]) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:13,代码来源:excel.py

示例8: __init__

# 需要导入模块: from openpyxl import workbook [as 别名]
# 或者: from openpyxl.workbook import Workbook [as 别名]
def __init__(self, ws_naem, excel_name):
        self.wb = Workbook()
        self.ws_naem = self.wb.active
        self.excel_name = excel_name 
开发者ID:luxux,项目名称:spider,代码行数:6,代码来源:excelform.py


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