本文整理匯總了Python中xlwt.Workbook方法的典型用法代碼示例。如果您正苦於以下問題:Python xlwt.Workbook方法的具體用法?Python xlwt.Workbook怎麽用?Python xlwt.Workbook使用的例子?那麽恭喜您, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在模塊xlwt的用法示例。
在下文中一共展示了xlwt.Workbook方法的26個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於我們的係統推薦出更棒的Python代碼示例。
示例1: __init__
點讚 10
# 需要導入模塊: import xlwt [as 別名]
# 或者: from xlwt 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,
示例2: __init__
點讚 6
# 需要導入模塊: import xlwt [as 別名]
# 或者: from xlwt import Workbook [as 別名]
def __init__(self):
# count用於計數excel行
self.excel = xlwt.Workbook(encoding=’utf8′)
self.sheet = self.excel.add_sheet(‘文獻列表’, True)
self.set_style()
self.sheet.write(0, 0, ‘序號’, self.basic_style)
self.sheet.write(0, 1, ‘題名’, self.basic_style)
self.sheet.write(0, 2, ‘作者’, self.basic_style)
self.sheet.write(0, 3, ‘單位’, self.basic_style)
self.sheet.write(0, 4, ‘關鍵字’, self.basic_style)
self.sheet.write(0, 5, ‘摘要’, self.basic_style)
self.sheet.write(0, 6, ‘來源’, self.basic_style)
self.sheet.write(0, 7, ‘發表時間’, self.basic_style)
self.sheet.write(0, 8, ‘數據庫’, self.basic_style)
if config.crawl_isDownLoadLink == ‘1’:
self.sheet.write(0, 9, ‘下載地址’, self.basic_style)
# 生成userKey,服務器不做驗證
self.cnkiUserKey = self.set_new_guid()
開發者ID:CyrusRenty,項目名稱:CNKI-download,代碼行數:21,
示例3: __init__
點讚 6
# 需要導入模塊: import xlwt [as 別名]
# 或者: from xlwt 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,
示例4: write_data
點讚 6
# 需要導入模塊: import xlwt [as 別名]
# 或者: from xlwt import Workbook [as 別名]
def write_data(data, tname):
file = xlwt.Workbook(encoding=’utf-8′)
table = file.add_sheet(tname, cell_overwrite_ok=True)
l = 0
for line in data:
c = 0
for _ in line:
table.write(l, c, line[c])
c += 1
l += 1
sio = StringIO.StringIO()
file.save(sio)
return sio
# excel業務邏輯處理
開發者ID:ysrc,項目名稱:xunfeng,代碼行數:18,
示例5: from_data
點讚 6
# 需要導入模塊: import xlwt [as 別名]
# 或者: from xlwt import Workbook [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,
示例6: create_workbook
點讚 6
# 需要導入模塊: import xlwt [as 別名]
# 或者: from xlwt import Workbook [as 別名]
def create_workbook(output_file):
”’ Creates a proper instance of data file writer depending on file extension.
Supported formats are: xls, xslx and csv.
Args:
output_file (str): file name.
Returns:
(xlwt.Workbook, XlsxWorkbook or OneCsvWriter): created data file
writer instance.
Raises:
ValueError: if a file with not supported extension was provided.
”’
if output_file.endswith(‘.xls’):
work_book = xlwt.Workbook()
elif output_file.endswith(‘.xlsx’):
work_book = XlsxWorkbook()
elif output_file.endswith(‘.csv’):
work_book = OneCsvWriter(output_file)
else:
raise ValueError(‘File {0} has unsupported output format’.format
(output_file))
return work_book
開發者ID:araith,項目名稱:pyDEA,代碼行數:26,
示例7: test_super_efficiency_with_VRS