- °³¿ä
- ¸ñ·Ï
- ¸ðµç ¿öÅ© ½ÃÆ® ³»ÀÇ Æ¯Á¤ ¼¿ Ãâ·ÂÇϱâ
- ƯÁ¤ ¼¿ µ¥ÀÌÅ͸¦ ÅØ½ºÆ® ÆÄÀÏ¿¡´Ù ¾²±â.
- XLS ÆÄÀÏÀ» CSV ÆÄÀÏ·Î º¯È¯Çϱâ
- À̹ÌÁö Áý¾î³Ö±â
- Çà ³ôÀÌ, ¿ Æø º¯°æÇϱâ
- ¸µÅ©
1 °³¿ä
VB ¹× VBA(Visual Basic Addin) ½ºÅ©¸³Æ®¸¦ ÀÌ¿ëÇÑ ¿¢¼¿ ¹®¼ 󸮸¦ ´Ù·é´Ù.
°ÔÀÓ °³¹ß½Ã ±âȹ Ãø¿¡¼ ¿¢¼¿ ¹®¼¸¦ ÀÌ¿ëÇØ µ¥ÀÌÅ͸¦ ³Ñ±â´Â °æ¿ì°¡ Àִµ¥, ÀÌ·± µ¥ÀÌÅ͸¦ ÇÁ·Î±×·¡¸Ó°¡ ÀÏÀÏÀÌ Àç°¡°øÇÏ´Â °ÍÀº ³ë°¡´Ù°¡ ¾Æ´Ï¶ó°í ÇÒ ¼ö ¾ø´Ù. ±×·¸´Ù°í ÇÁ·Î±×·¡¸Ó Ãø ±âÈ£¿¡ ¸ÂÃç¼ ±âȹ Ãø¿¡¼ CSV °°Àº °É ¾²´Â °Íµµ º°·Î¶ó°í »ý°¢ÇÑ´Ù. ¿Ö³ÄÇÏ¸é ¿¢¼¿ ¹®¼¿¡´Ù À̹ÌÁö µîÀ» ³Ö¾îµÖ¾ßÁö ÀÛ¾÷ÀÌ ÆíÇÑ °æ¿ìµµ Àֱ⠶§¹®ÀÌ´Ù. (CSV¿¡´Â ÅØ½ºÆ® ¹Û¿¡ ³ÖÀ» ¼ö ¾ø´Ù.)
°á±¹ ±âȹ Ãø¿¡¼´Â ¿¢¼¿ ¹®¼ ±×´ë·Î ÀÛ¾÷Çϰí, ±× ¿¢¼¿ ÆÄÀÏÀ» ÇÁ·Î±×·¡¸Ó°¡ ¾²±â ÆíÇÏ°Ô ¸¸µé¾îÁÖ´Â Áß°£ ¸Å°³Ã¼°¡ ÇÊ¿äÇÏ´Ù´Â ¸»ÀÌ´Ù. ±× ¸Å°³Ã¼·Î »ý°¢ÇÑ °ÍÀÌ VB ½ºÅ©¸³Æ®´Ù. ¾î¼³ÇÂ Åø Â¥ºÃÀÚ ¿¢¼¿º¸´Ù ÆíÇÒ ¸®µµ ¸¸¹«Çϰí...
¹®Á¦´Â WSH ½ºÅ©¸³Æ®¸¸À¸·Î´Â ¿¢¼¿ ±â´ÉÀ» ¿Ïº®ÇϰÔ(?) Ȱ¿ëÇϱⰡ Èûµé´Ù´Â Á¡Àε¥... ÀÏ´Ü ½ºÅ©¸³Æ®·Î Àû´çÈ÷ Â¥´Ù°¡ Èûµé¾îÁö¸é, VisualBasic ÄÜ¼Ö ¾ÖÇø®ÄÉÀ̼ÇÀ¸·Î ³Ñ¾î°¡´Â ¹æÇâÀ¸·Î...
2 ¸ñ·Ï
2.1 ¸ðµç ¿öÅ© ½ÃÆ® ³»ÀÇ Æ¯Á¤ ¼¿ Ãâ·ÂÇϱâ
'On Error Resume Next
Dim xlApp
Dim xlBook
Dim xlSheet
Dim xlRange
Dim i
Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.WorkBooks.Open("test.xls")
For Each xlSheet In xlBook.Sheets
For row=1 To 2 'xlSheet.Rows.Count
For col=1 To 2 'xlSheet.Columns.Count
WScript.Echo "(" & xlSheet.Name & "," & row & "," & col & ")=" & xlSheet.Cells(row, col)
Next
Next
i = i + 1
Next
xlBook.close False
xlApp.quit
2.2 ƯÁ¤ ¼¿ µ¥ÀÌÅ͸¦ ÅØ½ºÆ® ÆÄÀÏ¿¡´Ù ¾²±â.
Dim xlApp 'Excel.Application
Dim xlBook 'Excel.Workbook
Dim xlSht 'Excel.Worksheet
Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.WorkBooks.Open("test.xls")
Set xlSht = xlApp.activesheet
iRet = WriteResultFile(xlSht.Cells(1, 1).Value)
xlBook.close False
xlApp.quit
function WriteResultFile(strResult)
const ForReading=1, ForWriting=2, ForAppending=8
Dim fso, ts
set fso = CreateObject("Scripting.FileSystemObject")
set ts = fso.OpenTextFile("test.txt", ForWriting, True)
ts.WriteLine(strResult)
ts.Close
WriteResultFile = 0
end function
2.3 XLS ÆÄÀÏÀ» CSV ÆÄÀÏ·Î º¯È¯Çϱâ
On Error Resume Next
Dim xlApp
Dim xlBook
Dim xlSheet
Dim xlRange
Dim fso, file
Dim line, total
Dim XLSName, CSVName
const ForReading=1, ForWriting=2, ForAppending=8
If WScript.Arguments.Count <> 2 Then
WScript.Echo "Usage : convert.vbs excel_filename csv_filename"
WScript.Quit
End If
Set XLSName = WScript.Arguments.Item(0)
Set CSVName = WScript.Arguments.Item(1)
Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = True
Set xlBook = xlApp.WorkBooks.Open(XLSName)
Set fso = CreateObject("Scripting.FileSystemObject")
Set file = fso.OpenTextFile(CSVName, ForWriting, True)
For Each xlSheet In xlBook.Sheets
For row=2 To 10 'xlSheet.Rows.Count
total = 0
For col=1 To 15
total = total + Len(xlSheet.Cells(row, col))
Next
If total = 0 Then Exit For
line = CSV(xlSheet.Cells(row, 1)) & "," 'Ŭ·¡½º
line = line & CSV(xlSheet.Cells(row, 2)) & "," 'ŸÀÔ
line = line & CSV(xlSheet.Cells(row, 3)) & "," 'À̸§
line = line & CSV(xlSheet.Cells(row, 4)) & "," '°¡°Ý
line = line & CSV(xlSheet.Cells(row, 5)) & "," 'ÃÖ¼Ò
line = line & CSV(xlSheet.Cells(row, 6)) & "," 'ÃÖ´ë
line = line & CSV(xlSheet.Cells(row, 7)) & "," '½ºÅ¸ÀÏ
line = line & CSV(xlSheet.Cells(row, 8)) & "," '°èÀý
line = line & CSV(xlSheet.Cells(row, 9)) & "," '¹è»ö
line = line & CSV(xlSheet.Cells(row, 10)) & "," '³ëÃâ
line = line & CSV(xlSheet.Cells(row, 11)) & "," '·¹À̾î
line = line & CSV(xlSheet.Cells(row, 12)) & "," '¹üÇÁ
line = line & CSV(xlSheet.Cells(row, 13)) & "," '¼Ó¼º
line = line & CSV(xlSheet.Cells(row, 14)) & "," '¸Þ½Ã
line = line & CSV(xlSheet.Cells(row, 15)) 'ÅØ½ºÃÄ
file.WriteLine(line)
Next
Next
file.Close
xlBook.close False
xlApp.quit
WScript.Echo "º¯È¯ ¿Ï·á"
' ÀÓÀÇÀÇ ¼¿À» CSV Çü½ÄÀ¸·Î º¯È¯Çϱâ À§ÇÑ ÇÔ¼ö
Function CSV(text)
Dim QuoteIndex
Dim CommaIndex
Dim LineFeedIndex
Dim Result
Result = text
QuoteIndex = InStr(1, Result, """")
CommaIndex = InStr(1, Result, ",")
LineFeedIndex = InStr(1, Result, VBLF)
If QuoteIndex <> 0 OR CommaIndex <> 0 OR LineFeedIndex <> 0 Then
While QuoteIndex <> 0
Result = Mid(Result, 1, QuoteIndex) & """" & Mid(Result, QuoteIndex+1)
QuoteIndex = InStr(QuoteIndex+2, Result, """")
Wend
Result = """" & Result & """"
End If
CSV = Result
End Function
2.4 À̹ÌÁö Áý¾î³Ö±â
Dim xlApp
Dim xlBook
Dim xlRange
Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = True
Set xlBook = xlApp.WorkBooks.Open("d:\iteminfo.xls")
Set xlRange = xlApp.Range("A1")
InsertPicture xlApp.ActiveSheet, "d:\BED.BMP", xlRange, True, True
xlBook.close True 'º¯°æµÈ »çÇ×À» ÀúÀåÇϰí, ´Ý´Â´Ù.
xlApp.quit
' ´ë»óÀÌ µÇ´Â ¼¿¿¡´Ù°¡ À̹ÌÁö¸¦ Áý¾î³Ö´Â´Ù.
Sub InsertPicture(sheet, filename, cell, centerH, centerV)
Dim picture
Dim top
Dim left
Dim width
Dim height
' import picture
Set picture = sheet.Pictures.Insert(filename)
' À̹ÌÁö Å©±â¸¦ º¯°æÇÒ ¼ö ÀÖ´Ù.
'picture.Width = 100
'picture.Height = 100
' determine positions
top = cell.Top
left = cell.Left
If centerH Then
width = cell.Offset(0, 1).Left - cell.Left
left = left + width / 2 - picture.Width / 2
If l < 1 Then l = 1
End If
If centerV Then
height = cell.Offset(1, 0).Top - cell.Top
top = top + height / 2 - picture.Height / 2
If top < 1 Then top = 1
End If
' position picture
picture.Top = top
picture.Left = left
Set picture = Nothing
End Sub
2.5 Çà ³ôÀÌ, ¿ Æø º¯°æÇϱâ
Sub SetColumnWidth(sheet, col, width)
If col < 1 OR col > 256 Then Exit Sub
sheet.Columns(col).ColumnWidth = width
End Sub
Sub SetRowHeight(sheet, row, height)
If row < 1 OR row > 65536 Then Exit Sub
sheet.Rows(row).RowHeight = height
End Sub
3 ¸µÅ©
SeriousMoin v1 (koMoinMoin 1.0a4 Modified)