MS excel as Radgrid datasource

5 posts, 0 answers
  1. Ruby
    Ruby avatar
    9 posts
    Member since:
    Sep 2012

    Posted 01 Oct 2012 Link to this post

    I am using RadGrid with excel spreadsheet as the datasource, the data is displaying correctly in my grid.
    But, while Adding new record/inserting data to excel spreadheet. I am not sure how to do that.
    I have seen few examples but they are all showing exporting data to excel. But my requirement is just to add data to speadsheet from RadGrid

    I am pulling data from the spreadsheet using the following code
       

     

    Protected Sub uxRGMembersCleanup_NeedDataSource(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles uxRGMembersCleanup.NeedDataSource
          Dim cnstr As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Server.MapPath("~/App_Data/Test_Members.xlsx") & ";" & "Extended Properties=Excel 12.0"
          Dim oledbConn As New OleDbConnection(cnstr)
          Dim strSQL As String = "SELECT * FROM [Test_Members$]"
          Dim cmd As New OleDbCommand(strSQL, oledbConn)
          Dim ds As New DataSet()
          Dim da As New OleDbDataAdapter(cmd)
          da.Fill(ds)
          uxRGMembersCleanup.DataSource = ds
          'uxRGMembersCleanup.DataBind()
      End Sub

     

     

  2. Ruby
    Ruby avatar
    9 posts
    Member since:
    Sep 2012

    Posted 01 Oct 2012 Link to this post

    My aspx code :
    <telerik:RadGrid ID="uxRGMembersCleanup" runat="server" GridLines="Both" AllowAutomaticInserts="true" 
                       AllowSorting="True" AllowPaging="True" PageSize="10"  Width="50%" DataSourceID="SessionDataSource1"
    >
      
                            <HeaderContextMenu EnableTheming="True">
                            <CollapseAnimation Duration="200" Type="OutQuint" />
                        </HeaderContextMenu>  
                          <MasterTableView AutoGenerateColumns="False"  EditMode="InPlace" CommandItemDisplay="Top" DataKeyNames="MEMBER" DataSourceID="SessionDataSource1"
    >
      
                               <RowIndicatorColumn>
                                <HeaderStyle Width="30px" />
                            </RowIndicatorColumn>
                            <ExpandCollapseColumn>
                                <HeaderStyle Width="20px" />
                            </ExpandCollapseColumn>
                              <Columns>    
                                <telerik:GridBoundColumn DataField="Member" HeaderText="MEMBER" SortExpression="MEMBER"
                                                         UniqueName="MEMBER">
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="Name" HeaderText="NAME" SortExpression="NAME"
                                                         UniqueName="NAME">
                                </telerik:GridBoundColumn>
                   
                            </Columns>
                        </MasterTableView>
                        <FilterMenu EnableTheming="True">
                            <CollapseAnimation Duration="200" Type="OutQuint" />
                        </FilterMenu>
                    </telerik:RadGrid>
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Daniel
    Admin
    Daniel avatar
    4946 posts

    Posted 05 Oct 2012 Link to this post

    Hello Ruby,

    You can find some examples here:
    Read and Write data in Excel 2003 and Excel 2007 using Oledb
    How to update data in Excel file using OLEDB
    How to insert data to Excel file using OLEDB

    Let me know if you need more information.

    Best regards,
    Daniel
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  5. Otto Neff
    Otto Neff avatar
    36 posts
    Member since:
    Jul 2011

    Posted 21 Jun 2013 Link to this post

    Hi there,
    I did a new version of Sample using Telerik RadGrid with Excel as DataSource:

    http://webapps-in-action.com/post/Excel-(xlsxlsx)-as-DataSource-for-Telerik-RadGrid-or-any-other-ASPNET-Control

    Cheers Otto.
  6. Daniel
    Admin
    Daniel avatar
    4946 posts

    Posted 25 Jun 2013 Link to this post

    Hello Otto,

    Thank you for sharing your code with our community. If you want to make it easily accessible and easy to find I would recommend that you submit it as a code-library project here.
    Telerik Code Library

    Regards,
    Daniel
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017