# GrapeCity.Documents.Excel.IDataBar.FromJson

## Content

<div class="doc-site-dotnet-api-container">



<h1 id="GrapeCity_Documents_Excel_IDataBar_FromJson_" data-uid="GrapeCity.Documents.Excel.IDataBar.FromJson*">FromJson Method
</h1>
<div class="markdown level0 summary"></div>
<div class="markdown level0 conceptual"></div>



<a id="GrapeCity_Documents_Excel_IDataBar_FromJson_" data-uid="GrapeCity.Documents.Excel.IDataBar.FromJson*"></a>
<h4 id="GrapeCity_Documents_Excel_IDataBar_FromJson_System_String_" data-uid="GrapeCity.Documents.Excel.IDataBar.FromJson(System.String)">FromJson(string)</h4>
<div class="markdown level1 summary"><p>Loads the data bar conditional format from a JSON string.</p>
<p>
This method replaces the current data bar rule with the rule defined in
the specified JSON string. The JSON content is typically generated by
<a class="xref" href="GrapeCity.Documents.Excel.IDataBar.ToJson.html#GrapeCity_Documents_Excel_IDataBar_ToJson">ToJson()</a>.
</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">void FromJson(string json)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Sub FromJson(json As String)</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">json</span></td>
      <td><p>The JSON string that defines a data bar conditional format.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 id="GrapeCity_Documents_Excel_IDataBar_FromJson_System_String__examples">Examples</h5>
<pre><code class="lang-csharp">worksheet.Range["A1:A3"].Value = new object[,] {{10}, {30}, {20}};
IDataBar dataBar = worksheet.Range["A1:A3"].FormatConditions.AddDatabar();
dataBar.BarFillType = DataBarFillType.Solid;
dataBar.BarColor.Color = Color.Green;
dataBar.ShowValue = false;
string json = dataBar.ToJson();
IDataBar copiedDataBar = worksheet.Range["B1:B3"].FormatConditions.AddDatabar();
copiedDataBar.FromJson(json);</code></pre>

<h5 class="exceptions">Exceptions</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Condition</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.invalidoperationexception">InvalidOperationException</a></td>
      <td><p>if the specified JSON string does not describe a data bar conditional format.</p>
</td>
    </tr>
  </tbody>
</table>
</div>
