I have a cshtml view in mvc filled with xml such as :\[code\]@model myproject.net.Models.mymodel@{ Layout = null; Response.ContentType = "application/vnd.ms-excel"; Response.AddHeader("Content-Disposition", "attachment; " + "filename=" + Model.myusername.ToString() + "(" + Model.mydate.Date.ToShortDateString() + ").xls");}<?xml version="1.0" encoding="utf-8"?><ss:Workbook xmlns:ss="urn:schemas-microsoft-comffice:spreadsheet"> <Styles> <Style ss:ID="s25"> <Alignment ss:Horizontal="Center" ss:Vertical="Bottom"/> <Borders> <Border ssosition="Bottom" ss:LineStyle="Continuous" ss:Weight="1"/> </Borders> <Interior ss:Color="#FFA500" ssattern="Solid"/> </Style> </Styles> <ss:Worksheet ss:Name="Sheet1"> <ss:Table> @if (Model.someNumerableContent.Count > 0) { <!-- MyContent --> <ss:Row> <ss:Cell><ssata ss:Type="String">Content Header</ssata></ss:Cell> </ss:Row> <ss:Row> <ss:Cell><ssata ss:Type="String">SubHeader 1</ssata></ss:Cell> <ss:Cell><ssata ss:Type="String">SubHeader 2</ssata></ss:Cell> <ss:Cell><ssata ss:Type="String">SubHeader 3</ssata></ss:Cell> <ss:Cell><ssata ss:Type="String">SubHeader 4</ssata></ss:Cell> <ss:Cell><ssata ss:Type="String">SubHeader 5</ssata></ss:Cell> </ss:Row> foreach (var subContent in Model.someNumerableContent) { <ss:Row> <ss:Cell><ssata ss:Type="String">@subContent.mydate.Date.ToShortDateString()</ssata></ss:Cell> <ss:Cell><ssata ss:Type="String">@subContent.number</ssata></ss:Cell> <ss:Cell><ssata ss:Type="String">@subContent.name</ssata></ss:Cell> <ss:Cell><ssata ss:Type="String">@subContent.surname</ssata></ss:Cell> <ss:Cell><ssata ss:Type="String">@subContent.issue</ssata></ss:Cell> </ss:Row> } <ss:Row> </ss:Row> } </ss:Table> </ss:Worksheet></ss:Workbook>\[/code\]and i wanna convert it to .xls file and attach to a mail without saving it anywhere.but couldnt figure out how can i achive this. I cant use office.interop for some restrictions i got in the server so its not an option to me. I only want to create an .xls file by xml view and send it by mail.\[code\]// Memory stream for the xml fileusing (MemoryStream memoryStream = new MemoryStream()){ // Can i use something like this? byte[] contentAsBytes = Encoding.Default.GetBytes( View("ExportToExcel").ToString() ); memoryStream.Write(contentAsBytes, 0, contentAsBytes.Length); // Set the position to the beginning of the stream. memoryStream.Seek(0, SeekOrigin.Begin); // Create attachment ContentType contentType = new ContentType(); contentType.MediaType = MediaTypeNames.Text.Xml; contentType.Name = UserName + "(" + FileDate + ").xls"; // Attach mail.Attachment = new Attachment(memoryStream, contentType);}\[/code\]so how can i achive this?