当前位置: 动力学知识库 > 问答 > 编程问答 >

vb.net - Aspose.Cells - Set Border For Range

问题描述:

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!

分享给朋友:
您可能感兴趣的文章:
随机阅读: