We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How to Set style for multiple rows of same column in Excel

In my code i getting Cell No of excel for eg :D2:D4 at one time then D6:D8 and so on in C# dynamically according to my logic.
I need to set a same style(SetStyle) for D2 to D4 same as D6 to D8… and so on same for other column.plz refer attach image Exceldoc.PNG (1.7 KB)

how can i do that .



Thanks for using Aspose APIs.

Please use Range.SetStyle() for your needs. Please see the following sample code.

It gets the style from cell A1 and applies it to range of your choice.

Please also check the output Excel file generated by the code as well as the screenshot showing the effect of the code on source Excel file.

Download Links:
source and output excel files.zip (11.9 KB)
sc.png (48.6 KB)


Workbook wb = new Workbook("sample.xlsx");

Worksheet ws = wb.Worksheets[0];

//Get the style from cell A1 and apply it to range of your choice
Cell cell = ws.Cells["A1"];
Style st = cell.GetStyle();

Range rng = ws.Cells.CreateRange("G2:H4");