开发者

How to create a csv Excel file from content in a gridview in WPF?

I would like to export to a csv file the content of a gridview in WPF. Which is the best and efficient way to do开发者_开发问答 it?


Use the FileHelpers component to generate a CSV or simply use a StringBuilder instance to iterate through the contents of the columns in the WPF gridview, in similar pseudocode it would be like this.

StringBuilder sb = new StringBuilder();
foreach row in grid
   foreach col in grid
      sb.Append(col + ", ");
   end foreach
   sb.Append(Environment.NewLine);
end foreach

// Write out the StringBuilder instance to File

The above pseudocode iterates each row and each column, tacking on a delimiter for each column by using a comma.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