Question : Silverlight: open excel in Browser

Hi,

On my Silverlight project I need to show an excel document, received from the server, in a new browser tab.

With ASP works like this:
 private void OpenReport(string name)
    {
        FileStream fs = File.OpenRead(name);

        Response.AppendHeader("Content-disposition", "inline; filename=" + name);
        Response.AppendHeader("Pragma", "no-cache");
        Response.Expires = -1;
        Response.ContentType = "application/vnd.ms-excel";
        Response.BinaryWrite(GetWholeFileContent(fs, (int)fs.Length));
        Response.Flush();
    }


    private byte[] GetWholeFileContent(FileStream f, int lenght)
    {
        byte[] stream = new byte[lenght+1];
        f.Read(stream, 0, lenght);
        return stream;
    }

How to implement it on a Silverlight project?

Answer : Silverlight: open excel in Browser

try with the following inside your silverlight code:

System.Windows.Browser.HtmlPage.Window.Navigate(new Uri(http://servername/test.xls), ),"_blank");
 
Random Solutions  
 
programming4us programming4us