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.
Unfortunately, activation email could not send to your email. Please try again.

Range Formating

Thread ID:

Created:

Updated:

Platform:

Replies:

69051 Oct 11,2007 06:14 AM Oct 23,2007 04:06 AM Windows Forms 2
loading
Tags: XlsIO
Alexander
Asked On October 11, 2007 06:14 AM

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 03:31 AM


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


Alexander
Replied On October 23, 2007 04:06 AM

Thank you. This solution solved problem.

CONFIRMATION

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.

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.

;