• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python xlwt.Borders类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中xlwt.Borders的典型用法代码示例。如果您正苦于以下问题:Python Borders类的具体用法?Python Borders怎么用?Python Borders使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: css2excel

def css2excel(css):
    #custom_css = 'font: name "%s", %s on'%(current_value['font-family'].split(",")[0], current_value['font-weight'].split(",")[0])
    #export_sheet.write(row_idx, col_idx, current_value['data'], xlwt.easyxf('font: italic on; pattern: pattern solid, fore-colour grey25'))
    xf_list = []
    fnt = Font()
    borders = Borders()
    pattern = Pattern()
    align = Alignment()

    process_css = {
        'font-family' : [fnt, "name" , lambda x : x.split(",")[0]],
        'color' : [fnt, "colour_index", lambda x : excel_color_map.get(x,0)+8],
        'font-weight' : [fnt, "bold", lambda x : x.upper() == 'BOLD'],
        #'font-weight' : [fnt, "bold", lambda x : x == '700'],
        'text-align' : [align, "horz", lambda x : {'left':align.HORZ_LEFT, 'right':align.HORZ_RIGHT, 'center':align.HORZ_CENTER, 'justified': align.HORZ_JUSTIFIED}[x]],
        'background-color' : [pattern,"pattern_fore_colour", lambda x: excel_color_map.get(x,16)+8],
    }
    #TODO process_css -> css
    for i in process_css.keys():
        #print process_css[i][0] ,".",process_css[i][1], " => " , css[i] ,"  |  ", process_css[i][2](css[i]) 
        setattr(process_css[i][0], process_css[i][1], process_css[i][2](css[i]))

    style = XFStyle()
    style.font = fnt
    borders.left = Borders.THIN
    borders.right = Borders.THIN
    borders.top = Borders.THIN
    borders.bottom = Borders.THIN
    style.borders = borders
    style.pattern = pattern
    style.pattern.pattern = 1
    style.alignment = align

    return style
开发者ID:aniquez,项目名称:mod,代码行数:34,代码来源:excelib.py


示例2: getDefualtStyle

def getDefualtStyle():
	fnt = Font()
	fnt.name = 'Arial'
	
	borders = Borders()
	borders.left = Borders.THIN
	borders.right = Borders.THIN
	borders.top = Borders.THIN
	borders.bottom = Borders.THIN
	
	#pattern = Pattern()
	#pattern.pattern = Style.pattern_map['solid']
	###pattern.pattern_back_colour = 0xBFBFBF
	#pattern.pattern_fore_colour = 0x37
	
	
	alignment = Alignment()
	#alignment.horizontal = Alignment.HORZ_LEFT 
	alignment.horizontal = Alignment.HORZ_RIGHT
	
	
	style = XFStyle()
	#~ style.num_format_str='0.000%'
	#~ style.num_format_str='0+'
	#~ style.font = fnt
	style.align = alignment
	#style.borders = borders
	#~ style.pattern = pattern
	
	return style
开发者ID:Eddy-W,项目名称:scripts,代码行数:30,代码来源:savedata2xls_new.py


示例3: __init__

    def __init__(self, ws, headers, header_line_no=0, use_borders=False, styleHeaders=None, styleDict={}, widths={}):
        self.headers = headers
        self.header_line_no = header_line_no
        self._currentRowIndex = self.header_line_no + 1
        self.ws = ws
        self.rows = []

        # columnn widths
        if isinstance(widths, dict):
            self._explicit_widths = True
            self.__colwidths = widths
        else:
            self._explicit_widths = False
            self.__colwidths = {i:len(h) for i,h in enumerate(self.headers)}

        #***************************************************************************
        borders = Borders()
        if use_borders is True:
            borders.left = Borders.THIN
            borders.right = Borders.THIN
            borders.top = Borders.THIN
            borders.bottom = Borders.THIN

        self.normStyle = XFStyle()
        self.normStyle.font = normFont
        if use_borders:
            self.normStyle.borders = borders

        # headers
        if not isinstance(styleHeaders, XFStyle):
            self.styleHeaders = XFStyle()
            self.styleHeaders.font = fntHeaders
            self.styleHeaders.borders = borders

        else:
            self.styleHeaders = styleHeaders

        # for date fields if no styleDict
        self.styleDate = XFStyle()
        self.styleDate.borders = borders
        self.styleDate.num_format_str = 'MM/DD/YYYY'
        self.styleDate.font = normFont
        #***************************************************************************
        #
        # instance styles defined by user or defaults
        if all(map(lambda s: isinstance(s, XFStyle), styleDict.values())):
            self.styleDict = styleDict
            if DEFAULT_STYLE in styleDict:
                self._defaultStyle = self.styleDict[DEFAULT_STYLE]
        else:
            self.styleDict = {}
            self._defaultStyle = self.normStyle

        self.writeHeaders()
