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

C++빌더 팁&트릭
C++Builder Programming Tip&Tricks
[201] [테크닉] 엑셀을 실행하지 않고 엑셀 파일에 직접 저장하는 방법...
이의태 [bongsaja] 11474 읽음    2001-10-16 16:19
아래의 코드는 엑셀 프로그램을 열지 않고 직접 엑셀 파일로 저장하는 코드입니다.
유용하게 사용하세요.

WORD CXlsBof[6] = {0x809, 8, 0, 0x10, 0, 0};
WORD CXlsEof[2] = {0x0A, 0};
WORD CXlsLabel[6] = {0x204, 0, 0, 0, 0, 0};
WORD CXlsNumber[5] = {0x203, 14, 0, 0, 0};
WORD CXlsRk[5] = {0x27E, 10, 0, 0, 0};


void __fastcall XlsBeginStream(TStream *XlsStream, const WORD BuildNumber)
{
    CXlsBof[4] = BuildNumber;
    XlsStream->WriteBuffer(CXlsBof, sizeof(CXlsBof));
}

void __fastcall XlsEndStream(TStream *XlsStream)
{
    XlsStream->WriteBuffer(CXlsEof, sizeof(CXlsEof));
}

void __fastcall XlsWriteCellRk(TStream *XlsStream, const WORD ACol, const
WORD ARow, const
int AValue)
{
    CXlsRk[2] = ARow;
    CXlsRk[3] = ACol;
    XlsStream->WriteBuffer(CXlsRk, sizeof(CXlsRk));
    int V = ((AValue << 2) | 2);
    XlsStream->WriteBuffer(&V, 4);
}

void __fastcall XlsWriteCellNumber(TStream *XlsStream, const WORD ACol,
const WORD ARow, const double AValue)
{
    CXlsNumber[2] = ARow;
    CXlsNumber[3] = ACol;
    XlsStream->WriteBuffer(CXlsNumber, sizeof(CXlsNumber));
    XlsStream->WriteBuffer(&AValue, 8);
}

void __fastcall XlsWriteCellLabel(TStream *XlsStream, const WORD ACol, const
WORD ARow, const AnsiString AValue)
{
    WORD L = AValue.Length();
    CXlsLabel[1] = 8 + L;
    CXlsLabel[2] = ARow;
    CXlsLabel[3] = ACol;
    CXlsLabel[5] = L;
    XlsStream->WriteBuffer(CXlsLabel, sizeof(CXlsLabel));
    XlsStream->WriteBuffer(AValue.c_str(), L);
}

void __fastcall TForm1::Button1Click(TObject *Sender)
{
    TFileStream *FStream = new TFileStream("c:\\e.xls", fmCreate);
    try
    {
        XlsBeginStream(FStream, 0);
        for(int i = 0; i < 100; i++)
        {
            for(int j = 0; j < 100; j++)
                XlsWriteCellNumber(FStream, i, j, 34.34);
        }
        XlsEndStream(FStream);
    }
    __finally
    {
        delete FStream;
    }
}


+ -

관련 글 리스트
201 [테크닉] 엑셀을 실행하지 않고 엑셀 파일에 직접 저장하는 방법... 이의태 11474 2001/10/16
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.