¾È±Ô °øºÎ¹æ

ACTIVE SERVER PAGE > Excel Connection

µî·ÏÀÏ : 2017-07-04 17:39 Á¶È¸¼ö : 52,541

¿¢¼¿ ÆÄÀÏ°¡ Áغñ°¡ Àß µÇ¾úÀ¸¸é, ÀÌÁ¦ Excel¸¦ Connection ½ÃÄÑ º¸µµ·Ï ÇÏ°Ú½À´Ï´Ù.
 
  12.2.1  OLE-DB¸¦ ÅëÇÑ Connection
  Set objCnn = Server.CreateObject("ADODB.Connection") strCnn = "Driver={Microsoft Excel Driver (*.xls)}; DBQ=c:\inetpub\wwwroot\Excel\test.xls" objCnn.Open strCnn strSQL = "SELECT * from test" set objRs=ObjCnn.Execute(strSql)
 
À§ÀÇ ¿¹Á¦¿Í °°ÀÌ »ç¿ëÇÏ¸é µË´Ï´Ù. strCnn ¿¡¼­ DBQ´Â xls ÆÄÀÏÀÇ Àý´ë°æ·Î¸¦ Àû¾îÁÖ½Ã¸é µÇ±¸¿ä.
SELECT * FROM TEST ¿¡¼­ 'test'´Â  ¿¢¼¿ ÆÄÀÏ¿¡¼­ Á¤ÀÇÇÑ À̸§À» »ç¿ëÇÏ½Ã¸é µË´Ï´Ù.

Ưº°ÇÑ°ÍÀº ¾øÁö¿ä??

  12.2.2 ·¹Äڵ尪 Ãâ·ÂÇϱâ.
 

		Set objCnn = Server.CreateObject("ADODB.Connection")
		strCnn = "Driver={Microsoft Excel Driver (*.xls)}; DBQ=c:\inetpub\wwwroot\Excel\test.xls"
		objCnn.Open strCnn
			
		strSQL = "SELECT * from test" 
		Set objRs = Server.CreateObject("ADODB.Recordset")
		objRs.Open strSQL, objCnn
		
		Array1 = objRs.getRows()	
		
		Response.write "Ä®·³¼ö:"&Ubound(Array1,1)&"<br>"
		Response.write "Çà¼ö:"&Ubound(Array1,2)


À§ÀÇ ¿¹Á¦¸¦ º¸µµ·Ï ÇÏ°Ú½À´Ï´Ù.
À§ÀÇ ¿¹Á¦¸¦ º¸¸é,,,,

·¹ÄÚµå¼Â °´Ã¼¸¦ ÀÌ¿ëÇؼ­ ExcelÀÇ °ªÀ» °¡Áö°í ¿É´Ï´Ù. ¿©±â¿¡¼­ getRows() ÇÔ¼ö¸¦ »ç¿ëÇϸé,

·¹ÄÚµåÀÇ °ªÀ» °¡Áö°í ¿Ã¼ö Àִµ¥¿ä. ¿©±â¿¡¼­ Array1 ¿¡ µé¾î°¡´Â °ªÀº 2Â÷¿ø ¹è¿­ÀÇ ÇüÅ·Î

µé¾î°¡°Ô µË´Ï´Ù.

±×·³, ¿©±â¿¡¼­ ¹è¿­ÀÇ Å©±â¸¦ ¾Ë¾ÆºÁ¾ß°ÚÁö¿ä??

Array1 = objRs.getRows()

Response.write "Ä®·³¼ö:"&Ubound(Array1,1)&"<br>"
Response.write "Çà¼ö:"&Ubound(Array1,2)

¿©±â¿¡¼­ Ubound ÇÔ¼ö´Â ¹è¿­ÀÇ °¡ÀåÅ« ÀÎÀÚ°ªÀ» ±¸ÇØÁÖ´Â ÇÔ¼öÀÔ´Ï´Ù.

°á°ú´Â -------
Ä÷³¼ö : 3
Çà¼ö : 18

À̶ó´Â °ªÀÌ ³ª¿À´Â±º¿ä.

Áï, Ä®·³¼ö´Â 4 °¡ µÇ°í, Çà¼ö´Â 19°¡ µÈ´Ù´Â °ÅÁö¿©?

ÀÌ°É Ç¥·Î ±×·Á º¸µµ·Ï ÇÏ°Ú½À´Ï´Ù.
 
Array1(0,0) Array1(0,1) Array1(0,2) Array1(0,3)
Array1(1,0) Array1(1,1) Array1(1,2) Array1(1,3)
...
Array1(16,0) Array1(16,1) Array1(16,2) Array1(16,3)
Array1(17,0) Array1(17,1) Array1(17,2) Array1(17,3)
   
ÀÌ¿Í °°ÀÌ °ªÀÌ µé¾î°¡°ÚÁö¿ä???

Âü, Áß¿äÇÑ°Å ÇÑ°¡Áö...
ºí·°À» ÁöÁ¤ÇÑ Excel ÆÄÀÏÀÇ Ã¹¹ø°Çà(À§¿¡¼­´Â A1..D1)À» Àоî¿ÀÁö ¾Ê½À´Ï´Ù ºí·°À»
µÎ¹ø° ÇàºÎÅÍ ÁöÁ¤Çؼ­ »ç¿ëÇϼ¼¿ä.

ÀÌÇØ°¡ °¡½Ã³ª¿©?

±×·³, Àüü ¿¢¼¿°ªÀ» ºÒ·¯¿Ã·Á¸é ¾îÄÉ ÇØ¾ß Çұ???
 
Array1 = objRs.getRows()	
		
		Response.Write "<table border=1>"
		For i=0 to Ubound(Array1,2)
			Response.Write "lt;tr>"
			For j=0 to Ubound(Array1,1)
				If Array1(j,i) <> "" Then
					Response.Write "lt;td>" & Array(j,i) & "</td>"
				Else
					Response.Write "lt;td> </td>"
				End If
			Next
			Response.Write "lt;/tr>"
		Next
		Response.Write "</table>"


  Á÷Á¢ µ¹·Áº¸¼¼¿ä.... Å×À̺íÀÌ ÂÞ¿í Ãâ·ÂµÇ´Â°ÍÀ» º¼¼ö ÀÖ½À´Ï´Ù.
 
  µµ¿òÀÌ µÇ¼Ì³ª¿©???
 
¡Ø Ȥ½Ã µµ¿òÀÌ µÇ¼Ì´Ù¸é ´ñ±Û¿¡ ÇѸ¶µð ³²°ÜÁÖ¼¼¿ä!
ÀÛ¼ºÀÚ   ºñ¹Ð¹øÈ£
ÀÚµ¿±Û ¹æÁö     (ÀÚµ¿±Û ¹æÁö ±â´ÉÀÔ´Ï´Ù.)
³»¿ë   ´ñ±Û´Þ±â 
À̸ÞÀÏ ¹®ÀÇ : cak0280@nate.com  
Copyright 2000 By ENTERSOFT.KR All Rights Reserved.