开发者ID:Bolton-and-Menk-GIS,项目名称:LittleRiver-Tools,代码行数:54,代码来源:excel.py


示例4: setupFormat

    def setupFormat(self):
        headFont = Font()
        headFont.bold = True
        alignmentSetup = Alignment()
        alignmentSetup.wrap = True
        borders = Borders()
        borders.left = 1
        borders.right = 1
        borders.top = 1
        borders.bottom = 1

        self.header_style = XFStyle()
        self.header_style.font = headFont

        self.table_style = XFStyle()
        self.table_style.borders = borders
        self.table_style.alignment = alignmentSetup
开发者ID:ambonilla,项目名称:Convertidor-de-csv-a-xls-para-BNCR,代码行数:17,代码来源:CsvReader.py


示例5: estiloCeldasSeparadas

def estiloCeldasSeparadas():
    fnt = Font()
    fnt.bold=True
    #fnt.colour_index=2
    borders = Borders()
    borders.left = Borders.MEDIUM
    borders.right = Borders.MEDIUM
    borders.top = Borders.MEDIUM
    borders.bottom = Borders.MEDIUM
    pattern = Pattern()
    pattern.pattern = Pattern.SOLID_PATTERN
    pattern.pattern_fore_colour = 0x18#0x99
    style = XFStyle()   
    style.num_format_str='YYYY-MM-DD'
    style.font = fnt
    style.borders = borders
    style.pattern = pattern
    return style
开发者ID:santicalvo,项目名称:traductorpy,代码行数:18,代码来源:init_extract.py


示例6: transCellData_summary

def transCellData_summary(pos,val):
	tmp=[]
	tmp.append(transpos(pos)[0])
	tmp.append(transpos(pos)[1])
	style = getDefualtStyle()
	style.font.colour_index =0x17
	style.alignment.horz  = Alignment.HORZ_CENTER
	#style.borders.right = Borders.NO_LINE
	style.font.bold =True
	borders = Borders()
	borders.left = Borders.THIN
	borders.right = Borders.THIN
	borders.top = Borders.THIN
	borders.bottom = Borders.THIN
	style.borders = borders
	try:
		tmp.append(val)
	except:
		tmp.append(0)
	return tmp,style
开发者ID:Eddy-W,项目名称:scripts,代码行数:20,代码来源:savedata2xls_new.py


示例7: excel_style

def excel_style():
    borders_amount = Borders()
    borders_amount.right = Borders.THIN
    borders_amount.top = Borders.THIN
    borders_amount.bottom = Borders.THIN

    borders_name = Borders()
    borders_name.left = Borders.THIN
    borders_name.right = Borders.THIN
    borders_name.top = Borders.THIN
    borders_name.bottom = Borders.THIN

    style_amount = XFStyle()
    style_amount.borders = borders_amount

    style_name = XFStyle()
    style_name.borders = borders_name
    return style_amount, style_name
开发者ID:juacompe,项目名称:beryl,代码行数:18,代码来源:views.py


示例8: creaHojaDeTraduccion

def creaHojaDeTraduccion(excel, nombreHoja="traduccion"):
    hoja=excel.creaHoja(nombreHoja)
    hoja.col(0).width=90*256
    hoja.col(1).width=20*256
    fnt = Font()
    fnt.bold=True
    #fnt.colour_index=2
    borders = Borders()
    borders.left = Borders.MEDIUM
    borders.right = Borders.MEDIUM
    borders.top = Borders.MEDIUM
    borders.bottom = Borders.MEDIUM
    pattern = Pattern()
    pattern.pattern = Pattern.SOLID_PATTERN
    pattern.pattern_fore_colour = 0x18#0x99
    style = XFStyle()   
    style.num_format_str='YYYY-MM-DD'
    style.font = fnt
    style.borders = borders
    style.pattern = pattern
    hoja.write(0,0,"Original Text",style)
    hoja.write(0,1,"Translation",style)
    return hoja
开发者ID:santicalvo,项目名称:traductorpy,代码行数:23,代码来源:init_extract.py


示例9: __init__

 def __init__(self):
     self.style = XFStyle()
     base_font = Font()  # 设置基本字体
     base_font.height = FONT_SIZE_UNIT * 12
     self.style.font = base_font
     alignment = Alignment()  # 设置对齐
     alignment.horz = Alignment.HORZ_CENTER
     alignment.vert = Alignment.VERT_CENTER
     self.style.alignment = alignment
     borders = Borders()  # 设置边框
     borders.left = Borders.THIN
     borders.right = Borders.THIN
     borders.top = Borders.THIN
     borders.bottom = Borders.THIN
     borders.left_colour = COLOUR_BLACK
     borders.right_colour = COLOUR_BLACK
     borders.top_colour = COLOUR_BLACK
     borders.bottom_colour = COLOUR_BLACK
     self.style.borders = borders
     self.style.num_format_str = '#,##0'  # 设置数字格式
