Форумы HiProg.com - MS ACCESS, VBA, VB

 

Ответить на сообщение

Вернуться к теме

Вы отвечаете на сообщение:

ник: ddi
вот код

Public Function exporthv() As Boolean
        Dim t As New db.ph_exportDataTable
        Dim ta As New dbTableAdapters.ph_exportTableAdapter
        ta.Fill(t, userid, d1, d2)
        If FileIO.FileSystem.FileExists(Application.StartupPath & "\Export\Hamayqayin\PayDB.xlsx") = True Then
            My.Computer.FileSystem.DeleteFile(Application.StartupPath & "\Export\Hamayqayin\PayDB.xlsx")
        End If
        Dim Excel As Object = CreateObject("Excel.Application")
        Dim strFilename As String
        Dim intCol, intRow As Integer
        Dim strPath As String = Application.StartupPath & "\Export\Hamayqayin\"
        If Excel Is Nothing Then
            DevComponents.DotNetBar.MessageBoxEx.Show("", "Վճարներ", MessageBoxButtons.OK, MessageBoxIcon.Warning)
            Return False
        End If
        Try
            With Excel
                .SheetsInNewWorkbook = 1
                .Workbooks.Add()
                .Worksheets(1).Select()
                .cells(1, 1).value = "Heading"
                .cells(1, 1).EntireRow.Font.Bold = True
                Dim intI As Integer = 1
                For intCol = 0 To t.Columns.Count - 1
                    .cells(2, intI).value = t.Columns(intCol).ColumnName
                    .cells(2, intI).EntireRow.Font.Bold = True
                    intI += 1
                Next
                intI = 3
                Dim intK As Integer = 1
                For intCol = 0 To t.Columns.Count - 1
                    intI = 3
                    For intRow = 0 To t.Rows.Count - 1
                        .Cells(intI, intK).Value = t.Rows(intRow).ItemArray(intCol)
                        intI += 1
                    Next
                    intK += 1
                Next
                If Mid$(strPath, strPath.Length, 1) <> "\" Then
                    strPath = strPath & "\"
                End If
                strFilename = strPath & "PayDB.xlsx"
                .ActiveCell.Worksheet.SaveAs(strFilename)
            End With

            Excel.Workbooks.Close()
            Excel.Quit()
            Excel = Nothing
            'System.Runtime.InteropServices.Marshal.ReleaseComObject(Excel)
            GC.Collect()
             DevComponents.DotNetBar.MessageBoxEx.Show("&#1359;&#1406;&#1397;&#1377;&#1388;&#1398;&#1381;&#1408;&#1384; &#1377;&#1408;&#1407;&#1377;&#1392;&#1377;&#1398;&#1406;&#1377;&#1390; &#1381;&#1398;", "&#1358;&#1395;&#1377;&#1408;&#1398;&#1381;&#1408;", MessageBoxButtons.OK, MessageBoxIcon.Information)
        Catch ex As Exception
            DevComponents.DotNetBar.MessageBoxEx.Show(ex.Message, "&#1358;&#1395;&#1377;&#1408;&#1398;&#1381;&#1408;", MessageBoxButtons.OK, MessageBoxIcon.Information)
        End Try
        'Dim pro() As Process = System.Diagnostics.Process.GetProcessesByName("EXCEL")
        'For Each i As Process In pro
        'i.Kill()
        'Next
        Return True
    End Function


Ваше имя:

Пароль:

Цитировать: [quote][/quote] Код: [code][/code]
Жирный: [b][/b] Наклонный: [i][/i]
URL: [url][/url] 

Сообщение:

 Размер файла не более 50 Кбт. Большие файлы можно размещать на www.slil.ru

Прикрепить:

 

Для вставки смайлов в текст щелкните по значку.