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
75
Exporting XAMgrid to excell
posted

Hi  

Which is the best way to export xamlgrid to excell sheet?

Thanks

MK 

 

Parents
No Data
Reply
  • 8576
    Offline posted
    Hi MK -
     
    Since there is no 'ExportToExcel' method on the xamDataGrid, the only way to do this would be to write a routine that iterates through each record in the xamDataGrid's ViewableRecords collection looking for records of type DataRecord, and then looking at the Value of each Cell in the record's Cells collection.  You could then put this information in a comma delimited format and feed it to Excel.
     
    Here is some sample code:
     

    foreach (Record record in this.xamDataGrid1.ViewableRecords)

    {

    StringBuilder recordAsString = new StringBuilder();

    if (record is DataRecord)

    {

    foreach (Cell cell in ((DataRecord)record).Cells)

    {

    recordAsString.Append(cell.Value.ToString() + ",");

    }

    }

    // Feed this 'record as string' to Excel. For now, just print it in the debug window.

    Debug.Print(recordAsString.ToString());

    }

     
     
    Joe
     
Children