We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Range Formating

I'm coping Range from one XLS file to another. In original file I have white background, although Windows default background is grey(or some other...) so after code like this...

RangeOut.CopyTo(RangeIn, ExcelCopyRangeOptions.CopyStyles | ExcelCopyRangeOptions.UpdateMerges);

In destination file I have white background on all cells with data, and grey(default windows) background on all empty cells. That is not really good.

Is there any possibility to change background to whole worksheet, or preserve color after copying

2 Replies

RS Rajarajeswari S Syncfusion Team October 22, 2007 07:31 AM UTC


Hi Alexander,

Thanks for using Syncfusion products.

I regret for the long delay in response.

There is no particular property to set background color for the whole document but we can set the DefaultStyles to columns, using that we can apply background color for all the columns. Please refer the below code snippet which illustrates this.

IStyle columnsstyle = workbook.Styles.Add("ColumnStyle");
columnsstyle.Color = Color.Red;
for (int i = 1; i <= 256; i++)
{
//Set Styles
sheet.SetDefaultColumnStyle(i, columnsstyle);
}

Since the number of columns in Excel file is 256, the loop has to execute till 256 times.

Please let me know if this helps you.

Regards,
S.Rajarajeswari



AL Alexander October 23, 2007 08:06 AM UTC

Thank you. This solution solved problem.

Loader.
Live Chat Icon For mobile
Up arrow icon