Private Sub konverze(sender As Object, e As EventArgs) Handles konvertovat_btn.Click
Dim datestart As Date = Date.Now
Dim dateEnd As Date = Date.Now
Dim msExcelApplication As New Microsoft.Office.Interop.Excel.Application()
Dim xlApp As New Excel.Application
Dim path As String = "M:\Úsek financí\power BI\Helios Evidence vyrobnich operaci\říjen2018.xlsx"
Dim xlWorkbook As Excel.Workbook = xlApp.Workbooks.Add()
Dim xlWorksheet As Excel.Worksheet = CType(xlWorkbook.Sheets("List1"), Excel.Worksheet)
xlWorksheet.Cells(1, 1) = ""
If File.Exists("M:\Úsek financí\power BI\Helios Evidence vyrobnich operaci\říjen2018.xlsx") Then
Else
xlWorksheet.SaveAs(path)
xlWorkbook.Close()
xlApp.Quit()
End If
Dim workBook As Microsoft.Office.Interop.Excel.Workbook = msExcelApplication.Workbooks.Open("M:\Úsek financí\power BI\Helios Evidence vyrobnich operaci\říjen2018.xlsx", 0, False, Type.Missing, "", "", True, Type.Missing, Type.Missing, True, False, Type.Missing, True, False, False)
'workBook.WebOptions.Encoding = Microsoft.Office.Core.MsoEncoding.msoEncodingOEMNordic
Try
Dim workSheet As Microsoft.Office.Interop.Excel.Worksheet = workBook.Sheets(1)
With workSheet.QueryTables.Add(Connection:="TEXT;M:\Úsek financí\říjen2018.csv", Destination:=workSheet.Range("$A$1"))
.Name = "říjen2018"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.SavePassword = False
.RefreshStyle = Microsoft.Office.Interop.Excel.XlCellInsertionMode.xlInsertDeleteCells
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
'.TextFilePlatform = 1250
.TextFileStartRow = 1
.TextFileParseType = Microsoft.Office.Interop.Excel.XlTextParsingType.xlDelimited
.TextFileTextQualifier = Microsoft.Office.Interop.Excel.XlTextQualifier.xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = False
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = True
.TextFileSpaceDelimiter = False
.TextFileTrailingMinusNumbers = True
.Refresh(BackgroundQuery:=False)
End With
Catch ex As Exception
Console.WriteLine(ex.ToString())
Console.ReadLine()
Finally
'workBook.SaveAs(Name)
workBook.Close(True)
msExcelApplication.Quit()
Marshal.ReleaseComObject(xlWorksheet)
Marshal.ReleaseComObject(xlWorkbook)
Marshal.ReleaseComObject(workBook)
Marshal.ReleaseComObject(xlApp)
end sub