C++Builder Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
C++빌더 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
메신저 프로젝트
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
볼랜드포럼 광고 모집

C++빌더 Q&A
C++Builder Programming Q&A
[12095] 엑섹을 사용하고 시퍼여 ㅠㅠ
[] 1299 읽음    2001-10-25 21:12
C빌더루 작업하다가 엑셀을 실행시키려 합니다.

Variant xlApp;
    if(xlApp.IsEmpty())
    {
        xlApp = Variant::CreateObject("Excel.Application");
    }
    xlApp.OlePropertySet("Visible", true);

    Variant xlBooks;
    xlBooks = xlApp.OlePropertyGet("Workbooks");
    xlBooks.OleProcedure("Add");             //파일을 새로 만들때
//    xlBooks.OleProcedure("Open", "1.xls"); //파일을 오픈할때

    Variant xlBook = xlBooks.OlePropertyGet("Item", 1);
    Variant xlSheets = xlBook.OlePropertyGet("Worksheets");
    Variant xlSheet = xlSheets.OlePropertyGet("Item", 1);

    Variant VRange;
    VRange = xlSheet.OlePropertyGet("Range", "A1");
    VRange.OlePropertySet("Value", "물량 산출");
    VRange = xlSheet.OlePropertyGet("Range", "A4");
    VRange.OlePropertySet("Value", "번호");
    VRange = xlSheet.OlePropertyGet("Range", "B4");
    VRange.OlePropertySet("Value", " => ");
    VRange = xlSheet.OlePropertyGet("Range", "A5");
    VRange.OlePropertySet("Value", "거리");
    VRange = xlSheet.OlePropertyGet("Range", "B5");
    VRange.OlePropertySet("Value", " => ");
    VRange = xlSheet.OlePropertyGet("Range", "A6");
    VRange.OlePropertySet("Value", "수");
    VRange = xlSheet.OlePropertyGet("Range", "B6");
    VRange.OlePropertySet("Value", " => ");
    VRange = xlSheet.OlePropertyGet("Range", "A8");
    VRange.OlePropertySet("Value", "관할");
    VRange = xlSheet.OlePropertyGet("Range", "B8");
    VRange.OlePropertySet("Value", " => ");
    VRange = xlSheet.OlePropertyGet("Range", "A10");
    VRange.OlePropertySet("Value", "합계");
    VRange = xlSheet.OlePropertyGet("Range", "A11");
    VRange.OlePropertySet("Value", "수");
    VRange = xlSheet.OlePropertyGet("Range", "B11");
    VRange.OlePropertySet("Value", " => ");
    VRange = xlSheet.OlePropertyGet("Range", "A12");
    VRange.OlePropertySet("Value", "거리");
    VRange = xlSheet.OlePropertyGet("Range", "B12");
    VRange.OlePropertySet("Value", " => ");
    VRange = xlSheet.OlePropertyGet("Range", "A13");
    VRange.OlePropertySet("Value", "총수");
    VRange = xlSheet.OlePropertyGet("Range", "B13");
    VRange.OlePropertySet("Value", " => ");

    xlSheet = xlApp.OlePropertyGet("ActiveSheet");

    int sum1= 0;
    int sum2= 0;
    long sum3= 0;
    int count = 0;
    for(int i = 3; i < 163; i++)
    {

        xlSheet.OlePropertySet("Cells", 4, i, i);
        xlSheet.OlePropertySet("Cells", 5, i, i+2);
        xlSheet.OlePropertySet("Cells", 6, i, i*2);
//          xlSheet.OlePropertyGet("Range","B5");
//          xlSheet.OlePropertySet("Offset", i , i);
//      xlSheet.OlepropertySet("FormulaR1C1", "=R[-1]c*2");
        sum1 += i;
        sum2 += (i+2);
        sum3 += (i*2);
        count++;
    }
    for(int j = 1; j <= count; j++)
    {
        xlSheet.OlePropertySet("Cells", 3, j+2, j);
    }
    VRange = xlSheet.OlePropertyGet("Range", "B8");
    VRange.OlePropertySet("Value", " => ");
    VRange = xlSheet.OlePropertyGet("Range", "C8");
    VRange.OlePropertySet("Value", " ");
    VRange = xlSheet.OlePropertyGet("Range", "C11");
    VRange.OlePropertySet("Value", sum1);
    VRange = xlSheet.OlePropertyGet("Range", "C12");
    VRange.OlePropertySet("Value", sum2);
    VRange = xlSheet.OlePropertyGet("Range", "C13");
    VRange.OlePropertySet("Value", sum3);

이런 식으루 하면 엑셀이 실행은 됩니다.
근데 여기서는 Cells를 사용하여 가로로는 값이 들어가는 데
세로로 값을 넣으려면 어떻게 해야하죠?
책을 찾아봐두 위에 것밖에 없네여 ㅠㅠ
Offset을 사용하는것 같은데 사용 방법을 모르겠어염
제발 좀 갈켜주세여

글구여 이걸 다른 프로그램에 연결해야 하는데 혼자 실행하면
잘 되는데 포함시키려 하면 에러가 납니다. 이런 에럽니다.


Project sdiapp.exe raseid exception class EAccessViolation with message 'Access violation
at sddress 00506F8B in module 'SDIAPP.EXE'. Read of sddress FFFFFFFF'.
Process stopped. Use Step or Run to continue.


이런 에러가 납니다. 도대체 혼자 돌땐 괜찮다가 왜 포함만 시키면 이러는지 모르겠습니다.
전 씨빌더 배운지 얼마 안된 초봅니다.
친절하구 자세하게 설명 제발 부탁드립니다.

꾸벅

+ -

관련 글 리스트
12095 엑섹을 사용하고 시퍼여 ㅠㅠ 1299 2001/10/25
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.