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.

How to set theme color

Thread ID:

Created:

Updated:

Platform:

Replies:

126147 Sep 27,2016 05:30 AM Oct 3,2016 06:43 AM UWP 7
loading
Tags: XlsIO
Sharad Kumar
Asked On September 27, 2016 05:30 AM

Hi,

How to set theme color and tint color on cell .

If theme color index is 8 and tint color value is 0.00003564789.

IRange  oRange;
IWorkBook oworkbook;

oRange.CellStyle.Interior.Gradient.ForeColorObject.SetTheme(8,0.00003564789, oworkbook);

This function is through Exception.

Thanks
Sharad Kumar



Abirami Varadharajan [Syncfusion]
Replied On September 28, 2016 10:12 AM

Hi Sharad, 
  
Thank you for contacting Syncfusion support. 
  
We recommend to set the FillPattern to Gradient before setting theme color to each cell of a range. Kindly refer below code snippet to achieve this. 
  
Code Example: 
            IRange oRange=worksheet.Range["A1:A10"]; 
            Range.CellStyle.Interior.FillPattern = ExcelPattern.Gradient; 
            for (int i = 0; i < oRange.Cells.Length;i++) 
            { 
                oRange.Cells[i].CellStyle.Interior.Gradient.ForeColorObject.SetTheme(8, workbook, 0.00003564789); 
            } 
 Kindly try and let us know if this helps.  
  
Regards, 
Abirami. 


Sharad Kumar
Replied On September 28, 2016 11:39 PM

thanks for replay.

If pattern type is solid .
Range.CellStyle.Interior.FillPattern = ExcelPattern.Solid;

this function through Exception.

I have attach excel file. cell B7,B8,B9,B10 have theme color and tint color.

Cell B7 value is ->
<fi   <       fill>
    -<patternFill patternType="solid">
        <fgColor theme="9" tint="0.39997558519241921"/>
        <bgColor indexed="64"/>
    </patternFill>
</fill>
Kindly provide a code snippet which recover color cell value.


Thanks
Sharad kumar


Attachment: 10colorcelltest_bbec8a0c.rar

Sharad Kumar
Replied On September 28, 2016 11:45 PM

thanks for replay.

If pattern type is solid .
Range.CellStyle.Interior.FillPattern = ExcelPattern.Solid;

this function through Exception.

I have attach excel file. cell B7,B8,B9,B10 have theme color and tint color.

Cell B7 value is ->
        patternType="solid"
        fgColor theme="9" tint="0.39997558519241921"                     //  foreground color
        bgColor indexed="64"                                                          //  background color
Cell B8 value is ->
       patternType="solid"
       fgColor theme="7" tint="0..59999389629810485"
       bgColor indexed="64"

Kindly provide code snippet which recover cell color value.

Thanks
Sharad Kumar

Attachment: 10colorcelltest_74759db6.rar

Abirami Varadharajan [Syncfusion]
Replied On September 30, 2016 08:33 AM

Hi Sharad, 
  
When you try to access the forecolorobject of gradient which has solid Fill pattern will throw an exception. 
  
So, we recommend you to set the theme and tint color of the cell by accessing the Wrapped property of the InteriorWrapper class. Kindly refer the below code example to set the theme and tint color to range B7, B8, B9 and B10. 
  
Code Example: 
worksheet.Range["B7"].CellStyle.Interior.FillPattern = ExcelPattern.Solid; 
(worksheet.Range["B7"].CellStyle.Interior as InteriorWrapper).Wrapped.ColorObject.SetTheme(9, workbook, 0.39997558519241921); 
worksheet.Range["B8"].CellStyle.Interior.FillPattern = ExcelPattern.Solid; 
(worksheet.Range["B8"].CellStyle.Interior as InteriorWrapper).Wrapped.ColorObject.SetTheme(7, workbook, 0.59999389629810485); 
worksheet.Range["B9"].CellStyle.Interior.FillPattern = ExcelPattern.Solid; 
(worksheet.Range["B9"].CellStyle.Interior as InteriorWrapper).Wrapped.ColorObject.SetTheme(0, workbook, -0.14999847407452621); 
worksheet.Range["B10"].CellStyle.Interior.FillPattern = ExcelPattern.Solid; 
(worksheet.Range["B10"].CellStyle.Interior as InteriorWrapper).Wrapped.ColorObject.SetTheme(8, workbook, 0.59999389629810485); 
  
Kindly try this approach and let us know if this help at your end. 
  
Regards, 
Abirami. 


Sharad Kumar
Replied On October 1, 2016 12:51 AM

Thanks for reply.

I am not access to InteriorWrapper class .

       error ->   The type or namespace name "
InteriorWrapper" could not found .


Thanks
sharad kumar




Abirami Varadharajan [Syncfusion]
Replied On October 3, 2016 06:16 AM

Hi Sharad, 
 
We request you to include below namespace to your sample to access InteriorWrapper class. 
 
Code Example: 
using Syncfusion.XlsIO.Implementation; 
 
Kindly try and let us know if this resolves error at your end. 
 
Regards, 
Abirami. 


Sharad Kumar
Replied On October 3, 2016 06:43 AM



Thanks Abirami.



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.

;