직원들이 다 엑셀을 쓴다...
학교 다닐때는 한글을 주로 썼지만
회사 다니니 한글이 아니라 엑셀만 쓴다
관공서 외에는 한글 쓰는데가 1%도 없는거 같다...
라이브러리에 excel 추가 해서 사용하자..
자세한 사항은
첨부로....^^
추가 사항 (ADO로 엑셀 다루기)
펼쳐두기..
[code vb]
'ado로 엑셀 파일 연결------------------------
Private Sub cmdRead_Click()
Dim Rs As New ADODB.Recordset
Dim Fld As ADODB.Field
Dim nRow As Integer
Dim nCol As Integer
Dim SQL As String
Dim imsi As String
ExcelOpen (txtPath)
SQL = "select * " ' -- F1,F2,F3,F4,F5,F6 "
SQL = SQL & "FROM [Excel 8.0;HDR=Yes;DATABASE=" & txtPath & "].[Sheet1$] "
Rs.Open SQL, ExcelCon
With MSHFlexGrid1
.Redraw = False
nRow = 1
While Not Rs.EOF
.RowHeight(nRow) = 300
For nCol=0 to 5
.TextMatrix(nRow, nCol) = Rs.Fields(nCol) & ""
next
.Row = nRow
If nRow Mod 5 = 0 Then
For nCol = 1 To .Cols - 1
.col = nCol: .CellBackColor = &HC0FFFF
Next
End If
nRow = nRow + 1
.Rows = nRow + 1
Rs.MoveNext
Wend
.Rows = .Rows - 1
.Redraw = True
End With
Rs.Close
Set Rs = Nothing
ExcelClose
End Sub
'--------------------------------------------
'
'--------------------------------------------
Public Function ExcelOpen(strPath As String)
On Error GoTo e1:
Set ExcelCon = New ADODB.Connection
With ExcelCon
.Provider = "Microsoft.Jet.OLEDB.4.0"
.Properties("Extended Properties").Value = "Excel 8.0"
.Open strPath
End With
Exit Function
e1:
MsgBox Err.Description
End Function
Public Function ExcelClose()
ExcelCon.Close
End Function
[/code]
'ado로 엑셀 파일 연결------------------------
Private Sub cmdRead_Click()
Dim Rs As New ADODB.Recordset
Dim Fld As ADODB.Field
Dim nRow As Integer
Dim nCol As Integer
Dim SQL As String
Dim imsi As String
ExcelOpen (txtPath)
SQL = "select * " ' -- F1,F2,F3,F4,F5,F6 "
SQL = SQL & "FROM [Excel 8.0;HDR=Yes;DATABASE=" & txtPath & "].[Sheet1$] "
Rs.Open SQL, ExcelCon
With MSHFlexGrid1
.Redraw = False
nRow = 1
While Not Rs.EOF
.RowHeight(nRow) = 300
For nCol=0 to 5
.TextMatrix(nRow, nCol) = Rs.Fields(nCol) & ""
next
.Row = nRow
If nRow Mod 5 = 0 Then
For nCol = 1 To .Cols - 1
.col = nCol: .CellBackColor = &HC0FFFF
Next
End If
nRow = nRow + 1
.Rows = nRow + 1
Rs.MoveNext
Wend
.Rows = .Rows - 1
.Redraw = True
End With
Rs.Close
Set Rs = Nothing
ExcelClose
End Sub
'--------------------------------------------
'
'--------------------------------------------
Public Function ExcelOpen(strPath As String)
On Error GoTo e1:
Set ExcelCon = New ADODB.Connection
With ExcelCon
.Provider = "Microsoft.Jet.OLEDB.4.0"
.Properties("Extended Properties").Value = "Excel 8.0"
.Open strPath
End With
Exit Function
e1:
MsgBox Err.Description
End Function
Public Function ExcelClose()
ExcelCon.Close
End Function
[/code]
VB에서_엑셀_직접_다루기.pdf
댓글 없음:
댓글 쓰기