cell 选中不变蓝色

这个使用自带的风格就可以实现:

在初始化cell的时候加入selectionStyle即可

代码如下:

  1. if(cell==nil){
  2. //我不写cell的初始化啦
  3. cell.selectionStyle=UITableViewCellSelectionStyleNone;//这句话决定了cell选中时候背景不变蓝
  4. }
def test_specific_markings(): """测试指定文件和位置的标记功能,每次标记后立即清除""" pythoncom.CoInitialize() try: # ===== 用户可配置区域 ===== DOC_PATH = r"D:\GitProjects\T社量産_第八弾\Input\250723update\250721(From DN)\after\MET-M_FUEL-CSTD-4-XX-X-C7-305D-a.docx" EXCEL_PATH = r"D:\GitProjects\test\test7(10)\before\MET-G_T_SCREEN-CSTD-4-25-B-C19.xlsx" # 使用data_coord指定位置 ROW_DATA_COORD = 'A14' # 用于行标记的起始单元格 COL_DATA_COORD = 'D4' # 用于列标记的起始单元格 CELL_COORD = 'H9' # 用于单元格标记的起始单元格 TABLE_COORD = 'B4' # 用于单元格标记的起始单元格 PARAGRAPH_INDEX = 3 TABLE_INDEX = 1 PICTURE_INDEX = 0 SAVE_DOCUMENT = True AUTO_CLOSE_DELAY = 50 # 自动关闭前的等待时间(秒) # ========================= # 创建Word应用 # word_app = win32.DispatchEx('Word.Application') # word_app.Visible = True # 创建Excel应用 excel_app = win32.DispatchEx("Excel.Application") excel_app.Visible = True excel_app.DisplayAlerts = True # 打开Excel文档 excel_wb = excel_app.Workbooks.Open(EXCEL_PATH, ReadOnly=False) excel_ws = excel_wb.Worksheets(1) # 打开Word文档 # word_doc = word_app.Documents.Open(DOC_PATH) ############################## # Excel 标记与清除测试 ############################## # === 单元格标记与清除 === print(f"\n测试Excel单元格标记 (位置: {CELL_COORD})...") try: target_cell = excel_ws.Range(CELL_COORD) target_cell.Application.Goto(target_cell, True) # 添加标记 task_handler.add_mark_for_cell(excel_ws, target_cell,color_type =0x00FF00, number=8) print("✅ 单元格标记完成") # 等待查看标记 time.sleep(5) # 清除标记 #task_handler.clear_excel_mark(excel_wb) print("✅ 单元格标记已清除") time.sleep(2) # 等待查看清除效果 except Exception as e: print(f"❌ 单元格标记/清除失败: {str(e)}") traceback.print_exc() 就这一本单元格标记的红框显示不出来,什么原因: def add_mark_for_cell(ws, cell,color_type = 255, number=None): # 添加红色边框矩形(保持不变) red_rect = ws.Shapes.AddShape( Type=1, Left=cell.Left - 5, Top=cell.Top - 5, Width=cell.Width + 10, Height=cell.Height + 10 ) red_rect.Line.ForeColor.RGB = color_type red_rect.Line.Weight = 2.25 red_rect.Fill.Visible = 0 red_rect.Name = "lauf_border" if number is not None: label_left = cell.Left - 35 label_top = cell.Top - 5 # 创建文本框 label = ws.Shapes.AddTextbox( Orientation=1, Left=label_left, Top=label_top, Width=30, Height=20 ) # 强制激活文本框架 label.TextFrame.AutoSize = True # 触发框架初始化 label.Name = f"lauf_label_{number}" # 直接使用Characters()方法 text_chars = label.TextFrame.Characters() text_chars.Text = str(number) text_chars.Font.Bold = True text_chars.Font.Size = 10 text_chars.Font.Color = 0xFFFFFF # 设置样式(在文本添加后) label.Fill.ForeColor.RGB = 0xFF8800 #蓝色 label.Fill.Visible = True label.Line.Visible = False label.ZOrder(0) red_rect.ZOrder(0)
最新发布
10-14
<div class="hour-row" v-for="(hour, hIndex) in hourValues" :key="hIndex"> <div class="time-cell time-cell-bg" v-for="(day, dIndex) in weekDays" :key="dIndex" :style="getCellStyle(dIndex, hIndex, itemBgHeight, itemPosition)" :class="{ selected: isSelected(dIndex, hIndex) }" :data-day="dIndex" :data-hour="hIndex" :data-minute="0"> {{ hIndex }} </div> </div> <button @click="getHeight">点击</button> getCellStyle(day, hour, itemBgHeight, itemPosition) { const cell = this.cellStates[`${day},${hour}`]; // return cell ? { backgroundColor: cell.color}; this.itemBgHeight = itemBgHeight; this.itemPosition = itemPosition; if (cell) { console.log('cell', cell); } return cell ? { '--bg-height': this.itemBgHeight, '--position': this.itemPosition } : {}; }, getHeight() { const day = 0; const startTimeH = 2; const itemBgHeight = 60; this.getCellStyle(day, startTimeH, `${itemBgHeight}%`, 'bottom'); }, //cell背景渐变色 .time-cell-bg { /* 基础样式 */ // width: 300px; // height: 200px; // border: 1px solid #ccc; /* 背景渐变实现 */ background-image: linear-gradient(var(--gradient-direction, to bottom), $blueColor, $blueColor var(--bg-height, 0%), transparent var(--bg-height, 0%), transparent); /* 根据位置调整渐变方向 */ background-position: var(--bg-position); background-repeat: no-repeat; } /* 动态调整位置 */ .time-cell-bg[style*="top"] { --gradient-direction: to bottom; --bg-position: top; } .time-cell-bg[style*="bottom"] { --gradient-direction: to top; --bg-position: bottom; } 上面方法点击按钮,改变数组里某个div的背景颜色高度,其他的背景颜色高度保持不变
08-31
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值