Torna al Thread

Public Shared Sub SaveGridDataInFile(ByVal _dgInput As DataGridView, ByVal _sFieldsName() As String, ByVal _iStartIndexField As Integer, ByRef _fName As String, Optional ByVal stampaDaButton As Boolean = True) Dim objWriter As System.IO.StreamWriter = Nothing Dim i As Integer Dim j As Integer Try objWriter = New System.IO.StreamWriter(_fName, False) 'inserisce titolo For i = 0 To _sFieldsName.GetUpperBound(0) objWriter.Write(_sFieldsName(i) + ";") Next objWriter.WriteLine() For j = 0 To (_dgInput.Rows.Count - 1) 'parte dall'indice di colonna "intStartIndexField" della griglia For i = _iStartIndexField To (_dgInput.Columns.Count - 1) If Not TypeOf _dgInput.Item(i, j).Value Is DBNull Then If _dgInput.Item(i, j).ValueType.Name = "Double" Then objWriter.Write(_dgInput.Item(i, j).Value.ToString.Replace("."c, ","c)) Else objWriter.Write(_dgInput.Item(i, j).Value.ToString) End If Else objWriter.Write("") End If Next objWriter.WriteLine() objWriter.Flush() Next objWriter.Close() Catch ex As Exception Finally objWriter.Close() End Try End Sub
Copyright © dotNetHell.it 2002-2025
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5