乔山办公网我们一直在努力
您的位置:乔山办公网 > excel表格制作 > 怎么用python openpyxl 写入excle设置某个...-win32 excel,win10自带excel在哪

怎么用python openpyxl 写入excle设置某个...-win32 excel,win10自带excel在哪

作者:乔山办公网日期:

返回目录:excel表格制作


from xlwt import Workbook import xlwt book = Workbook() sheet1 = book.add_sheet('Sheet 1') book.add_sheet('Sheet 2') st = xlwt.easyxf('pattern: pattern solid;') for i in range(0, 100): st = xlwt.easyxf('pattern: pattern solid;'...

see: http://nullege.com/codes/search/openpyxl.style.Color

example:

import openpyxl

from openpyxl.style import Color, Fill
from openpyxl.cell import get_column_letter
..

cell = sheet.cell(column=pt[0], row=pt[1])
cell.style.fill.fill_type = Fill.FILL_SOLID
cell.style.fill.start_color = Color(color)
cell.style.fill.end_color = Color(color)
borders = xlwt.Borders()
borders.left = 1
borders.right = 1
borders.top = 1
borders.bottom = 1
borders.bottom_colour=0x3A    

style = xlwt.XFStyle()
style.borders = borders 

sheet.write(0, 0, 'Firstname',style)


#Win32#打开EXCEL
WinApp = win32com.client.DispatchEx('Excel.Application')
#要处理的excel文件路径#out.file是文件  绝对路径
WinBook = WinApp.Workbooks.Open(out_file)
 #要处理的excel页
WinSheet = WinBook.Worksheets('Sheet1')

#单元格添加颜色7a64e4b893e5b19e332
WinSheet.Cells(1, 1).Interior.ColorIndex = 3
#或者Range("A1") 
WinSheet.Range("A1").Interior.ColorIndex = 3   
#3=红色,不同的值代表不同的颜色,可以去查看msdn  vba 文档,这就不详细说了

#再是RGB调色方式#Cells 和 Range都可以,Range可以选择一大片区域
WinSheet.Cells(1, 1).Interior.Color = RGB(0, 0, 255) 
#或
WinSheet.Range("A1").Interior.Color = RGB(255, 0, 255) 
#字体的颜色也是一样
WinSheet.Cells(1, 1).Font.ColorIndex = 3
WinSheet.Cells(1, 1).Font.Color = RGB(0, 0, 255)

相关阅读

关键词不能为空
极力推荐
  • <em>北京</em>出租车计价<em>excel</em>计算公式-e

  • 可以实现C1中输入公式:=IF(B1>=0,$A$1+TIME(B1,0,0),$A$1-TIME(-B1,0,0))然后抄向下拖动就可以了.至于时间的格式,可以设置成YYYY-MM-DD hh:mm因为时间不能为袭负值,所以要判断zdB列为负时,作为减处理

ppt怎么做_excel表格制作_office365_word文档_365办公网