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
165
How to take CSV string.
posted

Hi.

Because I had wanted to acquire the displayed data by CSV, I tried.
Though it returns the result in order of sorting, not to have obtained the means to describe it clearly is my regret.
Is this code adequate?
Are there more adequate methods or more simple expedients?

public static string CreateCsvString(XamDataGrid xamDataGrid)
{
    return string.Join("\n", (
        from DataRecord dataRecord in xamDataGrid.Records
        where Visibility.Visible == dataRecord.VisibilityResolved
        select string.Join(",", (
            from cell in dataRecord.Cells
            where Visibility.Visible == cell.Field.VisibilityResolved
            orderby cell.Field.ActualPosition.Column
            select string.Format("\"{0}\"",
                cell.ConvertedValue.ToString().Replace("\"", "\"\""))).ToArray())).ToArray());
}

Thanks for reading my poor English and cruel code.

 

 

Parents
No Data
Reply
  • 9694
    posted

    Hello,

    I apologize no one has answered your post yet. Are you still looking for a solution? If so, would you be able to better describe the desired results you are looking for?

    Thank you!

Children
No Data