开发者ID:giveme168,项目名称:braavos,代码行数:20,代码来源:excel.py


示例10: write_sheet

    def write_sheet(self, data, sheet_name, print_to_screen=False):
        '''Write a very simple table to a new sheet in a spreadsheet,
           Optionally, print the table to the screen'''

        # most cells
        al = Alignment()
        al.horz = Alignment.HORZ_RIGHT
        al.vert = Alignment.VERT_CENTER
        font = Font()
        font.name = 'Arial'
        font.height = 9 * 20  # 9 pt
        style = XFStyle()
        style.font = font
        style.alignment = al

        # tops cells
        al = Alignment()
        al.horz = Alignment.HORZ_CENTER
        al.vert = Alignment.VERT_CENTER
        font = Font()
        font.name = 'Arial'
        font.bold = True
        font.height = 9 * 20  # 9 pt
        style_top = XFStyle()
        style_top.font = font
        style_top.alignment = al

        # left cells
        al = Alignment()
        al.horz = Alignment.HORZ_LEFT
        al.vert = Alignment.VERT_CENTER
        font = Font()
        font.name = 'Arial'
        font.bold = True
        font.italic = True
        font.height = 9 * 20  # 9 pt
        style_left = XFStyle()
        style_left.font = font
        style_left.alignment = al

        ws = self.add_sheet(sheet_name)

        for i, row in enumerate(data):
            for j, cell in enumerate(row):

                borders = Borders()

                if i == 0:
                    borders.top = 1
                    borders.bottom = 2

                if i == len(row) - 1:
                    borders.bottom = 1

                if j == 0:
                    borders.left = 1
                    borders.right = 1

                if j == len(row) - 1:
                    borders.right = 1

                if j == 0:
                    _style = style_left
                elif i == 0:
                    _style = style_top
                else:
                    _style = style

                _style.borders = borders

                # one of the libraries can get confused with plain strings
                if isinstance(cell, str):
                    cell = unicode(cell, 'utf-8')

                ws.write(i + 1, j + 1, cell, _style)

        if print_to_screen:
            print print_table(data, sheet_name, bold=True)
开发者ID:daleobrien,项目名称:workbook,代码行数:78,代码来源:__init__.py


示例11: report_get

    def report_get(self,cr,uid,ids,context=None):
  
        this=self.browse(cr,uid,ids[0])
        year = this.year_id.name
        year_id = this.year_id.id
        month = this.month
        if month == '1':
            month_name = 'January'
        elif month == '2':
            month_name = 'February'
        elif month == '3':
            month_name = 'March'
        elif month == '4':
            month_name = 'April'
        elif month == '5':
            month_name = 'May'
        elif month == '6':
            month_name = 'June'
        elif month == '7':
            month_name = 'July'
        elif month == '8':
            month_name = 'August'
        elif month == '9':
            month_name = 'September'
        elif month == '10':
            month_name = 'October'
        elif month == '11':
            month_name = 'November'
        elif month == '12':
            month_name = 'December'
        else:
            raise osv.except_osv(_('Warning !'),_("Specify month correctly. "))
        
        #Define the font attributes for header
        fnt = Font()
        fnt.name = 'Arial'
        fnt.height= 275
        
        #Define the font attributes for header
        content_fnt = Font()
        content_fnt.name ='Arial'
        content_fnt.height =220
        align_content = Alignment()
        align_content.horz= Alignment.HORZ_CENTER
     
        borders = Borders()
        borders.left = 0x02
        borders.right = 0x02
        borders.top = 0x02
        borders.bottom = 0x02
        
        #The text should be centrally aligned
        align = Alignment()
        align.horz = Alignment.HORZ_CENTER
        align.vert = Alignment.VERT_CENTER
        
        #We set the backgroundcolour here
        pattern = Pattern()
        pattern.pattern = Pattern.SOLID_PATTERN
        pattern.pattern_fore_colour =  0x1F

        #apply the above settings to the row(0) header
        style_header= XFStyle()
        style_header.font= fnt
        style_header.pattern= pattern
        style_header.borders = borders
        style_header.alignment=align    
        
        #Define the font attributes for header
        fnt1 = Font()
        fnt1.name = 'Arial'
        fnt1.height= 275
        
        #Define the font attributes for header
        content_fnt1 = Font()
        content_fnt1.name ='Arial'
        content_fnt1.height =220
        align_content1 = Alignment()
        align_content1.horz= Alignment.HORZ_CENTER
     
        borders1 = Borders()
        borders1.left = 0x02
        borders1.right = 0x02
        borders1.top = 0x02
        borders1.bottom = 0x02
        
        #The text should be centrally aligned
        align1 = Alignment()
        align1.horz = Alignment.HORZ_CENTER
        align1.vert = Alignment.VERT_CENTER
        
        #We set the backgroundcolour here
        pattern1 = Pattern()
        pattern1.pattern = Pattern.SOLID_PATTERN
        pattern1.pattern_fore_colour =  0x32

        #apply the above settings to the row(0) header
        style_header1= XFStyle()
        style_header1.font= fnt1
        style_header1.pattern= pattern1
