I currently implemented Excel Export behind code, I'm trying to have it be implemented in the ViewModel Instead. How abouts would I do that?
private void MenuItem_OnClick(object sender, RoutedEventArgs e)
{
try
{
string content;
var extension = "xml";
content = DrillThroughGridView.ToExcelML(true);
string path = String.Format("Export.{0}", extension);
if (File.Exists(path))
{
File.Delete(path);
}
using (FileStream fs = File.Create(path))
{
Byte[] info = Encoding.Default.GetBytes(content);
fs.Write(info, 0, info.Length);
}
Process.Start(path);
}
catch (Exception)
{
Notification.Error("Process Busy", "Please exit excel instance.");
}
}