如何为 Aspose Cells 中的单元格指定自定义颜色?

How can I assign a custom color to a cell in Aspose Cells?

在遗留(Excel Interop)代码中,可以这样做来为单元格分配自定义颜色:

contractCell.Interior.Color = ColorTranslator.ToOle(Color.FromArgb(202, 134, 250));

使用Aspose Cells,我试图找到相应的方法来做到这一点。此代码:

styleContractRow2.ForegroundColor = ColorTranslator.ToOle(Color.FromArgb(202, 134, 250));
styleContractRow2.Pattern = BackgroundType.Solid;

...不编译,告诉我,“无法将类型 'int' 隐式转换为 'System.Drawing.Color'

那么如何在 Aspose Cells 中分配自定义颜色?

好像不用翻译了;这编译:

styleContractRow2.ForegroundColor = Color.FromArgb(202, 134, 250);

请查看your Aspose.Cells forum thread中的回复和示例代码。

注意:我在 Aspose 担任开发人员布道师