Rad Grid Export to Excel issue

7 posts, 0 answers
  1. Kamardy
    Kamardy avatar
    2 posts
    Member since:
    Mar 2013

    Posted 13 Jun 2013 Link to this post

    Hi all, I want to ask about the report to excel. I want to create a report in excel using telerik following functions as telerik. using "gridlist.MasterTableView.ExportToExcel ()". but I am confused how to make it that I mark it. How to make such a report in excel with telerik??? Please help me master all to make report as picture :D

    Thank you

    This report image
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 13 Jun 2013 Link to this post

    Hi

    I guess you want to have MultiColumn Headers to be exported into Excel.
    I have tried an example.Please have a look into the below code.I have attached a screenshot to show the output.

    ASPX:
    <telerik:RadGrid ID="RadGrid1" runat="server" ShowGroupPanel="true" AllowSorting="true"
               DataSourceID="SqlDataSource1" AllowPaging="true" PageSize="30" AutoGenerateColumns="false">
               <ClientSettings>
                   <Scrolling AllowScroll="true" UseStaticHeaders="true"></Scrolling>
               </ClientSettings>
               <MasterTableView CommandItemDisplay="Bottom">
                   <CommandItemSettings ShowExportToExcelButton="true" ShowAddNewRecordButton="false"
                       ShowRefreshButton="false" />
                   <ColumnGroups>
                       <telerik:GridColumnGroup HeaderText="Product Details" Name="ProductDetails" HeaderStyle-HorizontalAlign="Center">
                       </telerik:GridColumnGroup>
                       <telerik:GridColumnGroup HeaderText="Location" Name="Location">
                       </telerik:GridColumnGroup>
                       <telerik:GridColumnGroup HeaderText="Category" Name="Category" ParentGroupName="ProductDetails">
                       </telerik:GridColumnGroup>
                       <telerik:GridColumnGroup HeaderText="Order Details" Name="OrderDetails" ParentGroupName="ProductDetails"
                           HeaderStyle-HorizontalAlign="Center">
                       </telerik:GridColumnGroup>
                   </ColumnGroups>
                   <Columns>
                       <telerik:GridBoundColumn UniqueName="SupplierName" DataField="SupplierName" HeaderText="Supplier Name">
                       </telerik:GridBoundColumn>
                       <telerik:GridBoundColumn UniqueName="Address" DataField="Address" ColumnGroupName="Location"
                           HeaderText="Address">
                       </telerik:GridBoundColumn>
                       <telerik:GridBoundColumn UniqueName="City" DataField="City" ColumnGroupName="Location"
                           HeaderText="City">
                       </telerik:GridBoundColumn>
                       <telerik:GridNumericColumn UniqueName="ID" DataField="ID" ColumnGroupName="Category"
                           HeaderText="ID">
                       </telerik:GridNumericColumn>
                       <telerik:GridBoundColumn UniqueName="CategoryName" DataField="CategoryName" ColumnGroupName="Category"
                           HeaderText="Name">
                       </telerik:GridBoundColumn>
                       <telerik:GridNumericColumn UniqueName="Freight" DataField="Freight" ColumnGroupName="OrderDetails"
                           HeaderText="Freight">
                       </telerik:GridNumericColumn>
                       <telerik:GridDateTimeColumn UniqueName="OrderDate" DataField="OrderDate" ColumnGroupName="OrderDetails"
                           HeaderText="Date">
                       </telerik:GridDateTimeColumn>
                       <telerik:GridBoundColumn UniqueName="OrderAddress" DataField="OrderAddress" ColumnGroupName="OrderDetails"
                           HeaderText="Address">
                       </telerik:GridBoundColumn>
                   </Columns>
               </MasterTableView>
           </telerik:RadGrid>

    Thanks,
    Shinu
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Kamardy
    Kamardy avatar
    2 posts
    Member since:
    Mar 2013

    Posted 13 Jun 2013 Link to this post

    Thanks Shinu, may I ask again. how to create a report like this see the picture ???  I put a red box
  5. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 14 Jun 2013 Link to this post

    Hi,

    Sorry , i did not understand your requirments well, when you export from radgrid,every content of that will get exported, anything outside of the grid is excluded. Here what is it that you want to add above the table? is it just some header or details of column in radgrid?
    Please elaborate on your requirements.

    Thanks,
    Shinu
  6. Kostadin
    Admin
    Kostadin avatar
    1708 posts

    Posted 18 Jun 2013 Link to this post

    Hi Kamardy,

    A possible solution is to use ShiftRowsDown method which gives you the opportunity to insert new rows at the chosen position. More information could be found at the following help article.

    Regards,
    Kostadin
    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.
  7. RJ
    RJ avatar
    386 posts
    Member since:
    Oct 2006

    Posted 31 Mar in reply to Kostadin Link to this post

    Hello All,

    How can I do this multi-column header if my columns are dynamically created?

    Lastly why is it I'm having error when I do export text with "-" or "+" character at the beginning of the text. Any workaround?

     

    Thanks in Advance,

    RJ

     

     

  8. Kostadin
    Admin
    Kostadin avatar
    1708 posts

    Posted 04 Apr Link to this post

    Hi,

    When the columns are dynamically created you need to hook OnColumnsCreated event handler and set ColumnGroupName to each one of them. Nevertheless, You can either create the column groups declarative or programmatically on Init/Load.  

    Regards your second question I am not sure which export format you are using but in case you are using Xlsx then you need to set a string format to each cell which start with "-". You can do that by hooking OnInfrastructureExporting and access the cells that starts with "-" and set format to "@".

    Regards,
    Kostadin
    Telerik
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017