#.........这里部分代码省略.........
开发者ID:arpitb827,项目名称:Salary-notifications,代码行数:101,代码来源:budget_details.py


示例12: account_budget

    def account_budget(self,cr,uid,ids,context=None):
        this=self.browse(cr,uid,ids[0])
        year = this.year_id.name
        year_id = this.year_id.id
        month = this.month
        if int(month) in [1,3,5,7,8,10,12]:
            join_date=year +'-'+month+'-'+'31'
        if int(month) in [4,6,9,11]:
            join_date=year +'-'+month+'-'+'30'
        if int(month) in [2]:
            if int(year) % 4 == 0:
                join_date=year +'-'+month+'-'+'29'
            else:
                join_date=year +'-'+month+'-'+'28'
        if month == '1':
            month_name = 'January'
        elif month == '2':
            month_name = 'February'
        elif month == '3':
            month_name = 'March'
        elif month == '4':
            month_name = 'April'
        elif month == '5':
            month_name = 'May'
        elif month == '6':
            month_name = 'June'
        elif month == '7':
            month_name = 'July'
        elif month == '8':
            month_name = 'August'
        elif month == '9':
            month_name = 'September'
        elif month == '10':
            month_name = 'October'
        elif month == '11':
            month_name = 'November'
        elif month == '12':
            month_name = 'December'
        else:
            raise osv.except_osv(_('Warning !'),_("Specify month correctly. "))
        
        #Define the font attributes for header
        fnt = Font()
        fnt.name = 'Arial'
        fnt.height= 275
        
        #Define the font attributes for header
        content_fnt = Font()
        content_fnt.name ='Arial'
        content_fnt.height =220
        align_content = Alignment()
        align_content.horz= Alignment.HORZ_CENTER
     
        borders = Borders()
        borders.left = 0x02
        borders.right = 0x02
        borders.top = 0x02
        borders.bottom = 0x02
        
        #The text should be centrally aligned
        align = Alignment()
        align.horz = Alignment.HORZ_CENTER
        align.vert = Alignment.VERT_CENTER
        
        #We set the backgroundcolour here
        pattern = Pattern()
        pattern.pattern = Pattern.SOLID_PATTERN
        pattern.pattern_fore_colour =  0x1F

        #apply the above settings to the row(0) header
        style_header= XFStyle()
        style_header.font= fnt
        style_header.pattern= pattern
        style_header.borders = borders
        style_header.alignment=align    
        
        #Define the font attributes for header
        fnt1 = Font()
        fnt1.name = 'Arial'
        fnt1.height= 275
        
        #Define the font attributes for header
        content_fnt1 = Font()
        content_fnt1.name ='Arial'
        content_fnt1.height =220
        align_content1 = Alignment()
        align_content1.horz= Alignment.HORZ_CENTER
     
        borders1 = Borders()
        borders1.left = 0x02
        borders1.right = 0x02
        borders1.top = 0x02
        borders1.bottom = 0x02
        
        #The text should be centrally aligned
        align1 = Alignment()
        align1.horz = Alignment.HORZ_CENTER
        align1.vert = Alignment.VERT_CENTER
        
        #We set the backgroundcolour here
#.........这里部分代码省略.........
开发者ID:arpitb827,项目名称:Salary-notifications,代码行数:101,代码来源:budget.py


