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
[19695] DBGrid의 내용을 엑셀로 저장할려구 하는데여..델마당에서 기초 샘플을 구해서 돌려 봤습니다..근데 궁금한
시후 [] 1255 읽음    2002-06-28 17:21
DBGrid의 내용을 엑셀로 저장할려구 하는데여..
지금 델마당에서 구한 기초 샘플로 개념을 잡고 있는데여..소스를 올려보면여..
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Variant xlApp, xlBooks, xlBook, xlSheets, xlSheet, VRange;

        try
        {
                xlApp = CreateOleObject("excel.Application");
        }
        catch (Exception &exception)
        {
                Application->MessageBox("Excel 에러", "에러", MB_OK);
                return;
        }

        if(SaveDialog1->Execute() == false) return;
        if(FileExists(SaveDialog1->FileName))
        {
                Application->MessageBox("파일이 있습니다", "에러", MB_OK);
                return;
        }

        xlApp.OlePropertySet("DisplayAlerts", false);
        xlApp.OlePropertySet("Visible", false);
        xlBooks = xlApp.OlePropertyGet("Workbooks");
        xlBooks.OleProcedure("Add");
        xlBook = xlBooks.OlePropertyGet("Item", 1);
        xlSheets = xlBook.OlePropertyGet("Worksheets");
        xlSheet = xlSheets.OlePropertyGet("Item", 1);
        xlSheet.OlePropertySet("Name", String("출력자료") );
        VRange = xlSheet.OlePropertyGet("Range", "A3");
        VRange.OlePropertySet("Value", "StyleNo");
        VRange = xlSheet.OlePropertyGet("Range", "B3");
        VRange.OlePropertySet("Value", "Col");
        VRange = xlSheet.OlePropertyGet("Range", "C3");
        VRange.OlePropertySet("Value", "Siz");
        VRange = xlSheet.OlePropertyGet("Range", "D3");
        VRange.OlePropertySet("Value", "수량");
        VRange = xlSheet.OlePropertyGet("Range", "E3");
        VRange.OlePropertySet("Value", "단가");
        VRange = xlSheet.OlePropertyGet("Range", "A4");
        VRange.OlePropertySet("Value", "ING001");
        VRange = xlSheet.OlePropertyGet("Range", "B4");
        VRange.OlePropertySet("Value", "BK");
        VRange = xlSheet.OlePropertyGet("Range", "C4");
        VRange.OlePropertySet("Value", "'44");
        VRange = xlSheet.OlePropertyGet("Range", "D4");
        VRange.OlePropertySet("Value", 1234);
        VRange = xlSheet.OlePropertyGet("Range", "E4");
        VRange.OlePropertySet("Value", 2223344);

        xlBook.OleProcedure("SaveAs", SaveDialog1->FileName);
        xlApp.OleProcedure("Quit");
}
//---------------------------------------------------------------------------

위의 코드에서 궁금한게여..분명 저장은 되는데 엑셀을 띄워서 불러오면 불러오지를 못하거든요.
그리고 세로 방향이 아니라 가로방향으로(A4 기준) 저장이 되야 하거든요..
엑셀을 좀더 정밀하게 제어를 하고 싶거든요..고수님들 도와 주세염..어케 해야 하져..

+ -

관련 글 리스트
19695 DBGrid의 내용을 엑셀로 저장할려구 하는데여..델마당에서 기초 샘플을 구해서 돌려 봤습니다..근데 궁금한 시후 1255 2002/06/28
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.