如何使用VB.net从Excel中某个区域的单元格中删除边框?
实现目标: 删除范围单元格中的边框(如果有) 我有:如何使用VB.net从Excel中某个区域的单元格中删除边框?,.net,vb.net,excel,border,vba,.net,Vb.net,Excel,Border,Vba,实现目标: 删除范围单元格中的边框(如果有) 我有: Dim range As Excel.Range = sheet.Range("A2:K100") For Each cell In range // Some cells in the Range has borders // How to remove borders from cells in the range Next cell 请帮忙 我是Vb.net的新手 检查 干杯,祝你好运 range.Borders(Ex
Dim range As Excel.Range = sheet.Range("A2:K100")
For Each cell In range
// Some cells in the Range has borders
// How to remove borders from cells in the range
Next cell
请帮忙强>
我是Vb.net的新手 检查
干杯,祝你好运
range.Borders(Excel.XlBordersIndex.xlEdgeLeft).LineStyle = Excel.XlLineStyle.xlLineStyleNone
range.Borders(Excel.XlBordersIndex.xlEdgeRight).LineStyle = Excel.XlLineStyle.xlLineStyleNone
range.Borders(Excel.XlBordersIndex.xlEdgeTop).LineStyle = Excel.XlLineStyle.xlLineStyleNone
range.Borders(Excel.XlBordersIndex.xlEdgeBottom).LineStyle = Excel.XlLineStyle.xlLineStyleNone
range.Borders(Excel.XlBordersIndex.xlInsideHorizontal).LineStyle = Excel.XlLineStyle.xlLineStyleNone
range.Borders(Excel.XlBordersIndex.xlInsideVertical).LineStyle = Excel.XlLineStyle.xlLineStyleNone
删除单元格周围和单元格之间的边框(通过xlInsideHorizontal
和xlInsideVertical
)。如果需要对角线边框,请包括xlDiagonalDown
和xlDiagonalUp
好的,上面的代码非常冗长。以下方面也应该做到这一点:
For Each border in range.Borders
border.LineStyle = Excel.XlLineStyle.xlLineStyleNone
Next
range.Borders.LineStyle = Excel.XlLineStyle.xlLineStyleNone
见:
编辑:
查看MSDN页面时,我想知道这一行是否也能做到:
For Each border in range.Borders
border.LineStyle = Excel.XlLineStyle.xlLineStyleNone
Next
range.Borders.LineStyle = Excel.XlLineStyle.xlLineStyleNone
为什么所有的答案都这么复杂 对于整个图纸,请使用
With .Cells
.Borders.LineStyle = xlLineStyleNone
End With
对于一个范围,只需根据需要替换.Cells即可。Borders.LineStyle=xlNone它管理范围周围的边界,而不是范围内的边界。我正在修改这个问题以澄清问题。如果范围。。太大了。。那么,它能一次完成整个范围吗?它应该非常快,因为你没有像在你的样本中那样迭代每个单元格。你试过了吗?我想它类似于我们在每个单元格的边界上迭代。。我的意思是,你的解决方案看起来不错,但对整个范围没有直接的方法吗?我想一定有一个?等等。。一艘邮轮。。这就是我要找的。。伟大的THANX!!在Windows7:)2020上的Excel2007中,一行程序适用于我,这就是我正在寻找的答案。。谢谢。这是正确的答案。其他的都是不必要的复杂。