示例13: detail_budget

    def detail_budget(self,cr,uid,ids,context=None):
        this=self.browse(cr,uid,ids[0])
        year = this.year_id.name
        year_id = this.year_id.id
        month = this.month
        if month == '1':
            month_name = 'January'
        elif month == '2':
            month_name = 'February'
        elif month == '3':
            month_name = 'March'
        elif month == '4':
            month_name = 'April'
        elif month == '5':
            month_name = 'May'
        elif month == '6':
            month_name = 'June'
        elif month == '7':
            month_name = 'July'
        elif month == '8':
            month_name = 'August'
        elif month == '9':
            month_name = 'September'
        elif month == '10':
            month_name = 'October'
        elif month == '11':
            month_name = 'November'
        elif month == '12':
            month_name = 'December'
        else:
            raise osv.except_osv(_('Warning !'),_("Specify month correctly. "))
        if int(month) in [1,3,5,7,8,10,12]:
            join_date=year +'-'+month+'-'+'31'
        if int(month) in [4,6,9,11]:
            join_date=year +'-'+month+'-'+'30'
        if int(month) in [2]:
            if int(year) % 4 == 0:
                join_date=year +'-'+month+'-'+'29'
            else:
                join_date=year +'-'+month+'-'+'28'
        
        #Define the font attributes for header
        fnt = Font()
        fnt.name = 'Arial'
        fnt.height= 275
        
        #Define the font attributes for header
        content_fnt = Font()
        content_fnt.name ='Arial'
        content_fnt.height =220
        align_content = Alignment()
        align_content.horz= Alignment.HORZ_CENTER
     
        borders = Borders()
        borders.left = 0x02
        borders.right = 0x02
        borders.top = 0x02
        borders.bottom = 0x02
        
        #The text should be centrally aligned
        align = Alignment()
        align.horz = Alignment.HORZ_CENTER
        align.vert = Alignment.VERT_CENTER
        
        #We set the backgroundcolour here
        pattern = Pattern()
        pattern.pattern = Pattern.SOLID_PATTERN
        pattern.pattern_fore_colour =  0x1F

        #apply the above settings to the row(0) header
        style_header= XFStyle()
        style_header.font= fnt
        style_header.pattern= pattern
        style_header.borders = borders
        style_header.alignment=align    
        
        #Define the font attributes for header
        fnt1 = Font()
        fnt1.name = 'Arial'
        fnt1.height= 275
        
        #Define the font attributes for header
        content_fnt1 = Font()
        content_fnt1.name ='Arial'
        content_fnt1.height =220
        align_content1 = Alignment()
        align_content1.horz= Alignment.HORZ_CENTER
     
        borders1 = Borders()
        borders1.left = 0x02
        borders1.right = 0x02
        borders1.top = 0x02
        borders1.bottom = 0x02
        
        #The text should be centrally aligned
        align1 = Alignment()
        align1.horz = Alignment.HORZ_CENTER
        align1.vert = Alignment.VERT_CENTER
        
        #We set the backgroundcolour here
#.........这里部分代码省略.........
开发者ID:arpitb827,项目名称:Salary-notifications,代码行数:101,代码来源:budget.py


示例14: range

    pattern.pattern = Pattern.SOLID_PATTERN     # 设置其模式为实型
    pattern.pattern_fore_colour = i
    # 设置单元格背景颜色 0 = Black, 1 = White, 2 = Red, 3 = Green, 4 = Blue, 5 = Yellow, 6 = Magenta,  the list goes on...
    style.pattern = pattern             # 将赋值好的模式参数导入Style
    sheet.write_merge(i, i, 0, 2, Line_data, style) #以合并单元格形式写入数据,即将数据写入以第1/2/3列合并德单元格内

for i in range(0x00,0xff):              # 设置单元格内字体样式
    fnt = Font()                        # 创建一个文本格式,包括字体、字号和颜色样式特性
    fnt.name = '微软雅黑'                # 设置其字体为微软雅黑, 'SimSun'    # 指定“宋体”
    fnt.colour_index = i                # 设置其字体颜色
    fnt.bold = True
    style.font = fnt                    #将赋值好的模式参数导入Style
    sheet.write_merge(i,i,3,5,Line_data,style)  #以合并单元格形式写入数据,即将数据写入以第4/5/6列合并德单元格内

for i in range(0, 0x53):                # 设置单元格下框线样式
    borders = Borders()
    borders.left = i
    borders.right = i
    borders.top = i
    borders.bottom = i
    style.borders = borders         #将赋值好的模式参数导入Style
    sheet.write_merge(i,i,6,8,Line_data,style)  #以合并单元格形式写入数据,即将数据写入以第4/5/6列合并德单元格内

for i in range(6, 80):                  # 设置单元格下列宽样式
    sheet.write(0,i,Line_data,style)
    sheet.col(i).width = 0x0d00 + i*50

path_py = "/home/gswewf/jian1.bmp"         #读取插入图片以.py运行时路径,images和.py在同一目录下

sheet.insert_bitmap(path_py, 2, 9)         #插入一个图片
开发者ID:gswyhq,项目名称:hello-world,代码行数:30,代码来源:xlwt设置excel单元格字体及格式.py


