# GrapeCity.Documents.Excel.ColorUtilities.StringToColor

## Content

<div class="doc-site-dotnet-api-container">



<h1 id="GrapeCity_Documents_Excel_ColorUtilities_StringToColor_" data-uid="GrapeCity.Documents.Excel.ColorUtilities.StringToColor*">StringToColor Method
</h1>
<div class="markdown level0 summary"></div>
<div class="markdown level0 conceptual"></div>



<a id="GrapeCity_Documents_Excel_ColorUtilities_StringToColor_" data-uid="GrapeCity.Documents.Excel.ColorUtilities.StringToColor*"></a>
<h4 id="GrapeCity_Documents_Excel_ColorUtilities_StringToColor_System_String_" data-uid="GrapeCity.Documents.Excel.ColorUtilities.StringToColor(System.String)">StringToColor(string)</h4>
<div class="markdown level1 summary"><p>Converts a color string to a <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.drawing.color">color structure</a>.<br>
The supported color string formats include:</p>
<ul><li><b>RGB format</b>: "rgb(r,g,b)", e.g., "rgb(255,0,0)" for red.</li><li><b>RGBA format</b>: "rgba(r,g,b,a)", e.g., "rgba(255,0,0,0.5)" for red with 50% opacity.</li><li><b>Hexadecimal</b>: "#RGB" or "#RRGGBB", e.g., "#F00" or "#FF0000" for red.</li><li><b>Hexadecimal with alpha</b>: "#RGBA" or "#RRGGBBAA", e.g., "#F00C" or "#FF0000CC" for red with 90% opacity.</li><li><b>Color name</b>: A predefined color name, e.g., "red".</li></ul>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public static Color StringToColor(string colorString)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Shared Function StringToColor(colorString As String) As Color</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></td>
      <td><span class="parametername">colorString</span></td>
      <td><p>The color string to be converted.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.drawing.color">Color</a></td>
      <td><p>The <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.drawing.color">color structure</a> representing the color.</p>
</td>
    </tr>
  </tbody>
</table>
</div>
