Aspose.Cells - Set Border For Range

混江龙づ霸主 提交于 2019-12-11 03:34:48

问题


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?


回答1:


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!



来源:https://stackoverflow.com/questions/14834080/aspose-cells-set-border-for-range

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!