示例15: exportToExcel

 def exportToExcel(self,objectProject):
     
     book = Workbook();
     sheet1 = book.add_sheet('Sheet 1')
     sheet1.col(1).width = 256*20;
     sheet1.col(2).width = 256*80;
     sheet1.col(3).width = 256*10;
     sheet1.col(4).width = 256*20;
     
     default_book_style = book.default_style
     default_book_style.font.height = 20 * 36    # 36pt
     
     fnt = Font()
     fnt.name = 'Arial'
     fnt.colour_index = 4
     fnt.bold = True
     
     borders = Borders()
     borders.left = Borders.THIN
     borders.right = Borders.THIN
     borders.top = Borders.THIN
     borders.bottom = Borders.THIN
     
     pattern = Pattern();
     pattern.pattern = Pattern.SOLID_PATTERN
     pattern.pattern_fore_colour = 23
     
     
     algn1 = Alignment();
     algn1.wrap = 1;
     #algn1.horz = Alignment.HORZ_CENTER
     #algn1.vert = Alignment.VERT_TOP
     
     alignHeader =  Alignment();
     alignHeader.horz = Alignment.HORZ_CENTER;
     
     alignTop =  Alignment();
     alignTop.vert = Alignment.VERT_TOP    
     print "export";
     if( objectProject):
         i=0;
        
         print "start" ;
         
         styleHead = XFStyle();
         styleHead.font = fnt;
         styleHead.borders = borders;
         styleHead.pattern = pattern;
         styleHead.alignment = alignHeader;
         
         row1 = sheet1.row(i) ;
         row1.write(0, ('risk id').decode('UTF8'),styleHead );
         sheet1.write_merge(i, i, 1, 2,  ('รายละเอียด').decode('UTF8')  ,styleHead  );
         
       #  row1.write(1, ('รายละเอียด').decode('UTF8'));
         
         row1.write(3, ('วันที่รายงาน').decode('UTF8'), styleHead );
         row1.write(4, ('หน่วยที่รายงาน').decode('UTF8'), styleHead );
         
         i=i+1; 
         
         
         style1 = XFStyle();
         style1.alignment = algn1;
         
         #style0 = xlwt.easyxf('font: name Times New Roman size 20, color-index black, bold on')
         
         
         for value in  objectProject:
             
             row1 = sheet1.row(i) ;
             
             styleRowDetail = XFStyle();
             styleRowDetail.borders = borders;
             styleRowDetail.alignment = alignTop;
             
             StyleRowDetailWrap = styleRowDetail ;
             StyleRowDetailWrap.alignment = algn1;
             
             styleDate = XFStyle()
             styleDate.num_format_str = 'DD-MM-YYYY'   ;   #'D-MMM-YY';
             styleDate.borders = borders;
             
             row1.write(0, value.get('risk_management_id'),styleRowDetail  );
             #row1.write(1, value.get('risk_detail').decode('UTF8') , style1);
             sheet1.write_merge(i, i, 1, 2,   value.get('risk_detail').decode('UTF8') , StyleRowDetailWrap    ); 
             row1.write(3, value.get('report_date') ,styleDate);
             row1.write(4, value.get('report').decode('UTF8') ,styleRowDetail );
             
             i=i+1; 
             row1 = sheet1.row(i) ;
             row1.write(0," "  );
             row1.write(1,('หน่วยที่เกี่ยวข้อง').decode('UTF8') ,styleHead      );
             sheet1.write_merge(i, i, 2, 3,('รายละเอียดการตอบ').decode('UTF8') , styleHead );
             i=i+1; 
             
             for sub in value.get('response') :
                 row1 = sheet1.row(i) ;
                 row1.write(0," "  );
                 row1.write(1,sub.get('risk_team').decode('UTF8') , styleRowDetail   );
#.........这里部分代码省略.........
开发者ID:tongpa,项目名称:bantakCom,代码行数:101,代码来源:risktoexcel.py


示例16: write_cursor_to_excel

def write_cursor_to_excel(curs, filename, sheetTitle):


    """write_cursor_to_excel






    curs: a cursor for an open connection to an oracle database


    filename: name of the XLS file to create


    sheetTitle: name of the sheet to create


    """


    # create style for header row - bold font, thin border below


    fnt = Font()


    fnt.bold = True


    borders = Borders()


    borders.bottom = Borders.THIN


    hdrstyle = XFStyle()


    hdrstyle.font = fnt


    hdrstyle.borders = borders


    # create a date format style for any date columns, if any


    datestyle = XFStyle()


    datestyle.num_format_str = 'DD/MM/YYYY'


    # create the workbook. (compression: try to reduce the number of repeated styles)


    wb = Workbook(style_compression=2)


    # the workbook will have just one sheet


    sh = wb.add_sheet(sheetTitle)


    # write the header line, based on the cursor description


    c = 0


    colWidth = []


    for col in curs.description:


        #col[0] is the column name


        #col[1] is the column data type


        sh.write(0, c, col[0], hdrstyle)


        colWidth.append(1) # arbitrary min cell width


        if col[1] == cx_Oracle.DATETIME:


            colWidth[-1] = len(datestyle.num_format_str)


        if colWidth[-1] < len(col[0]):


