Free Support Forum - aspose.com

Solid Cell Borders Instead of Dashed

Hi,

I am using Aspose.Cells latest version to create the output of a report and saving it as pdf and serve to the client. However, I need to use solid borders for all data cells instead of the dashed borders (which is default when printgridlines is true).

I have tried the below, which lets me change the color and thickness, but borders are always dashed:

Aspose.Cells.Range range = workbook.Worksheets[0].Cells.CreateRange(0, 0, workbook.Worksheets[0].Cells.MaxDataRow, workbook.Worksheets[0].Cells.MaxDataColumn);
Aspose.Cells.Style style = range[0, 0].GetStyle();

style.SetBorder(Aspose.Cells.BorderType.BottomBorder, Aspose.Cells.CellBorderType.Hair, System.Drawing.Color.Blue);
style.SetBorder(Aspose.Cells.BorderType.TopBorder, Aspose.Cells.CellBorderType.Hair, System.Drawing.Color.Blue);
style.SetBorder(Aspose.Cells.BorderType.LeftBorder, Aspose.Cells.CellBorderType.Hair, System.Drawing.Color.Blue);
style.SetBorder(Aspose.Cells.BorderType.RightBorder, Aspose.Cells.CellBorderType.Hair, System.Drawing.Color.Blue);

range.SetStyle(style);

Please advise on how can I simple mimic selecting a range of cells in MS Excel and choosing "all borders" option.

Thanks.

Hi,


Well, I think you may try to use Thick, Medium or Thin line type etc. accordingly for your needs, see the following lines of code, e.g

style.SetBorder(Aspose.Cells.BorderType.BottomBorder, Aspose.Cells.CellBorderType.Thick, System.Drawing.Color.Blue);
style.SetBorder(Aspose.Cells.BorderType.TopBorder, Aspose.Cells.CellBorderType.Thick, System.Drawing.Color.Blue);
style.SetBorder(Aspose.Cells.BorderType.LeftBorder, Aspose.Cells.CellBorderType.Thick, System.Drawing.Color.Blue);
style.SetBorder(Aspose.Cells.BorderType.RightBorder, Aspose.Cells.CellBorderType.Thick, System.Drawing.Color.Blue);


Thank you.

Ok, that worked. Somehow I thought I already tried it and got dashed borders - but testing once again, I noticed that your are right.

Thanks.

Hi,

Thanks for your posting and using Aspose.Cells for .NET.

We are pleased to know your issue is resolved. If you face any other issue, please feel free to post, we will be glad to help you more.