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

Export to Excel - Folder Location as Hyperlink

6 Answers 146 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Rick
Top achievements
Rank 1
Rick asked on 10 Apr 2014, 05:11 PM
NUTSHELL
In an Export to Excel, I want a column that contains a network folder location to be a hyperlink to that location.

DETAIL
I have a grid of many columns, one of which is hidden and contains a network file location.  The field is displayed in when Export to Excel, but it is only a text field.  I would like this to be a hyperlink so the user could click it which would open the network location specified in that field.

SAMPLE FIELD DATA
\\c-fs\vol2\Proposal\2014\a9873 - NYC - GSF – Brockport, NY

EXISTING CODE
Protected Sub btnExport_Click(ByVal sender As Object, ByVal e As EventArgs)
 
    Me.RadGrid1.MasterTableView.GetColumn("Location").Display = True  'This field contains the network location
    Me.RadGrid1.MasterTableView.GetColumn("Proposal_NotIssued").Display = True
    Me.RadGrid1.MasterTableView.GetColumn("Proposal_NotIssuedReason").Display = True
    Me.RadGrid1.MasterTableView.GetColumn("Proposal_Qualification").Display = True
    Me.RadGrid1.MasterTableView.GetColumn("Proposal_EstimatedProjectArea").Display = True
    Me.RadGrid1.MasterTableView.GetColumn("Proposal_EstimatedConstructionCost").Display = True
    Me.RadGrid1.MasterTableView.GetColumn("Proposal_WinningProbabilityPct").Display = True
    Me.RadGrid1.MasterTableView.GetColumn("Proposal_DateGranted").Display = True
    Me.RadGrid1.MasterTableView.GetColumn("Proposal_ProjectID").Display = True
    Me.RadGrid1.MasterTableView.GetColumn("Proposal_Comments").Display = True
 
    For Each item As GridDataItem In Me.RadGrid1.Items
        If item.Selected = False Then
            item.Visible = False
        End If
    Next
    Me.RadGrid1.Rebind()
    Me.RadGrid1.ExportSettings.ExportOnlyData = True
    Me.RadGrid1.ExportSettings.OpenInNewWindow = True
    Me.RadGrid1.ExportSettings.FileName = "Selected Proposals " & Format(Now, "yyyy-MM-dd-h-mm-ss")
    'Me.RadGrid1.ExportSettings.IgnorePaging = True
    Me.RadGrid1.ExportSettings.UseItemStyles = True
    Me.RadGrid1.MasterTableView.ExportToExcel()
 
 
End Sub

I am programming in MS Visual Studio 2012.
I am using Telerik UI for ASP.NET AJAX, v.2014.1.225.45

6 Answers, 1 is accepted

Sort by
0
Accepted
Daniel
Telerik team
answered on 11 Apr 2014, 12:23 PM
Hello Rick,

Thanks for the exhaustive explanation. The easiest way to achieve that would be to use a template column as shown below:
<telerik:GridTemplateColumn>
    <ItemTemplate>
        <a href="\\network_location\folder\sub_folder">Click here to open the folder</a>
    </ItemTemplate>
</telerik:GridTemplateColumn>

Let me know whether this way is suitable for you.

Regards,
Daniel
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Accepted
Jeffrey
Top achievements
Rank 1
answered on 09 May 2014, 02:35 PM
Thank you.  I got tied up in other things and I'm just returning to this now.  I should have explained that the hyperlink I was looking for would be in Excel.  I'm not yet sure if your solution will do that, however, I would like to apply a solution where they can show the folder directly from the grid as well.


First things first:
I have added your markup to my grid, however I am not sure how to get the actual network location into the markup.  My datafield is called "Location".  How do I get that into the hrfey of the marup you sent.


Second:
I have a column with a command button that opens the folder, however, this does not work once published to a server.  My code:

