This commit is contained in:
2022-07-08 08:12:43 +02:00
parent 697b78e3c9
commit 7f5057dc3e
121 changed files with 8039 additions and 19322 deletions

View File

@@ -1,4 +1,5 @@
Imports System.Net.Mail
Imports System.IO
Imports System.Net.Mail
Imports System.Text
Imports ClosedXML.Excel
@@ -122,9 +123,69 @@ Public Class cProgramFunctions
End Function
Public Shared Function genCSVFromDT(dt As DataTable, Optional openCSV As Boolean = False, Optional showColumnName As Boolean = True, Optional optFileName As String = "") As String
Try
Dim sPath As String = Environment.GetFolderPath(Environment.SpecialFolder.Personal) & "\VERAG\SDL\tmp\" ' My.Computer.FileSystem.GetTempFileName
If Not My.Computer.FileSystem.DirectoryExists(sPath) Then
My.Computer.FileSystem.CreateDirectory(sPath)
End If
Public Shared Function genExcelFromDT_NEW(dt As DataTable, Optional rangeAsWaehrung() As String = Nothing, Optional ShowAutoFilter As Boolean = True, Optional HeaderTxt As String = "", Optional HeaderTxt2 As String = "", Optional openPDF As Boolean = True, Optional optFileName As String = "") As String
Dim txt As String = ""
If showColumnName Then
Dim line As String = ""
For Each column As DataColumn In dt.Columns
'Add ColumnName
line += ";" & column.ColumnName.Replace(";", ",")
Next
'Add new line
txt += line.Substring(1) & vbCrLf
End If
For Each row As DataRow In dt.Rows
Dim line As String = ""
For Each column As DataColumn In dt.Columns
'Add the Data rows.
line += ";" & row(column.ColumnName).ToString().Replace(";", ",")
Next
'Add new line
txt += line.Substring(1) & vbCrLf
Next
Dim endung = ".csv"
Dim filename As String = ""
If optFileName <> "" Then
filename = sPath & optFileName & endung '".xlsx"
While IO.File.Exists(filename)
filename = sPath & optFileName & Now.ToString("ddMMyyyyHHmmss") & endung '".xlsx"
End While
Else
filename = sPath & "tmp_" & Now.ToString("ddMMyyyyHHmmss") & endung '".xlsx"
While IO.File.Exists(filename)
filename = sPath & "tmp_" & Now.ToString("ddMMyyyyHHmmss") & endung '".xlsx"
End While
End If
Using sw As StreamWriter = New StreamWriter(filename, False, System.Text.Encoding.UTF8)
sw.WriteLine(txt)
End Using
If openCSV Then Process.Start(filename)
Return filename
Catch ex As Exception
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
Return Nothing
End Try
End Function
Public Shared Function genExcelFromDT_NEW(dt As DataTable, Optional rangeAsWaehrung() As String = Nothing, Optional ShowAutoFilter As Boolean = True, Optional HeaderTxt As String = "", Optional HeaderTxt2 As String = "", Optional openPDF As Boolean = True, Optional optFileName As String = "", Optional endung As String = ".xlsx") As String
Try
Dim sPath As String = Environment.GetFolderPath(Environment.SpecialFolder.Personal) & "\VERAG\SDL\tmp\" ' My.Computer.FileSystem.GetTempFileName
@@ -162,14 +223,14 @@ Public Class cProgramFunctions
Dim filename As String = ""
If optFileName <> "" Then
filename = sPath & optFileName & ".xlsx"
filename = sPath & optFileName & endung '".xlsx"
While IO.File.Exists(filename)
filename = sPath & optFileName & Now.ToString("ddMMyyyyHHmmss") & ".xlsx"
filename = sPath & optFileName & Now.ToString("ddMMyyyyHHmmss") & endung '".xlsx"
End While
Else
filename = sPath & "tmp_" & Now.ToString("ddMMyyyyHHmmss") & ".xlsx"
filename = sPath & "tmp_" & Now.ToString("ddMMyyyyHHmmss") & endung '".xlsx"
While IO.File.Exists(filename)
filename = sPath & "tmp_" & Now.ToString("ddMMyyyyHHmmss") & ".xlsx"
filename = sPath & "tmp_" & Now.ToString("ddMMyyyyHHmmss") & endung '".xlsx"
End While
End If