Aspose.Cells - 为范围设置边框 [英] Aspose.Cells - Set Border For Range
问题描述
我可以看到的唯一方法是编写一个方法枚举范围内的所有单元格以确定正确的边框属性。这似乎是一个稍微可怕的方式来实现我所看到的一个简单的任务,所以希望有一个更好的办法!
是否有?
好吧,让我们开始吧。
假设我们想添加边界到从A2单元格到H6单元格区域的范围。
请记住Aspose中的单元格索引是基于零的。
所以A2单元格的行1和列0的索引。
定义范围
Dim range = current_worksheet.Cells.CreateRange(1,0,5,8)
设置边框 p>
range.SetOutlineBorder(Aspose.Cells.BorderType.TopBorder,Aspose.Cells.CellBorderType.Thick,Drawing.Color.Blue)
range.SetOutlineBorder(Aspose.Cells.BorderType.BottomBorder,Aspose.Cells.CellBorderType.Thick,Drawing.Color.Blue)
range.SetOutlineBorder(Aspose.Cells.BorderType.LeftBorder,Aspose.Cells.CellBorderType。 Thick,Drawing.Color.Blue)
range.SetOutlineBorder(Aspose.Cells.BorderType.RightBorder,Aspose.Cells.CellBorderType.Thick,Drawing.Color.Blue)
就是这样!
I'm currently working with Aspose.Cells. I've largely managed to do what I need to do however one issue remains; I can't see an easy way to apply a border to a defined range. I can for a cell, however when applying the style to the range all cells in the range are formatted.
The only way I can see around this is to write a method to enumerate all cells within the range to determine the right border attributes. This seems a slightly hideous way to achieve what I see as a simple task, so am hoping there is a better way!
Is there?
Ok let's start. Assuming we want to add borders to a range from A2 cell to H6 cell range. Always remember that cell index in Aspose is Zero based. So the A2 cell has index of row 1 and column 0.
Define the range
Dim range = current_worksheet.Cells.CreateRange(1, 0, 5, 8)
Set the borders
range.SetOutlineBorder(Aspose.Cells.BorderType.TopBorder,Aspose.Cells.CellBorderType.Thick,Drawing.Color.Blue)
range.SetOutlineBorder(Aspose.Cells.BorderType.BottomBorder,Aspose.Cells.CellBorderType.Thick, Drawing.Color.Blue)
range.SetOutlineBorder(Aspose.Cells.BorderType.LeftBorder,Aspose.Cells.CellBorderType.Thick, Drawing.Color.Blue)
range.SetOutlineBorder(Aspose.Cells.BorderType.RightBorder,Aspose.Cells.CellBorderType.Thick, Drawing.Color.Blue)
That's it!
这篇关于Aspose.Cells - 为范围设置边框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!