In LINQPad software, I would like to know if it is possible to save or export the Results in an Html file.
The result tab is
I would like to save the result and be able to send it by email.
I know I can do it by using some extarnal instructions like
string htmlResult = Util.Run ("test.linq", QueryResultFormat.Html).AsString();
or
lprun -format=html foo.linq > output.html
But I would like to be able to export the Results on demand, not always. I would like to bring a minimum of interactivity to my scripts. I would like to let the user of the script decide when to continue and when to send the script.
I just need an access to the body element of the Results. LINQpad made me crazy about this because I can generate the Html with Util.Run or lprun, I can also access the head of this Result by using Util.HtmlHead, I can clear the Result by using Util.ClearResults(), I can write everything I want in this Result page BUT impossible to retrieve it. I can export it manually by using the Export button on top right but I cannot do it by programmation.
I created a workaround by using the extensions with a new Util class
public static class Util2
{
// https://www.linqpad.net/CustomizingDump.aspx
// http://www.linqpad.net/lprun.aspx
// https://stackoverflow.com/questions/3555317/linqpad-extension-methods
private static StringBuilder htmlStringBuilder = new StringBuilder();
/// <summary>Writes to LINQPad result window and save the result in html file</summary>
public static object Save(this object o, bool writeFile = false, string fileName = null)
{
htmlStringBuilder.Append(Util.ToHtmlString(o));
return o;
}
public static string GetResults()
{
return htmlStringBuilder.ToString();
}
public static void ClearResults()
{
htmlStringBuilder.Clear();
}
}
I can use this by simply adding a .Save() after all my .Dump(). I cannot use the Console.Write() anymore and try to use Util.RawHtml() a maximum.