<%

'필요하신분 있으시면 사용하세요..^^

'[소스 시작]

%>

<Script Language="VBScript">

<!--

Option Explicit

'-----------------------------------------------------------------------------------

'   용도        :   그리드 제목 설정

'   파라미터    :   flexgrid1(그리드명:객체)

'   리턴        :   없음

'-----------------------------------------------------------------------------------

Sub fnSetGridTitle(fgSet)

    On Error Resume Next


    fgSet.Cols = 13

    fgSet.Rows = 0

    fgSet.MergeCells = 5


    '컬럼제목 -----------------------------------------------------------------------

    fgSet.AddItem "1" &_

            vbTab & "2" &_

            vbTab & "3" &_

            vbTab & "4" &_

            vbTab & "5" &_

            vbTab & "6" &_

            vbTab & "7" &_

            vbTab & "8" &_

            vbTab & "9"

    '컬럼제목 -----------------------------------------------------------------------


    If Err.number > 0 then                  ''' 에러처리

        MsgBox Err.description

    End If

End Sub


'---------------------

'☞ 조회 엑셀 정보 설정

'---------------------

Sub fnSearchResult()

    On Error Resume Next

    '컬럼내용 -----------------------------------------------------------------------

    flexgrid1.AddItem "a" & _

                        vbTab & "b" & _

                        vbTab & "c" & _

                        vbTab & "d" & _

                        vbTab & "e" & _

                        vbTab & "f" & _

                        vbTab & "g" & _

                        vbTab & "h" & _

                        vbTab & "i"

    '컬럼내용 -----------------------------------------------------------------------

End Sub


'--------------------------------------

'☞ 조회 Excel 파일로 저장하기

'--------------------------------------

Sub TransToExcel

    Dim szName

    Dim oExcelApp

   

    Call fnSetGridTitle(flexgrid1)

    Call fnSearchResult()


    On Error Resume Next


    szName = "C:\Result.xls"                                        '''Client 자동 저장 위치

    flexgrid1.SaveGrid szName ,4,true                             ''' 그리드의 내용을 메모리에 저장

             

    Set oExcelApp = CreateObject("Excel.Application")      ''' 엑셀객체 생성

    oExcelApp.Visible = True                                          ''' 엑셀화면을 보여줌


    Call oExcelApp.Workbooks.Open(szName,,true)         ''' 그리드의 내용이 엑셀로 저장



    ''' 타이틀 부분을 병합하는 부분 시작

    oExcelApp.Range("A1:A1").Select

    oExcelApp.Selection.HorizontalAlignment = 3

    oExcelApp.Range("B1:B1").Select

    oExcelApp.Selection.HorizontalAlignment = 3

    oExcelApp.Range("C1:C1").Select

    oExcelApp.Selection.HorizontalAlignment = 3

    oExcelApp.Range("D1:D1").Select

    oExcelApp.Selection.HorizontalAlignment = 3

    oExcelApp.Range("E1:E1").Select

    oExcelApp.Selection.HorizontalAlignment = 3

    oExcelApp.Range("F1:F1").Select

    oExcelApp.Selection.HorizontalAlignment = 3

    oExcelApp.Range("G1:G1").Select

    oExcelApp.Selection.HorizontalAlignment = 3

    oExcelApp.Range("H1:H1").Select

    oExcelApp.Selection.HorizontalAlignment = 3

    oExcelApp.Range("I1:I1").Select

    oExcelApp.Selection.HorizontalAlignment = 3

    oExcelApp.Range("J1:J1").Select

    oExcelApp.Selection.HorizontalAlignment = 3

    ''' 타이틀 부분을 병합하는 부분 끝


    'Msgbox "EXCEL 저장 OK"   '성공 메시지


    if Err.number <> 0 then                                  ''' 에러처리

        Msgbox Err.description

    end if



    Set oExcelApp = Nothing                             ''' 엑셀객체 자원반납

End Sub

//-->

</Script>


<a style="cursor:hand;"OnClick="TransToExcel()">엑셀변환</a>

