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