?? unit1.cpp
字號:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "QImport2"
#pragma link "QImport2XLS"
#pragma resource "*.dfm"
TForm1 *Form1;
AnsiString arCountry[5][18];
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
QImportXLS1->FileName = ExtractFilePath(Application->ExeName) + "..\\..\\data\\country.xls";
StringGrid1->Cells[0][0] = "Name";
StringGrid1->Cells[1][0] = "Capital";
StringGrid1->Cells[2][0] = "Continent";
StringGrid1->Cells[3][0] = "Area";
StringGrid1->Cells[4][0] = "Population";
StringGrid1->ColWidths[0] = 125;
StringGrid1->ColWidths[1] = 70;
StringGrid1->ColWidths[2] = 80;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::QImportXLS1BeforeImport(TObject *Sender)
{
for (int i = 0; i <= 4; i++)
for (int j = 0; j <= 17; j++)
arCountry[i][j] = EmptyStr;
FCounter = 0;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::QImportXLS1UserDefinedImport(TObject *Sender,
TQImportRow *Row)
{
for (int i = 0; i <= Row->Count - 1; i++)
arCountry[i][FCounter] = Row->Items[i]->Value;
FCounter++;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
QImportXLS1->Execute();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
for (int i = 0; i <= 4; i++)
for (int j = 1; j <= 18; j++)
StringGrid1->Cells[i][j] = EmptyStr;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::QImportXLS1AfterImport(TObject *Sender)
{
for (int i = 0; i <= 4; i++)
for (int j = 0; j <= 17; j++)
StringGrid1->Cells[i][j + 1] = arCountry[i][j];
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -