title: Is there a way to convert Scala-Spark DataFrame to HTML table, or converting DataFrame to Scala map then convert to Json and then HTML?
body: <p>I run some test and get result which is small DataFrame, with approx 3-6 columns and 10-20 row. And now I want to send this email to my colleague, and for ease I want this to be in tabular format as DataFrame rather then scala map of Json.</p>
  
  <p>So, I want to convert the DataFrame to HTML table which I can attach in email.(This will be done automatically after automated task run of DataBricks)</p>
  
  <p>Till now I have tried converting the DataFrame to Scala map then convert map to Json. but couldn't find anything to convert json to HTML in Scala.</p>
  
  <p>I am converting df to map with this code:</p>
  
  <pre><code>val DataFrameToArray = df.collect.map(r =&gt; Map(df.columns.zip(r.toSeq):_*))
  </code></pre>
  
  <p>Which gives result as array map below(Sorry forgot to mention that):</p>
  
  <pre><code>DataFrameToArray: Array[scala.collection.immutable.Map[String,Any]] = Array(map(Name -&gt; Ross, Age -&gt; 31, Gender -&gt; Male), map(Name -&gt; Monica, Age -&gt; 28, Gender -&gt; Female), map(Name -&gt; Joey, Age -&gt; 32, Gender -&gt; Male), map(Name -&gt; Rach, Age -&gt; 29, Gender -&gt; Female))
  </code></pre>
  
  <p>and now I am converting this to array with below code:</p>
  
  <pre><code>val newJson = compactRender(decompose(DataFrameToArray))
  </code></pre>
  
  <p>Which gives results as:</p>
  
  <pre><code>newJson: String = [{"Name":"Ross","Age":31,"Gender":"Male"},{"Name":"Monica","Age":28,"Gender":"Female"},{"Name":"Joey","Age":32,"Gender":"Male"},{"Name":"Rach","Age":29,"Gender":"Female"}]
  </code></pre>
  
  <p>so it is quite not possibe for me to add it with User case class, or if you can help here.</p>