⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unit1.cpp

📁 EMS Advanced.Import.Component.Suite.v2.43
💻 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 + -