Excel 출력 CreateObject("Excel.Application")

1512 단어 .net
Dim xlApplication = CreateObject("Excel.Application")
        Dim xlBooks = xlApplication.Workbooks.Add
        Dim xlSheet = xlBooks.Worksheets(1)
        Dim strFilePath = comSaveFileDialog(Me, , , TG.eDIALOGKBN.XLS)
        Dim iCnt As Integer = 0
        //Excel 
        xlApplication.Visible = False

        xlBooks = xlApplication.Workbooks.Add
        xlSheet = xlBooks.ActiveSheet
        //Excel 
        xlSheet.Range(xlSheet.Cells(1, 1), xlSheet.Cells(1, 2)).Merge(Reflection.Missing.Value)
        //Excel 
        xlSheet.Cells(1, 1).Interior.Color = System.Drawing.Color.FromArgb(171, 171, 171).ToArgb()
        For Each dr As DataRow In Me.ToriData.Select()
            iCnt += 1
            xlSheet.Cells(iCnt, 1).Value = iCnt
            //Excel 
            xlSheet.Cells(iCnt, 1).HorizontalAlignment = DL_EXCEL_XLHALIGNRIGHT
            //Excel 
            xlSheet.Cells(iCnt, 1).Borders.LineStyle = 1
        Next

        //xlApplication.Visible = True
        //xlApplication.UserControl = True

        'Excel 
        xlApplication.DisplayAlerts = False

        'Excel 
        xlBooks.SaveAs(FileName:=strFilePath, FileFormat:=DL_EXCEL_HOZON)

        'Excel 
        xlApplication.Quit()

        'COM 
        System.Runtime.InteropServices.Marshal.ReleaseComObject(xlSheet)
        System.Runtime.InteropServices.Marshal.ReleaseComObject(xlBooks)
        System.Runtime.InteropServices.Marshal.ReleaseComObject(xlApplication)

좋은 웹페이지 즐겨찾기