728x90
728x90
아래의 코드는 엑셀 프로그램을 열지 않고 직접 엑셀 파일로 저장하는 코드입니다.
유용하게 사용하세요.
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;
}
}
[펌] http://cbuilder.borlandforum.com/impboard/impboard.dll?action=read&db=bcb_tip&no=201
유용하게 사용하세요.
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;
}
}
[펌] http://cbuilder.borlandforum.com/impboard/impboard.dll?action=read&db=bcb_tip&no=201
728x90
'WORK > Sotfware' 카테고리의 다른 글
ini file로 저장,읽기 (0) | 2009.08.26 |
---|---|
BCB 가속기 [Compiler/Code insight 가속기 2.7 정식 버전.] (0) | 2009.08.26 |
RS232 통신 프로그램 - 3 (0) | 2009.08.24 |
IntToHex (0) | 2009.08.20 |
엑셀에서 특정 열의 타입을 지정해주는법 (0) | 2009.08.20 |
댓글