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

Light Green does not work when exporting to excel with XlsIO

Light green does not work. It exports as grey.

range.CellStyle.Color = Color.LightGreen;
//Where range is an IRange for any sheet

This will not result in the background color to the range being Light Green.

Has anyone found a solution or work around for this? I have very picky users and unfortunately have to use LightGreen.

Thank you.

4 Replies

JT Joseph Takahata June 9, 2010 02:41 PM UTC

No one has heard of this?

Here is a section of code you can use to get the same results:

using Syncfusion.XlsIO;
//...
public void WriteToExcel()
{
//Instantiate the spreadsheet creation engine.
ExcelEngine excelEngine = new ExcelEngine();
//Instantiate the excel application object.
IApplication application = excelEngine.Excel;
//A new workbook is created.[Equivalent to creating a new workbook in MS Excel]
//The creation of a new workbook in the excel file
IWorkbook workbook = application.Workbooks.Create(1);
//The first worksheet object in the worksheets collection is accessed.
IWorksheet sheet = workbook.Worksheets[0];

//Select a range and would expect to make the back color LightGreen
IRange range = sheet["A1:A6"];
range.CellStyle.Color = Color.LightGreen;

//Saving the workbook to disk.
workbook.SaveAs(@"C:\test.xls");
//Close the workbook.
workbook.Close();
//No exception will be thrown if there are unsaved workbooks.
excelEngine.ThrowNotSavedOnDestroy = false;
excelEngine.Dispose();
}

This will create the attached file. Which you'll notice does not have light green as the fill color for A1 to A6.



test_79e1ad09.zip


LR Lokesh R Syncfusion Team June 10, 2010 05:04 AM UTC

Hi Joseph,

Thank you very much for your interest on Syncfusion products.

We are very sorry for the delay caused in getting back to you.For your information Excel could not able to detect the System color to the Excel color, So setting the color property will give you in irrelevant output. We recommend you to use the ColorIndex property instead of Color ,the ColorIndex Property accepts the ExcelKnownColors value. Could you please do the below modifications in your code snippet and let us know if this helps you.

[C#] Code Snippet:
IRange range = sheet["A1:A6"];
range.CellStyle.ColorIndex = ExcelKnownColors.Light_green;

Please, let us know if you need any clarifications.

Thanks,
Lokesh.


WL Willis Logwood June 11, 2010 07:52 PM UTC

Does this mean you can't do your own custom colors?


LR Lokesh R Syncfusion Team June 15, 2010 11:22 AM UTC

Hi Joseph,

Yes, it is possible to define our own custom colors, we have an another property FillBackgroundRGB which accepts the System.Drawing.Color values ,but we strongly recommend you to use the ColorIndex property and for more information regarding the color and fill settings please navigate to the below online documentation link.

Online link:
http://help.syncfusion.com/ug_82/Reporting_XlsIO/PatternSettings.html

Please, let me know if you need any clarifications.

Thanks,
Lokesh.


Loader.
Live Chat Icon For mobile
Up arrow icon