We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Set workbook cell gradient color using Aspose.Cells for .NET in C#


I am using Aspose.cells. i try to apply a two color gradient fill to some cells in my worksheet.
This is my code :

Workbook wbd= new Workbook(FileFormatType.Xlsx);
Cell cella4= wbd.Worksheets[0].Cells[“A4”];
Cell cella5 = wbd.Worksheets[0].Cells[“A5”];
Cell cella6 = wbd.Worksheets[0].Cells[“A6”];
Style a4 = new Style();
Style a5 = new Style();
Style a6 = new Style();
a4.SetTwoColorGradient(System.Drawing.Color.Indigo, System.Drawing.Color.White, Aspose.Cells.Drawing.GradientStyleType.Horizontal, 1);
a5.SetTwoColorGradient(System.Drawing.Color.Black, System.Drawing.Color.White, Aspose.Cells.Drawing.GradientStyleType.Horizontal, 1);
a6.SetTwoColorGradient(System.Drawing.Color.Yellow, System.Drawing.Color.BlueViolet, Aspose.Cells.Drawing.GradientStyleType.Horizontal, 1);

When i see the destination file the cells a4,a5,a6 are filled with same color of style a4. style a5 & a6 are not applied to cells a5 & a6. Please Help.

Abdul R Sha

Hi Abdul,

After an initial test using your sample code, I can find the issue as you have mentioned. I have logged the issue with an id: CELLSNET-30020. We will figure your issue out soon.

Thank you.


We have fixed this issue. Please download:
Aspose.Cells for .NET (Latest Version)

The issues you have found earlier (filed as CELLSNET-30020) have been fixed in this update.

This message was posted using Notification2Forum from Downloads module by Aspose Notifier.


Thanks for resolving the issue. We are in plan to acquire license for Aspose.cells but before that we have some issues which we are stuck up with , the issues are listed below :

1) when we convert a Excel sheet into image (Tiff format) , The conditional formats are not copied. For example the particular cell has conditional format - icon sets of up, side, down arrows as conditional formats. when we try to convert to image its values are only copied and not conditional format images.

2)A particular cell contains 7 different conditional formats with gradient colors.when i try to copy this sheet to another workbook . After copying the entire sheet, the cell has only two different gradient colors repeating for all the 7 different conditions.

3)Currently we can paste an image into a cell referring to a particular cell location for ex : (0,0) or (5,4). can we paste the image to a location starting from the middle of fifth column(4.5) because the location of cell is in integer so we are unable to give decimal values to its positions.

4) In future if u have Updated the dll. do we need to replace the entire dll or will u provide update patches as an alternative ?

These are the main issues and clarifications we need to know at this point of time. If u need more inputs on this issue probably i can provide u with the sample code and sample excel file with which i found this issue. once again thanks for resolving the previous issue.

Thanks ,

Abdul R Sha.


1) Give us your template Excel file and output image with sample code here, we will check the issue soon.
2) Give us your Sample Files (input + output etc.) and sample code to reproduce the issue. We will check it soon.
3) Well, you may make use of Picture’s attributes e.g UpperLeftColumn, UpperLeftRow, LowerRightColumn, LowerRightRow, UpperDeltaX/Y etc. The DeltaX is in unit of 1/1024 of the width of the column. DeltaY is in unit of 1/256 of the height of the row. The LowerRightRow is used to set the lower row index; the LowerDeltaY attribute is used to set vertical offset from its lower row etc.
4) Well, for future fixes/enhancements, you only need to replace the Aspose.Cells.dll library in your project.

Thank you.

Hi Amjad,

1) This is the sample code for Converting sheet to images. . But the conditonal formats are not converted to images. Have Attached the sample File Template1.xlsx and output image file sheetimage1.tiff in zip format

Aspose.Cells.Workbook book = new Aspose.Cells.Workbook("C:\\Template1.xlsx");

//Workbook book = new Workbook("C:\\Testbook.xls");

//Get the first worksheet.

//Worksheet sheet = book.Worksheets[0];

