Free Support Forum - aspose.com

Gridlines are not visible when styles are applied to cells

Hi,
I have an issue with the gridlines.
If i have a set of consecutive rows and columns of the worksheet which are set to a particular style (the same one), all the cells seem to merge together in the sense that the gridlines between them disappear.

I used the sheet.isGridLinesVisible = true property but it still doesnt work for me.

Is there a way around this issue ?

regards,
Jaideep.

Hi Jaideep,

Thanks for considering Aspose

If i have a set of consecutive rows and columns of the worksheet which are set to a particular style (the same one), all the cells seem to merge together in the sense that the gridlines between them disappear.

Well, when you apply some style formattings to consecutive set of cells in rows and columns, the cells will look like as merged cells and the girdlines won't be visible. For confirmation, you may test it in MS Excel.

If you still have some doubts, could you manually implement it (what your are requiring for ) in MS Excel and post the template excel file here. So, that we may try to copy the same look using Aspose.Cells APIs.

Thank you.

Thanks for the reply amjad.

I have figured a work around, since the gridlines are not visible, i am manually drawing borders around the cells which seem to get merged.

Now in order to do that i have to call the
cell.Style.Borders(BorderType.TopBorder).Color = somecolor method for each border (top,bottom,left, right). Is there a method which i can just pass the cell to, and set all 4 borders in one call ?

Please let me know.

regards,
Jaideep.

Hi,

If your cells are consecutive cells, I think you 'd better create a named range based on those cells and set borders to the range.

E.g.,

[C#]
Workbook workbook = new Workbook();
Cells cells = workbook.Worksheets[0].Cells;
Range range = cells.CreateRange("B6", "P216");
Style stl;
stl= workbook.Styles[workbook.Styles.Add()];
stl.Font.Name = "Arial";
stl.Font.IsBold = true;
stl.Font.Color = Color.Blue;
stl.Borders[BorderType.TopBorder].LineStyle = CellBorderType.Thin;
stl.Borders[BorderType.TopBorder].Color = Color.Blue;
stl.Borders[BorderType.LeftBorder].LineStyle = CellBorderType.Thin;
stl.Borders[BorderType.LeftBorder].Color = Color.Blue;
stl.Borders[BorderType.BottomBorder].LineStyle = CellBorderType.Thin;
stl.Borders[BorderType.BottomBorder].Color = Color.Blue;
stl.Borders[BorderType.RightBorder].LineStyle = CellBorderType.Thin;
stl.Borders[BorderType.RightBorder].Color = Color.Blue;
range.Style = stl;
workbook.Save(@"d:\test\t_rangeborders.xls");
[VB]
Dim workbook As Workbook = New Workbook()
Dim cells As Cells = workbook.Worksheets(0).Cells
Dim range As Range = cells.CreateRange("B6", "P216")
Dim stl As Style
stl= workbook.Styles(workbook.Styles.Add())
stl.Font.Name = "Arial"
stl.Font.IsBold = True
stl.Font.Color = Color.Blue
stl.Borders(BorderType.TopBorder).LineStyle = CellBorderType.Thin
stl.Borders(orderType.TopBorder).Color = Color.Blue
stl.Borders(BorderType.LeftBorder).LineStyle = CellBorderType.Thin
stl.Borders(BorderType.LeftBorder).Color = Color.Blue
stl.Borders(BorderType.BottomBorder).LineStyle = CellBorderType.Thin
stl.Borders(BorderType.BottomBorder).Color = Color.Blue
stl.Borders(BorderType.RightBorder).LineStyle = CellBorderType.Thin
stl.Borders(BorderType.RightBorder).Color = Color.Blue
range.Style = stl
workbook.Save("d:\test\t_rangeborders.xls")
Thank you.