Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
40
Export to Excel Hierarchical Grid
posted

When you export to Excel with a hierarchical grid it includes the outline in the excel workbook.

Is it possible to change this behavior so that the entire contents are displayed in one record?

This way if the root grid had the author name and the child grid had book title and price when you exported it would put the autho, book title and price on one line and you would have a row for each author and book combination.


Parents
  • 4960
    posted

    So if I understand correctly, what you are trying to achieve is something like this?

    Original Grid:

    Dostoyevsky      1821-1881     Russian novelist
     *  Crime and Punishment        1866
     *  Brothers Karamazov            1880
    Dumas               1802-1870    French novelist
     *  Three Musketeers                1844
     *  Count of Monte Crisco          1846

    Desired Worksheet:

    Dostoyevsky           Crime and Punishment      1866
    Dostoyevsky           Brothers Karamazov          1880
    Dumas                   Three Musketeers              1844
    Dumas                   Count of Monte Crisco        1846

    This should be possible using the events, although it will require some careful finnagling from you to control where the exporter writes the cell values. 

    WebGridExcelExporter will fire RowExporting events fired before each row (both parent rows and child rows), as well as firing the HeaderRowExporting event (which happens for the child band's column headers, which you may want to erase or combine with column headers from the parent band.) 

    At any point you can change the location in the Worksheet where the exported UltraGridRow's cells go by adjusting the CurrentRowIndex and CurrentColumnIndex properties on the EventArgs your event handlers of these events will be passed.  So you can do things like back-up, shift cells up in the worksheet from a child row to overwrite a the worksheet cells in a parent row or eliminate any extra rows of spacing between row islands, etc.  As far as copying the Author's Name from the parent row, you'll need to make that copy yourself for each child row of data but you can copy that from the parent row that was exported to each child row that exports after it (until a new parent row is exported, you can check teh EventArgs' CurrentOutlineIndex or the row's Band object to determine when this changes, among other methods), since the parent row will always export first / on top.

Reply Children
No Data