-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ffd2810
commit fb42bff
Showing
5 changed files
with
279 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/usr/bin/env python | ||
# _#_ coding:utf-8 _*_ | ||
import xlwt | ||
|
||
class CellWriter(object): | ||
def __init__(self,name): | ||
self.file_name = name | ||
self.workbook = xlwt.Workbook(encoding='utf-8') | ||
# for sh in args: | ||
# self.worksheet = self.workbook.add_sheet(sh) | ||
|
||
def fontStyle(self): | ||
font = xlwt.Font() | ||
font.name = u"微软雅黑" | ||
# font.height = 20 * 12 | ||
return font | ||
|
||
def borderStyle(self): | ||
borders = xlwt.Borders() | ||
borders.left = 1 | ||
borders.right = 1 | ||
borders.top = 1 | ||
borders.bottom = 1 | ||
return borders | ||
|
||
def writeBanner(self,sheetName,bList): | ||
for ds in bList: | ||
sheetName.write(0, bList.index(ds), ds, self.bodySttle(pattern=5)) | ||
|
||
def bodySttle(self,pattern=None): | ||
style = xlwt.XFStyle() | ||
style.alignment.horz = 2 | ||
style.alignment.vert = 1 | ||
style.alignment.wrap = 1 | ||
if pattern: | ||
pat = xlwt.Pattern() | ||
pat.pattern = xlwt.Pattern.SOLID_PATTERN | ||
pat.pattern_fore_colour = pattern | ||
style.pattern = pat | ||
style.font = self.fontStyle() | ||
style.borders = self.borderStyle() | ||
return style | ||
|
||
def save(self): | ||
self.workbook.save(self.file_name) |
Oops, something went wrong.