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

Free Support Forum - aspose.com

Copy style from one worksheet to another

Hi Team,

I have a requirment where i have to copy style of one sheet to another. I tried below but is not working out.

Style sty = worksheet.Cells[0,0].GetStyle();

StyleFlag flag = new StyleFlag();

flag.All = true;


I am unable to do it cell wise, row wise and column wise. Please help me out as soon as possible. This request is super urgent. Please pass on the method to do this as soon as possible.


Hi Niveditha,

Thanks for your posting and using Aspose.Cells.

I have tested this issue with the latest version: Aspose.Cells for .NET (Latest Version) and found ApplyStyle() is working fine for a range of cells, rows, columns and all cells.

Please note, ApplyStyle() does not exist for a single cell, you can however create a range of single of cell and apply style to it.

Please see the following code. It copies style of cell B2 inside worksheet and then apply style to range of cells, row and column and entire worksheet on second and third worksheet. I have attached the source, output xlsx files and screenshot for your reference.


Workbook workbook = new Workbook(“source.xlsx”);

Worksheet worksheet = workbook.Worksheets[0];

Worksheet worksheet1 = workbook.Worksheets[1];

Worksheet worksheet2 = workbook.Worksheets[2];

Style sty = worksheet.Cells[“B2”].GetStyle();

StyleFlag flag = new StyleFlag();

flag.All = true;

//Apply style on range of cells

Range range1 = worksheet1.Cells.CreateRange(“D5:H5”);

range1.ApplyStyle(sty, flag);

Range range2 = worksheet1.Cells.CreateRange(“F7”);

range2.ApplyStyle(sty, flag);

//Apply style on second column and row of the worksheet1

worksheet1.Cells.Columns[1].ApplyStyle(sty, flag);

worksheet1.Cells.Rows[1].ApplyStyle(sty, flag);

//Apply style on all cells of the worksheet2

worksheet2.Cells.ApplyStyle(sty, flag);