export 2 datagrids to excel spreadsheet, each datagrid in a separate worksheet

4 posts, 0 answers
  1. peter
    peter avatar
    37 posts
    Member since:
    Feb 2011

    Posted 22 Sep 2012 Link to this post

    Hi i have two datagrids on a page, and on the click of a button, i would like to export the datagrids to the same excel spreadsheet, however both have to be in seperate worksheets, how can i achieve this. Thanks
  2. peter
    peter avatar
    37 posts
    Member since:
    Feb 2011

    Posted 24 Sep 2012 Link to this post

    Hi does anyone know if this is possible, thanks
  3. DevCraft banner
  4. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1127 posts

    Posted 24 Sep 2012 Link to this post

    Hi,

    Yes, it is possible, but not out of the box. First of all, you should use the ExcelML format, as it is the only one that supports separate worksheets. And this is the trick: you should export both of the RadGridViews in separate MemoryStreams, read them as strings and then write the modified content in the FileStream opened for the exporting operation. You should achieve something like that in the end:
    <Workbook . . . >
        <Worksheet . . . >
            <Table . . .>
            Grid1 rows
            </Table>
        </Worksheet>
        <Worksheet . . . >
            <Table . . .>
            Grid2 rows
            </Table>
        </Worksheet>
    </Workbook>
    Please, let us know in case you need any additional assistance on this.

    Greetings,
    Ivan Ivanov
    the Telerik team

    Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.

  5. peter
    peter avatar
    37 posts
    Member since:
    Feb 2011

    Posted 29 Sep 2012 Link to this post

    Hi have you got an example of this, i have no idea what to do, thanks
Back to Top