小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

表格數(shù)據(jù)導(dǎo)到Txt、Excel

 *藍(lán)星* 2019-07-20

'表格數(shù)據(jù)導(dǎo)到Txt

    Private Sub ToolStripButtonExpTxt_Click(sender As Object, e As EventArgs) Handles ToolMain_ButtonExpTxt.Click

        Dim cFileName As String = "D:\MyProg\" & "連板" & Date.Now.Month.ToString & Date.Now.Day.ToString & ".txt"

        Dim oFile As New StreamWriter(cFileName)

        Dim strTemp As String = Nothing

        Try

            For r = 0 To DGV_GpHqFind.RowCount - 1

                strTemp = ""

                For c = 0 To DGV_GpHqFind.Columns.Count - 1

                    strTemp &= DGV_GpHqFind(c, r).Value & ","

                Next

                oFile.WriteLine(strTemp)

            Next

            MsgBox("數(shù)據(jù)已導(dǎo)到:" & cFileName, 64, "信息提示")

            oFile.Close()

        Catch ex As Exception

            MsgBox(ex.ToString, 48, "錯誤信息")

        End Try

        oFile = Nothing

    End Sub

    '表格數(shù)據(jù)導(dǎo)到Excel

    Private Sub ToolStripButtonExpExcel_Click(sender As Object, e As EventArgs) Handles ToolMain_ButtonExpExcel.Click

        Dim oExce As Excel.Application

        Dim oWork As Excel.Workbook

        Dim oSh As Excel.Worksheet

        Dim oRng As Excel.Range

        Try

            Dim cTitle As String = "代碼,名稱,今開,昨收,今收,漲跌,漲幅%,最高,最低,成交量,成交額"

            Dim aTitle As Array = cTitle.Split(",")

            ' Start Excel and get Application object.

            oExce = CreateObject("Excel.Application")

            oExce.Visible = True

            ' Add a new workbook.

            oWork = oExce.Workbooks.Add

            oSh = oWork.ActiveSheet

            For c As Integer = 0 To aTitle.Length - 1

                oSh.Cells(1, c + 1).Value = aTitle(c)

            Next

            oExce.ScreenUpdating = False

            ' Format A1:D1 as bold, vertical alignment = center.

            oSh.Range("A:B").NumberFormatLocal = "@"

            For r = 0 To Me.DGV_GpHqFind.RowCount - 1

                For c = 0 To Me.DGV_GpHqFind.ColumnCount - 1

                    With oSh

                        If c < 2 Then

                            .Cells(r + 2, c + 1).Value = Me.DGV_GpHqFind.Item(c, r).Value.ToString

                        Else

                            .Cells(r + 2, c + 1).Value = Me.DGV_GpHqFind.Item(c, r).Value

                        End If

                    End With

                Next

            Next

            With oSh.Range("A1", "K" & DGV_GpHqFind.RowCount + 1)

                .Font.Name = "微軟雅黑"

                .Font.Size = 11

            End With

            With oSh.Range("A1", "K1")

                .Font.Bold = True

                .VerticalAlignment = Excel.XlVAlign.xlVAlignCenter

                .EntireColumn.AutoFit()

            End With

            oExce.ScreenUpdating = True

            ' Make sure Excel is visible and give the user control

            ' of Excel's lifetime.

            ' Release object references.

            'oExce.Visible = True

            oRng = Nothing

            oSh = Nothing

            oWork = Nothing

            oExce.Quit()

            oExce = Nothing

        Catch ex As Exception

            MsgBox(ex.ToString, 48, "錯誤信息")

        End Try

    End Sub

    本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點(diǎn)擊一鍵舉報。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多