This is a migrated thread and some comments may be shown as answers.

Excel file open in Rad File Explorer

5 Answers 235 Views
FileExplorer
This is a migrated thread and some comments may be shown as answers.
pavan
Top achievements
Rank 1
pavan asked on 17 Nov 2015, 05:00 PM
how to open the excel file in a popup window as pdf gets opened in a popup window on click of file in rad file explorer folder.

5 Answers, 1 is accepted

Sort by
0
Vessy
Telerik team
answered on 18 Nov 2015, 09:05 AM
Hi Pavan,

The file-previwing functionality provided in FileExplorer is entirely handled by the browser itself and cannot be controlled by us. If the browser is able to open a specific file type (e.g. the machine has third party plug-in for reading such files like in a PDF scenario), FileExplorer also will be able to preview this file. By default the browsers does not support previewing of Microsoft Office file formats.

Regards,
Vessy
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
pavan
Top achievements
Rank 1
answered on 18 Nov 2015, 03:42 PM

Hi Vessy,

 

I was trying to implement Group Docs Viewer to solve the problem. But when I double click on the file in rad file explorer no information is showing up.

 

fileviewer.aspx    where groupdocs is being used

 

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="FileViewer.aspx.cs" Inherits="jquerytreeview.FileViewer" %>
<%@ Import Namespace="Groupdocs.Web.UI" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
    <%=Viewer.CreateScriptLoadBlock().LoadJquery(true).LoadJqueryUi(true).UseHttpHandlers()%>
    <style>
            /*body, html {
                height: 100%;
            }*/
            body {
                overflow:  hidden;
            }
    </style>
</head>
<body>
    <div id="viewer" style="width: 100%; height: 100%;text-align: center;"></div>
        <%= Viewer.ClientCode()
            .TargetElementSelector("#viewer")
            .Stream(System.IO.File.OpenRead(this.Filepath),this.Filename, this.FileType,this.DisplayFileName,true)           
            .UseHtmlBasedEngine(this.Mode)
            .UseInnerThumbnails(false).OpenThumbnails(false)
            .SupportPageRotation()
            .ShowFolderBrowser(false)
            .ShowViewerStyleControl(false)
            .ZoomToFitHeight(true)
            .Quality(100)
            .BackgroundColor("#c60000")
            .SupportPageRotation(false) 
        %>
        <script type="text/javascript">
            function Check() {
                var new_width = $(window).width();
                $("#viewer").groupdocsViewer("setWidth", new_width);
                var threshold = 860;
                if (new_width < threshold) {
                    var new_zoom = new_width * 100 / threshold;
                    $("#viewer").groupdocsViewer("setZoom", new_zoom);
                } else {
                    $("#viewer").groupdocsViewer("setZoom", 100);
                }
            }
            $(document).ready(function () {
                $(document).bind('touchstart,touchmove', function (e) {
                    e.preventDefault();
                });
                var containerElement = $("#viewer");
                containerElement.groupdocsViewer("on", "documentLoadCompleted.groupdocs",
                function (e) {
                    Check();
                });
            });

            $(window).resize(function () {
                Check();
            });
        </script>
</body>
</html>

 

Fileviewer.aspx.cs

 

public partial class FileViewer : System.Web.UI.Page
    {
        public String Filepath;
        public String Filename;
        public String DisplayFileName;
        public String FileType;
        public Boolean Mode;

        protected void Page_Load(object sender, EventArgs e)
        {
            string filePath = Request.QueryString["filePath"];

    this.DisplayFileName = "FileName";
            this.Filename = "FileName";
            this.Mode = true;
            this.Filepath = filePath;
            this.FileType = "pdf";
        }

0
pavan
Top achievements
Rank 1
answered on 18 Nov 2015, 03:43 PM
can you provide me any sample example how to use third party document viewer with telerik rad file explorer ?
0
pavan
Top achievements
Rank 1
answered on 18 Nov 2015, 08:11 PM

Hi Vessy,

 

I was able to integrate group docs viewer with telerik rad file explore. But I am not able to open the images i.e .jpg file in document viewer. they are being opened in the telerik rad window. Any suggestions please.

 

function OnClientFileOpen(oExplorer, args) {
                var item = args.get_item();
                var fileExtension = item.get_extension();

                var fileDownloadMode = true;
                if ((fileDownloadMode == true) && (fileExtension == "docx" || fileExtension == ".jpg" || fileExtension == "pdf" || fileExtension == "xlsx" || fileExtension == "txt")) {
                    args.set_cancel(true);

                    var requestImage = "Handler.ashx?path=" + item.get_url();
                    document.location = requestImage;
                }
            }

 

code inside Handler.ashx

 

 

public void ProcessRequest(HttpContext context)
        {
            Context = context;
            string filePath = context.Request.QueryString["path"];
            filePath = context.Server.MapPath(filePath);

            if (filePath == null)
            {
                return;
            }

            System.IO.StreamReader streamReader = new System.IO.StreamReader(filePath);
            System.IO.BinaryReader br = new System.IO.BinaryReader(streamReader.BaseStream);

            byte[] bytes = new byte[streamReader.BaseStream.Length];

            br.Read(bytes, 0, (int)streamReader.BaseStream.Length);

            if (bytes == null)
            {
                return;
            }

            streamReader.Close();
            br.Close();
            string extension = System.IO.Path.GetExtension(filePath);
            string fileName = System.IO.Path.GetFileName(filePath);

            if (extension == ".jpg")
            { // Handle *.jpg and
                //WriteFile(bytes, fileName, "image/jpeg jpeg jpg jpe", context.Response);
                context.Response.Redirect(String.Format("FileViewer.aspx?filePath={0}", filePath));
            }
            else if (extension == ".gif")
            {// Handle *.gif
                WriteFile(bytes, fileName, "image/gif gif", context.Response);
            }
            else if (extension == ".docx")
            {
                // Handle *.pdf
                //WriteFile(bytes, fileName, "application/vnd.openxmlformats-officedocument.wordprocessingml.document", context.Response);

                context.Response.Redirect(String.Format("FileViewer.aspx?filePath={0}", filePath));
            }
            else if (extension == ".pdf")
            {
                context.Response.Redirect(String.Format("FileViewer.aspx?filePath={0}", filePath));
            }
            else if (extension == ".xlsx")
            {
                context.Response.Redirect(String.Format("FileViewer.aspx?filePath={0}", filePath));
            }
            else if (extension == ".txt")
            {
                context.Response.Redirect(String.Format("FileViewer.aspx?filePath={0}", filePath));
            }
        }

0
Vessy
Telerik team
answered on 20 Nov 2015, 02:59 PM
Hi Pavan,

Configuring third party tools is out of the scopes of our support services, and I am afraid that I cannot provide you any assistance on this matter. My advise is to contact the support of the found by you document viewer and address your further questions about this tool to them, as they are much more acquainted with their product.

Regards,
Vessy
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
FileExplorer
Asked by
pavan
Top achievements
Rank 1
Answers by
Vessy
Telerik team
pavan
Top achievements
Rank 1
Share this question
or