在xlwings模块里如何设置单元格增加单斜线和双斜线

在xlwings模块里如何设置单元格增加单斜线和双斜线,如:
1、在单元格里增加单斜线和文字:

在xlwings模块里如何设置单元格增加单斜线和双斜线
2、在单元格里增加双斜线和文字:

在xlwings模块里如何设置单元格增加单斜线和双斜线

Jason990420
最佳答案
import xlwings as xw
from xlwings.constants import BordersIndex

"""
class BordersIndex:
    xlDiagonalDown     =  5
    xlDiagonalUp       =  6
    xlEdgeLeft         =  7
    xlEdgeTop          =  8
    xlEdgeBottom       =  9
    xlEdgeRight        = 10
    xlInsideVertical   = 11
    xlInsideHorizontal = 12
"""

wb = xw.Book()

sht = wb.sheets.active
cell = sht.range('c3')

cell.api.Borders(BordersIndex.xlDiagonalDown).LineStyle = 1
cell.api.Borders(BordersIndex.xlDiagonalDown).Weight    = 3
cell.api.Borders(BordersIndex.xlDiagonalUp).LineStyle   = 1
cell.api.Borders(BordersIndex.xlDiagonalUp).Weight      = 3

wb.save('D:/1.xlsx')
wb.close()

file

1个月前 评论
讨论数量: 1
Jason990420
import xlwings as xw
from xlwings.constants import BordersIndex

"""
class BordersIndex:
    xlDiagonalDown     =  5
    xlDiagonalUp       =  6
    xlEdgeLeft         =  7
    xlEdgeTop          =  8
    xlEdgeBottom       =  9
    xlEdgeRight        = 10
    xlInsideVertical   = 11
    xlInsideHorizontal = 12
"""

wb = xw.Book()

sht = wb.sheets.active
cell = sht.range('c3')

cell.api.Borders(BordersIndex.xlDiagonalDown).LineStyle = 1
cell.api.Borders(BordersIndex.xlDiagonalDown).Weight    = 3
cell.api.Borders(BordersIndex.xlDiagonalUp).LineStyle   = 1
cell.api.Borders(BordersIndex.xlDiagonalUp).Weight      = 3

wb.save('D:/1.xlsx')
wb.close()

file

1个月前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!