
幸运的是,我找到了这一面:https://www.linuxtut.com/en/150745ae0cc17cb5c866/
(有许多行类型定义了Excel )
(xlContinuous = 1
xlDashDot = 4
xlDashDotDot = 5
xlSlantDashDot = 13
xlDash = -4115
xldot = -4118
xlDouble = -4119
xlLineStyleNone = -4142)我运行时使用的是+/- 100.000次设置行,因为我认为任何地方都应该是将这一行放进我的图片中的索引号,但是它们都是.为什么不行?
我该怎么设置这条线?为什么在一个巨大的负值中有一些行索引而不是1,2,3.?我怎样才能发现像“数字”这样的事情呢?
为什么这是可能的,为了发送特定位置的应用程序数据,我想进一步了解一下,我在哪里可以了解到更多呢?
发布于 2022-07-17 20:39:26
(1) --你找不到线上虚线的介质,因为没有。作为边框绘制的线是lineStyle和Weight的组合。lineStyle为xlDash,权重为表中值03的xlThin,值08为xlMedium。
(2)来了解如何在VBA中设置这样的内容,使用宏记录器,它将显示在设置边框时设置了lineStyle、权重(和颜色)。
(3)有许多描述所有常量的页面(如查看注释中链接到的@FaneDuru )。它们也可以在微软本身找到:https://learn.microsoft.com/en-us/office/vba/api/excel.xllinestyle和https://learn.microsoft.com/en-us/office/vba/api/excel.xlborderweight。似乎有人将它们转换为linuxTut页面上的Python常量。
(4)不问为什么枚举不是连续值。我认为,特别是带负数的常量,有更多的用途。只是不要直接使用这些值,总是使用已定义的常量。
(5)您可以假设没有定义常量的数值可以工作,但是结果是不可预测的。没有常数的价值观不太可能产生“新的”(如不同的边框风格)。
正如您在下表中所看到的,并非所有组合都会给出不同的边框。将权重设置为xlHairline将忽略lineStyle。将其设置为xlThick也会忽略lineStyle,但xlDouble除外。另一方面,当权重不是xlDouble时,将忽略xlThick。
Sub border()
With ThisWorkbook.Sheets(1)
With .Range("A1:J18")
.Clear
.Interior.Color = vbWhite
End With
Dim lStyles(), lWeights(), lStyleNames(), lWeightNames
lStyles() = Array(xlContinuous, xlDash, xlDashDot, xlDashDotDot, xlDot, xlDouble, xlLineStyleNone, xlSlantDashDot)
lStyleNames() = Array("xlContinuous", "xlDash", "xlDashDot", "xlDashDotDot", "xlDot", "xlDouble", "xlLineStyleNone", "xlSlantDashDot")
lWeights = Array(xlHairline, xlThin, xlMedium, xlThick)
lWeightNames = Array("xlHairline", "xlThin", "xlMedium", "xlThick")
Dim x As Long, y As Long
For x = LBound(lStyles) To UBound(lStyles)
Dim row As Long
row = x * 2 + 3
.Cells(row, 1) = lStyleNames(x) & vbLf & "(" & lStyles(x) & ")"
For y = LBound(lWeights) To UBound(lWeights)
Dim col As Long
col = y * 2 + 3
If x = 1 Then .Cells(1, col) = lWeightNames(y) & vbLf & "(" & lWeights(y) & ")"
With .Cells(row, col).Borders
.LineStyle = lStyles(x)
.Weight = lWeights(y)
End With
Next
Next
End With
End Sub

https://stackoverflow.com/questions/73014614
复制相似问题