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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Range Formating

Thread ID:





69051 Oct 11,2007 10:14 AM UTC Oct 23,2007 08:06 AM UTC WinForms 2
Tags: XlsIO
Asked On October 11, 2007 10:14 AM UTC

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

Rajarajeswari S [Syncfusion]
Replied On 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.


Replied On October 23, 2007 08:06 AM UTC

Thank you. This solution solved problem.


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon