Applying borders to the cells

Hello,

I want to apply the borders , autofitt for the columns . For Getting Borders i have written below logic

but borders are not appearing. please help me on this.

I am attaching the sheet as well for better understanding

I attached the sheet named NewReportgen.xlsx in which i am expecting the borders

Workbook workbookEvalExtract = new Workbook();

Worksheet worksheetEvalExtract = workbookEvalExtract.Worksheets[0];

worksheetEvalExtract.IsGridlinesVisible = false;

worksheetEvalExtract.AutoFitColumn(0);

worksheetEvalExtract.AutoFitColumn(3);

worksheetEvalExtract.AutoFitColumn(4);

worksheetEvalExtract.AutoFitColumn(5);

worksheetEvalExtract.AutoFitColumn(6);

worksheetEvalExtract.AutoFitColumn(7);

worksheetEvalExtract.AutoFitColumn(8);

worksheetEvalExtract.AutoFitColumn(9);

Aspose.Cells.Cells cells = worksheetEvalExtract.Cells;

Aspose.Cells.Style style = new Aspose.Cells.Style();

cells[currentRow, 0].PutValue("Perimeter:");

style.Borders[BorderType.TopBorder].LineStyle = CellBorderType.Thick;

style.Borders[BorderType.TopBorder].Color = Color.Black;

style.Borders[BorderType.BottomBorder].LineStyle = CellBorderType.Thick;

style.Borders[BorderType.BottomBorder].Color = Color.Black;

style.Borders[BorderType.LeftBorder].LineStyle = CellBorderType.Thick;

style.Borders[BorderType.LeftBorder].Color = Color.Black;

style.Borders[BorderType.RightBorder].LineStyle = CellBorderType.Thick;

style.Borders[BorderType.RightBorder].Color = Color.Black;

cells[currentRow++, 1].PutValue(ReportRow["Perimeter"]);

Thank you,

Anusha VALLABHANENI.

Hi,


Thanks for providing some details and template file.

Well, you have defined the Style but never applied it to the cells. We recommend you to kindly see the following documents for your complete reference on how to apply borders or formatting to a cell, range of cells or row/column etc. Please refer to the documents and then implement your own logic and code to apply formatting to your desired cells/area accordingly:

(Note: see the description and example code under sub-heading “Format Ranges…Adding Borders to a Named Range” in the document)


Hope, this helps a bit.

Thank you.