#.........这里部分代码省略.........
开发者ID:libopen,项目名称:mysear,代码行数:101,代码来源:table2Excel.py


示例17: archivo_excel

def archivo_excel(titulo, archivo_logo = 'unprg.bmp', label_resumen = [], datos_resumen = [], heads = [], color = 0x9ACD32, registros = [], nombre_archivo = 'descargar.xls'):

    book = Workbook()
    sheet1 = book.add_sheet('Hoja 01')

    #estilos de celda titulo
    fnt_titulo = Font()
    fnt_titulo.name = 'Arial'
    fnt_titulo.bold = True

    style_titulo = XFStyle()
    style_titulo.font = fnt_titulo

    #estilos de celda etiqueta resumen
    fnt_etiqueta_resumen = Font()
    fnt_etiqueta_resumen.name = 'Arial'
    fnt_etiqueta_resumen.bold = True

    style_etiqueta_resumen = XFStyle()
    style_etiqueta_resumen.font = fnt_etiqueta_resumen

    #estilos de celda datos resumen
    fnt_dato_resumen = Font()
    fnt_dato_resumen.name = 'Arial'

    style_dato_resumen = XFStyle()
    style_dato_resumen.font = fnt_dato_resumen

    #estilos de celda heads
    fnt_heads = Font()
    fnt_heads.name = 'Arial'
    fnt_heads.bold = True
    borders_heads = Borders()
    borders_heads.left = Borders.THIN
    borders_heads.right = Borders.THIN
    borders_heads.top = Borders.THIN
    borders_heads.bottom = Borders.THIN
    pattern_heads = Pattern()
    pattern_heads.pattern = Pattern.SOLID_PATTERN
    pattern_heads.pattern_fore_colour = color

    style_heads = XFStyle()
    style_heads.font = fnt_heads
    style_heads.borders = borders_heads
    style_heads.pattern = pattern_heads

    #estilos de celda registros
    fnt_registros = Font()
    fnt_registros.name = 'Arial'
    borders_registros = Borders()
    borders_registros.left = Borders.THIN
    borders_registros.right = Borders.THIN
    borders_registros.top = Borders.THIN
    borders_registros.bottom = Borders.THIN


    style_registros = XFStyle()
    style_registros.font = fnt_registros
    style_registros.borders = borders_registros
    
    
    sheet1.insert_bitmap(settings.MEDIA_ROOT + 'archivos_excel/%s' % archivo_logo, 1, 0)

    #escribir el titulo
    sheet1.write(10,0,titulo, style_titulo)

    row = 12
    col = 0
    #escribir las etiquetas del resumen
    for etiqueta in label_resumen:
        sheet1.write(row, col, etiqueta, style_etiqueta_resumen)
        row+=1

    row = 12
    col = 1
    #escribir los datos del resumen
    for dato in datos_resumen:
        sheet1.write(row, col, dato, style_dato_resumen)
        row+=1

    row+=1
    col = 0
    #escribimos los encabezados
    for head in heads:
        sheet1.write(row,col,head,style_heads)
        col+=1

    row+=1
    col=1
    n = 1
    #recorremos la lista y escribimos los datos
    for fila in registros:
        sheet1.write(row,0,n,style_registros)
        for dato in fila:
            sheet1.write(row,col,dato,style_registros)
            col+=1
        col=1
        row+=1
        n+=1

#.........这里部分代码省略.........
开发者ID:lizceth,项目名称:Mysite,代码行数:101,代码来源:reportes.py


示例18: Font

from datetime import date
from xlwt import Workbook, XFStyle, Borders, Pattern, Font

fnt = Font()
fnt.name = 'Arial'

borders = Borders()
borders.left = Borders.THICK
borders.right = Borders.THICK
borders.top = Borders.THICK
borders.bottom = Borders.THICK

pattern = Pattern()
pattern.pattern = Pattern.SOLID_PATTERN
pattern.pattern_fore_colour = 0x0A

style = XFStyle()
style.num_format_str='YYYY-MM-DD'
style.font = fnt
style.borders = borders
style.pattern = pattern

book = Workbook()
sheet = book.add_sheet('A Date')
sheet.write(1,1,date(2009,3,18),style)

book.save('date.xls')
开发者ID:DivyaShanmugam,项目名称:pydanny-event-notes,代码行数:27,代码来源:xfstyle_format.py


