首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >win32com LineStyle Excel

win32com LineStyle Excel
EN

Stack Overflow用户
提问于 2022-07-17 19:09:02
回答 1查看 128关注 0票数 0

幸运的是,我找到了这一面:https://www.linuxtut.com/en/150745ae0cc17cb5c866/

(有许多行类型定义了Excel )

代码语言:javascript
复制
(xlContinuous    =  1
xlDashDot       =  4
xlDashDotDot    =  5
xlSlantDashDot  = 13
xlDash          = -4115
xldot           = -4118
xlDouble        = -4119
xlLineStyleNone = -4142)

我运行时使用的是+/- 100.000次设置行,因为我认为任何地方都应该是将这一行放进我的图片中的索引号,但是它们都是.为什么不行?

我该怎么设置这条线?为什么在一个巨大的负值中有一些行索引而不是1,2,3.?我怎样才能发现像“数字”这样的事情呢?

为什么这是可能的,为了发送特定位置的应用程序数据,我想进一步了解一下,我在哪里可以了解到更多呢?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-07-17 20:39:26

(1) --你找不到线上虚线的介质,因为没有。作为边框绘制的线是lineStyleWeight的组合。lineStyle为xlDash,权重为表中值03的xlThin,值08为xlMedium

(2)来了解如何在VBA中设置这样的内容,使用宏记录器,它将显示在设置边框时设置了lineStyle、权重(和颜色)。

(3)有许多描述所有常量的页面(如查看注释中链接到的@FaneDuru )。它们也可以在微软本身找到:https://learn.microsoft.com/en-us/office/vba/api/excel.xllinestylehttps://learn.microsoft.com/en-us/office/vba/api/excel.xlborderweight。似乎有人将它们转换为linuxTut页面上的Python常量。

(4)不问为什么枚举不是连续值。我认为,特别是带负数的常量,有更多的用途。只是不要直接使用这些值,总是使用已定义的常量。

(5)您可以假设没有定义常量的数值可以工作,但是结果是不可预测的。没有常数的价值观不太可能产生“新的”(如不同的边框风格)。

正如您在下表中所看到的,并非所有组合都会给出不同的边框。将权重设置为xlHairline将忽略lineStyle。将其设置为xlThick也会忽略lineStyle,但xlDouble除外。另一方面,当权重不是xlDouble时,将忽略xlThick

代码语言:javascript
复制
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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73014614

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档