Spire.XLS is a professional Excel API that enables developers to create, manage, manipulate, convert and print Excel worksheets. Get free and professional technical support for Spire.XLS for .NET, Java, Android, C++, Python.
Thu Dec 21, 2023 11:44 am
I would like to change the text color of a cell and get the following error messages:
sheet.Range["A10"].Style.Font.Color = Color.Red; //Error: CS0103: The name 'Color' does not exist in the current context
sheet.Range["A10"].Style.Font.Color = "FF0000"; //CS0029: Cannot implicitly convert type 'string' to 'System.Drawing.Color'
-
ProPotsdam
-
- Posts: 9
- Joined: Sun Nov 29, 2020 4:30 pm
Fri Dec 22, 2023 1:50 am
Hello,
Thank you for your inquiry.
Regarding your request, please note that the Color reference you mentioned is from the System.Drawing library. Here is the complete code snippet that you can use:
- Code: Select all
sheet.Range["A10"].Style.Font.Color = System.Drawing.Color.Red;
sheet.Range["A10"].Style.Font.Color = System.Drawing.Color.FromArgb(System.Convert.ToInt32("FF0000", 16));
Sincerely,
Annika
E-iceblue support team
-
Annika.Zhou
-
- Posts: 1657
- Joined: Wed Apr 07, 2021 2:50 am
Fri Dec 22, 2023 8:34 am
Arrgh!
Sorry to have wasted your time...
using the Libary via codebehind it runs smoothly:
using Spire.Xls;
using System.Drawing;
...
public string officeExcel01(string _datensatz)
{
...
sheet.Range["A10"].Style.Font.Color = Color.Red;
...
}
Thanks for the hint ...
-
ProPotsdam
-
- Posts: 9
- Joined: Sun Nov 29, 2020 4:30 pm
Fri Dec 22, 2023 8:49 am
Hello,
You're welcome.
If you encounter other issues related to our products in the future, please feel free to contact us.
Have a nice day.
Sincerely,
Annika
E-iceblue support team
-
Annika.Zhou
-
- Posts: 1657
- Joined: Wed Apr 07, 2021 2:50 am