<telerik:GridBoundColumn DataField="Location" Display="False" ColumnGroupName="DLB"  FilterControlAltText="Filter Location column" HeaderText="Location" ReadOnly="True" SortExpression="Location" UniqueName="Location" ItemStyle-Width="2px" AllowFiltering="False" HeaderStyle-Height="44px" HeaderStyle-HorizontalAlign="Left" HeaderStyle-VerticalAlign="Middle">
    <ColumnValidationSettings>
          
    </ColumnValidationSettings>
    <HeaderStyle HorizontalAlign="Left" VerticalAlign="Middle" Height="44px"></HeaderStyle>
 
    <ItemStyle Width="600px"></ItemStyle>
</telerik:GridBoundColumn>

The code behind...
Protected Sub RadGrid1_ItemCommand(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid1.ItemCommand
 
 
    Dim value As String
 
    If e.CommandName = "ShowFiles" Then
        Dim dataItm As GridDataItem = TryCast(e.Item, GridDataItem)
 
        value = dataItm("Location").Text & "\03 Submitted\"
 
 
        Process.Start("explorer.exe", value)
 
    End If
 
 
 
End Sub



0
Rick
Top achievements
Rank 1
answered on 09 May 2014, 04:03 PM
(Ignore Jeffrey-- I was logged onto a co-workers account)

Thank you.  I got tied up in other things and I'm just returning to this now.  I should have explained that the hyperlink I was looking for would be in Excel.  I'm not yet sure if your solution will do that, however, I would like to apply a solution where they can show the folder directly from the grid as well.


First things first:
I have added your markup to my grid, however I am not sure how to get the actual network location into the markup.  My datafield is called "Location".  How do I get that into the hrfey of the marup you sent.


Second:
I have a column with a command button that opens the folder, however, this does not work once published to a server.  My code:


<telerik:GridBoundColumn DataField="Location" Display="False" ColumnGroupName="DLB"  FilterControlAltText="Filter Location column" HeaderText="Location" ReadOnly="True" SortExpression="Location" UniqueName="Location" ItemStyle-Width="2px" AllowFiltering="False" HeaderStyle-Height="44px" HeaderStyle-HorizontalAlign="Left" HeaderStyle-VerticalAlign="Middle">
    <ColumnValidationSettings>
           
    </ColumnValidationSettings>
    <HeaderStyle HorizontalAlign="Left" VerticalAlign="Middle" Height="44px"></HeaderStyle>
  
    <ItemStyle Width="600px"></ItemStyle>
</telerik:GridBoundColumn>

The code behind:
Protected Sub RadGrid1_ItemCommand(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid1.ItemCommand
  
  
    Dim value As String
  
    If e.CommandName = "ShowFiles" Then
        Dim dataItm As GridDataItem = TryCast(e.Item, GridDataItem)
  
        value = dataItm("Location").Text & "\03 Submitted\"
  
  
        Process.Start("explorer.exe", value)
  
    End If
  
  
  
End Sub
0
Rick
Top achievements
Rank 1
answered on 09 May 2014, 06:26 PM
PS - I tried your code and I found that in Excel, it will open the folder.  Once I can get the actual location into the link, that will be great.

As for opening the network location from the browser, I still would like to find a location for that.
0
Rick
Top achievements
Rank 1
answered on 09 May 2014, 06:32 PM
Okay, this is what I did and it works, so thanks!

<telerik:GridTemplateColumn>
    <ItemTemplate>
        <a href="<%# Eval("Location")%>">Click here to open the folder</a>
    </ItemTemplate>
</telerik:GridTemplateColumn>
0
Daniel
Telerik team
answered on 10 May 2014, 06:45 AM
Hello Rick,

I'm glad to hear that you have managed to find the proper solution. You can also use the file URI scheme for that purpose. Example shown below:
file:///c|/WINDOWS/Temp

Regards,
Daniel
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
Rick
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Jeffrey
Top achievements
Rank 1
Rick
Top achievements
Rank 1
Share this question
or