求助!vb.net 2010 datagridview另存为2007版本的EXCEL文件打开提示文件损坏,2003正常。
程序代码:
Dim SaveFile As New SaveFileDialog SaveFile.Filter = "Excel 2003|*.xls|Excel 2007|*.xlsx" SaveFile.OverwritePrompt = True SaveFile.RestoreDirectory = True SaveFile.InitialDirectory = "d:\" SaveFile.ShowDialog() Dim ws As New (SaveFile.OpenFile, System.Text.Encoding.Default) Dim str As String = "" For i As Integer = 0 To DGV.Columns.Count - 1 str += DGV.Columns(i).HeaderCell.Value.ToString & vbTab Next str += vbCrLf For Each row As DataGridViewRow In DGV.Rows For i As Integer = 0 To DGV.Columns.Count - 1 If Not row.IsNewRow Then str += row.Cells.Item(i).Value.ToString & vbTab End If Next str += vbCrLf Next ws.Write(str) ws.Close() End Sub
[此贴子已经被作者于2016-3-16 12:18编辑过]