<OBJECT id=flexgrid1

    style="Z-INDEX: 100; LEFT: 8px; WIDTH: 0px; POSITION: absolute; TOP: 0px; HEIGHT: 0px"

    classid=clsid:D76D712E-4A96-11D3-BD95-D296DC2DD072 VIEWASTEXT>

    <PARAM NAME="_cx" VALUE="15082">

    <PARAM NAME="_cy" VALUE="9896">

    <PARAM NAME="_ConvInfo" VALUE="1">

    <PARAM NAME="Appearance" VALUE="1">

    <PARAM NAME="BorderStyle" VALUE="1">

    <PARAM NAME="Enabled" VALUE="-1">

    <PARAM NAME="Font" VALUE="Times New Roman">

    <PARAM NAME="MousePointer" VALUE="0">

    <PARAM NAME="BackColor" VALUE="2147483653">

    <PARAM NAME="ForeColor" VALUE="2147483656">

    <PARAM NAME="BackColorFixed" VALUE="2147483663">

    <PARAM NAME="ForeColorFixed" VALUE="2147483666">

    <PARAM NAME="BackColorSel" VALUE="2147483661">

    <PARAM NAME="ForeColorSel" VALUE="2147483662">

    <PARAM NAME="BackColorBkg" VALUE="2147483660">

    <PARAM NAME="BackColorAlternate" VALUE="2147483653">

    <PARAM NAME="GridColor" VALUE="2147483663">

    <PARAM NAME="GridColorFixed" VALUE="2147483664">

    <PARAM NAME="TreeColor" VALUE="2147483664">

    <PARAM NAME="FloodColor" VALUE="192">

    <PARAM NAME="SheetBorder" VALUE="2147483654">

    <PARAM NAME="FocusRect" VALUE="1">

    <PARAM NAME="HighLight" VALUE="1">

    <PARAM NAME="AllowSelection" VALUE="-1">

    <PARAM NAME="AllowBigSelection" VALUE="-1">

    <PARAM NAME="AllowUserResizing" VALUE="0">

    <PARAM NAME="SelectionMode" VALUE="0">

    <PARAM NAME="GridLines" VALUE="1">

    <PARAM NAME="GridLinesFixed" VALUE="2">

    <PARAM NAME="GridLineWidth" VALUE="1">

    <PARAM NAME="Rows" VALUE="50">

    <PARAM NAME="Cols" VALUE="10">

    <PARAM NAME="FixedRows" VALUE="1">

    <PARAM NAME="FixedCols" VALUE="1">

    <PARAM NAME="RowHeightMin" VALUE="0">

    <PARAM NAME="RowHeightMax" VALUE="0">

    <PARAM NAME="ColWidthMin" VALUE="0">

    <PARAM NAME="ColWidthMax" VALUE="0">

    <PARAM NAME="ExtendLastCol" VALUE="0">

    <PARAM NAME="FormatString" VALUE="(Format)&#11;10&#11;1320&#9;9&#9;4&#9;&#9;&#9;&#9;0&#9;0&#9;&#9;0&#9;&#11;1320&#9;9&#9;4&#9;&#9;&#9;&#9;0&#9;0&#9;&#9;0&#9;&#11;1320&#9;9&#9;4&#9;&#9;&#9;&#9;0&#9;0&#9;&#9;0&#9;&#11;1320&#9;9&#9;4&#9;&#9;&#9;&#9;0&#9;0&#9;&#9;0&#9;&#11;1320&#9;9&#9;4&#9;&#9;&#9;&#9;0&#9;0&#9;&#9;0&#9;&#11;1320&#9;9&#9;4&#9;&#9;&#9;&#9;0&#9;0&#9;&#9;0&#9;&#11;1320&#9;9&#9;4&#9;&#9;&#9;&#9;0&#9;0&#9;&#9;0&#9;&#11;1320&#9;9&#9;4&#9;&#9;&#9;&#9;0&#9;0&#9;&#9;0&#9;&#11;1320&#9;9&#9;4&#9;&#9;&#9;&#9;0&#9;0&#9;&#9;0&#9;&#11;1320&#9;9&#9;9&#9;&#9;&#9;&#9;0&#9;0&#9;&#9;0&#9;&#11;(Text)&#11;">

    <PARAM NAME="ScrollTrack" VALUE="0">

    <PARAM NAME="ScrollBars" VALUE="3">

    <PARAM NAME="ScrollTips" VALUE="0">

    <PARAM NAME="MergeCells" VALUE="0">

    <PARAM NAME="MergeCompare" VALUE="0">

    <PARAM NAME="AutoResize" VALUE="-1">

    <PARAM NAME="AutoSizeMode" VALUE="0">

    <PARAM NAME="AutoSearch" VALUE="0">

    <PARAM NAME="AutoSearchDelay" VALUE="2">

    <PARAM NAME="MultiTotals" VALUE="-1">

    <PARAM NAME="SubtotalPosition" VALUE="1">

    <PARAM NAME="OutlineBar" VALUE="0">

    <PARAM NAME="OutlineCol" VALUE="0">

    <PARAM NAME="Ellipsis" VALUE="0">

    <PARAM NAME="ExplorerBar" VALUE="0">

    <PARAM NAME="PicturesOver" VALUE="0">

    <PARAM NAME="FillStyle" VALUE="0">

    <PARAM NAME="RightToLeft" VALUE="0">

    <PARAM NAME="PictureType" VALUE="0">

    <PARAM NAME="TabBehavior" VALUE="0">

    <PARAM NAME="OwnerDraw" VALUE="0">

    <PARAM NAME="Editable" VALUE="0">

    <PARAM NAME="ShowComboButton" VALUE="-1">

    <PARAM NAME="WordWrap" VALUE="0">

    <PARAM NAME="TextStyle" VALUE="0">

    <PARAM NAME="TextStyleFixed" VALUE="0">

    <PARAM NAME="OleDragMode" VALUE="0">

    <PARAM NAME="OleDropMode" VALUE="0">

    <PARAM NAME="DataMode" VALUE="0">

    <PARAM NAME="VirtualData" VALUE="-1">

    <PARAM NAME="DataMember" VALUE="">

    <PARAM NAME="ComboSearch" VALUE="3">

    <PARAM NAME="AutoSizeMouse" VALUE="-1">

    <PARAM NAME="FrozenRows" VALUE="0">

    <PARAM NAME="FrozenCols" VALUE="0">

    <PARAM NAME="AllowUserFreezing" VALUE="0">

    <PARAM NAME="BackColorFrozen" VALUE="0">

    <PARAM NAME="ForeColorFrozen" VALUE="0">

    <PARAM NAME="WallPaperAlignment" VALUE="9">

    </OBJECT>    

<%

'[소스 끝]

%>




참고자료 URL :

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnasdj01/html/asp0193.asp

+ Recent posts