Aspose.Cells.Worksheet sheet;

Aspose.Cells.Rendering.ImageOrPrintOptions imgOptions;

Aspose.Cells.Rendering.SheetRender sr;

for (int i = 0; i < book.Worksheets.Count; i++)


sheet = book.Worksheets[0];// Considering the first sheet to convert to images

imgOptions = new Aspose.Cells.Rendering.ImageOrPrintOptions();

//Specify the image format

if (i != 0)


imgOptions.HorizontalResolution = 150;

imgOptions.VerticalResolution = 150;


imgOptions.OnePagePerSheet = true;

imgOptions.IsImageFitToPage = false;

imgOptions.ImageFormat = System.Drawing.Imaging.ImageFormat.Tiff;

sr = new Aspose.Cells.Rendering.SheetRender(sheet, imgOptions);

sr.ToImage(0, "C:\\sheetimage" + i + ".tiff");


2) This is the sample code for second issue. .

Workbook wbd = new Workbook("C:\\Template2.xlsx");

Workbook wbd1 = new Workbook(FileFormatType.Xlsx);




In the output excel even though i change the value in cell I3 the correct colors are not reflected.

I have attached input excel : Template2.xlsx & outputExcel : Template2dest.xlsx .

3) Convert an Exel to pdf : Conditional formats are not copied properly in the PDF

This is the sample code that i used to convert excel to pdf

Workbook workbook = new Workbook("C:\\Template1.xlsx");

PdfSaveOptions pdfSaveOptions = new PdfSaveOptions(SaveFormat.Pdf);

pdfSaveOptions.OnePagePerSheet = true;


I have attaced the Input Excel :Template1.xlsx & output PDF : Template1toPDF.pdf . .

These are the issues that we face as of now. Kindly help in solving the issues. .

Thanks & Regards,

Abdul R Sha


Thanks for providing us the template files and sample code segments.

I have found all your three mentioned issues using your sample code segments and template files.

I have logged a ticket for the issues with an id: CELLSNET-30449. We will look into it soon.

Thank you.

Hi Amjad,

We have got the license for aspose.cells . Earlier we had some issues in gradient color rendering,Converting excel to pdf and the same has been logged as ticket ID No: CELLSNET-30449. Without fixing this issue we cannot move further in our project. This ticket is still in the unresolved status. Appreciate your help in this.


Abdul R Sha.


We have logged your comment/request. Hopefully it will be fixed soon. We will update you asap.

Hi Shakeel,

Still the issue’s that i mentioned were not Fixed.Its been so long that the issue is still in Unresolved status. We need the issue fixed asap so that it does not affect our project timelines. Appreciate your help in this regard.

Abdul R Sha


Will you please try the latest version:
Aspose.Cells for .NET (Latest Version)
and let me know your feedback.

Hi Shakeel,

Have used the latest version as shared by you. But still the issue is not solved. Its the same even after using the latest version. The issue is not solved.

Abdul R Sha.


Thanks for your feedback. I have increased the priority of this task. Hopefully it will be fixed soon.


We have fixed this issue. Please download: Aspose.Cells for .NET (Latest Version)


Please try the attached latest fixed version v7.0.2.2, we have enhanced further regarding conditional formatting / formatting issues when rendering.

Thank you.

Hi ,

The second issue is not resolved.
When i copy the sheet from one excel to another , and i try changing value in cell I3. The correct colors are not reflected in the destination sheet. To give more insight about this issue i have attached two snapshot of gradient color in source and destination sheets.

By comparing the two snapshot we can infer that the conditional formats are not properly set in the destination sheet while copying sheet from source. Appreciate your help in this regard.

Abdul R Sha.


Thanks for providing us the screen shots.

Yes, I can find the issue as you have mentioned by copying the worksheet (in the Template2.xlsx file) to other workbook. I have reopened the issue and we will fix it soon.

Thank you.


Please try the latest version/fix Latest Version. We have fixed the issue regarding conditional formattings.

Thank you.

The issues you have found earlier have been fixed in this update.