示例19: exportToXls

    def exportToXls(self):
        # opening file dialog
        fileName = QFileDialog.getSaveFileName(self, "Save as", RES, "Microsoft Excel Spreadsheet (*.xls)")

        if fileName.count() > 0:
            try:
                COLUMN_WIDTH = 3000

                alignment = Alignment()
                alignment.horizontal = Alignment.HORZ_CENTER
                alignment.vertical = Alignment.VERT_CENTER

                borders = Borders()
                borders.left = Borders.THIN
                borders.right = Borders.THIN
                borders.top = Borders.THIN
                borders.bottom = Borders.THIN

                style = XFStyle()
                style.alignment = alignment
                style.borders = borders

                font = Font()
                font.bold = True
                headerStyle = XFStyle()
                headerStyle.font = font

                separate = Borders()
                separate.left = Borders.THIN
                separate.right = Borders.DOUBLE
                separate.top = Borders.THIN
                separate.bottom = Borders.THIN
                separateStyle = XFStyle()
                separateStyle.borders = separate

                book = Workbook(encoding="utf-8")

                # modelling data
                if self.exportStepByStep.isChecked():
                    dec_sheet = book.add_sheet("Data decomposition")

                    # decomposition data
                    if self.exportData.isChecked():
                        # initial data
                        column = 0
                        row = 0
                        dec_sheet.write(row, column, "Time series", headerStyle)
                        dec_sheet.col(column).width = COLUMN_WIDTH
                        row += 1
                        for item in self.parentWidget().currentDataSet[0]:
                            dec_sheet.write(row, column, item, separateStyle)
                            row += 1

                        # decomposition
                        for lvl in self.parentWidget().wCoefficients:
                            row = 0
                            column += 1
                            dec_sheet.write(row, column, "Level" + str(column - 1), headerStyle)
                            dec_sheet.col(column).width = COLUMN_WIDTH
                            row += 1
                            for item in lvl:
                                dec_sheet.write(row, column, item, style)
                                row += 1

                    # decomposition graphs
                    if self.exportGraph.isChecked():
                        pass

                    levels_sheet = book.add_sheet("Multiscale forecast")

                    # levels data
                    if self.exportData.isChecked():
                        column = 0
                        for lvl in self.parentWidget().processedWCoeffs:
                            row = 0
                            levels_sheet.write(row, column, "Level" + str(column), headerStyle)
                            levels_sheet.col(column).width = COLUMN_WIDTH
                            row += 1
                            for item in lvl:
                                levels_sheet.write(row, column, float(item), style)
                                row += 1
                            column += 1

                if self.exportForecast.isChecked():
                    result_sheet = book.add_sheet("Results")

                    if self.exportData.isChecked():
                        # initial
                        column = 0
                        row = 0
                        result_sheet.write(row, column, "Initial data", headerStyle)
                        result_sheet.col(column).width = COLUMN_WIDTH
                        row += 1
                        for item in self.parentWidget().currentDataSet[0]:
                            result_sheet.write(row, column, item, separateStyle)
                            row += 1

                        # forecast
                        row = 0
                        column += 1
#.........这里部分代码省略.........
开发者ID:Xifax,项目名称:muscale,代码行数:101,代码来源:guiTool.py


示例20: exportToXls

    def exportToXls(self):
        # opening file dialog
        fileName = QFileDialog.getSaveFileName(self,
            'Save as', RES, 'Microsoft Excel Spreadsheet (*.xls)')

        if fileName.count() > 0:
            try:
                COLUMN_WIDTH = 3000

                alignment = Alignment()
                alignment.horizontal = Alignment.HORZ_CENTER
                alignment.vertical = Alignment.VERT_CENTER

                borders = Borders()
                borders.left = Borders.THIN
                borders.right = Borders.THIN
                borders.top = Borders.THIN
                borders.bottom = Borders.THIN

                style = XFStyle()
                style.alignment = alignment
                style.borders = borders

                font = Font()
                font.bold = True
                headerStyle = XFStyle()
                headerStyle.font = font

                separate = Borders()
                separate.left = Borders.THIN
                separate.right = Borders.DOUBLE
                separate.top = Borders.THIN
                separate.bottom = Borders.THIN
                separateStyle = XFStyle()
                separateStyle.borders = separate

                book = Workbook(encoding='utf-8')

                # modelling data
                dec_sheet = book.add_sheet('Data decomposition')

                # decomposition data
                # initial data
                column = 0
                row = 0
                dec_sheet.write(row, column, 'Time series', headerStyle)
                dec_sheet.col(column).width = COLUMN_WIDTH
                row += 1
                for item in self.data[0]:
                    dec_sheet.write(row, column, item, separateStyle)
                    row += 1

                # decomposition
                for lvl in self.wCoefficients:
                    row = 0
                    column += 1
                    dec_sheet.write(row, column, 'Level' + str(column - 1), headerStyle)
                    dec_sheet.col(column).width = COLUMN_WIDTH
                    row += 1
                    for item in lvl:
                        dec_sheet.write(row, column, item, style)
                        row += 1

                # decomposition gra 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python xlwt.Font类代码示例发布时间:2022-05-26
下一篇:
Python xlwt.easyxf函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap