A good way to export a datagridview to excel table

The original code is in the url here. And I have change some of the code to get it run.

And I'm suprised by the way the guy using the LINQ.

And I'm thinking of learning more about LINQ someday.

            var lines = new List<string>();
            var valueLines = this.changeTable.AsEnumerable()
                   .Select(row => string.Join(",", row.ItemArray.AsEnumerable().Select(obj => obj.ToString()).ToArray()));
            lines.AddRange(valueLines);
            File.WriteAllLines(sfd.FileName, lines.ToArray());
原文地址:https://www.cnblogs.com/henyihanwobushi/p/3134888.html