Если вы можете получить mht, вы можете извлечь его содержимое с помощью MIMER .
Здесь есть пакет nu-get (MIMER потребует .NET Framework 3.5):
https://www.nuget.org/packages/MIMER/
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using MIMER;
namespace MimerTest
{
// https://github.com/smithimage/MIMER/blob/master/MIMERTests/MHT/MhtTests.cs
// https://github.com/smithimage/MIMER/
static class Program
{
/// <summary>
/// Der Haupteinstiegspunkt für die Anwendung.
/// </summary>
[STAThread]
static void Main()
{
if (false)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
System.IO.Stream m_Stream;
string path = @"d:\USERNAME\documents\visual studio 2013\Projects\MimerTest\MimerTest\whatismht.mht";
System.IO.FileInfo finf = new System.IO.FileInfo(path);
m_Stream = new System.IO.FileStream(path, System.IO.FileMode.Open, System.IO.FileAccess.Read);
var reader = new MIMER.RFC2045.MailReader();
MIMER.IEndCriteriaStrategy endofmessage = new MIMER.RFC2045.BasicEndOfMessageStrategy();
var message = reader.ReadMimeMessage(ref m_Stream, endofmessage);
System.Collections.Generic.IDictionary<string,string> allContents = message.Body;
string strFile = allContents["text/html"];
foreach (System.Collections.Generic.KeyValuePair<string,string> kvp in allContents)
{
System.Console.WriteLine(kvp.Key);
System.Console.WriteLine(kvp.Value);
}
System.Console.WriteLine(" --- Press any key to continue --- ");
System.Console.ReadKey();
}
}
}
В ReportViewer 2005 года вы можете включить HTML с помощью отражения:
private static void EnableFormat(ReportViewer viewer, string formatName)
{
const BindingFlags Flags = BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance;
FieldInfo m_previewService = viewer.LocalReport.GetType().GetField
(
"m_previewService",
Flags
);
MethodInfo ListRenderingExtensions = m_previewService.FieldType.GetMethod
(
"ListRenderingExtensions",
Flags
);
object previewServiceInstance = m_previewService.GetValue(viewer.LocalReport);
IList extensions = ListRenderingExtensions.Invoke(previewServiceInstance, null) as IList;
PropertyInfo name = extensions[0].GetType().GetProperty("Name", Flags);
foreach (object extension in extensions)
{
if (string.Compare(name.GetValue(extension, null).ToString(), formatName, true) == 0)
{
FieldInfo m_isVisible = extension.GetType().GetField("m_isVisible", BindingFlags.NonPublic | BindingFlags.Instance);
FieldInfo m_isExposedExternally = extension.GetType().GetField("m_isExposedExternally", BindingFlags.NonPublic | BindingFlags.Instance);
m_isVisible.SetValue(extension, true);
m_isExposedExternally.SetValue(extension, true);
break;
}
}
}
Использование:
var Viewer = new Microsoft.Reporting.WebForms.ReportViewer();
EnableFormat(Viewer, "HTML4.0");
Вы также можете найти это интересным:
http://www.codeproject.com/Articles/23966/Report-Viewer-generate-reports-MS-Word-formats