Assalomu alaykum, yordam.uz saytimizga xush kelibsiz.
Bu saytda o`zingizni qiziqtirgan savollarga javob olishingiz va o`z sohangiz bo`yicha savollarga javob berishingiz mumkin. Bizning Oilamizga a'zo bo`lganingiz uchun chuqur Minnatdorchilik bildiramiz !!!

C++ Builder 6 Excelga export qilishga yordam kerak

+1 ovoz
173 marta ko‘rilgan
so‘radi 20 dekabr, 18 Akmal Abdullayev (123 bal)
C++ Builder 6 dasturlash muhitida tuzgan dasturimda ADOTable componentasi orqali excelga export qilinganimda faqat ma'lumotlar chiqayapti. Shu ma'lumotning jadval chiziqlarini chizish kerak. Iloji bo'lsa C++ da kod kerak edi.

1 ta javob

0 ovoz
javob berdi 25 dekabr, 18 E-soft (698 bal)

Kod:

void __fastcall TBaza::ExcelClick(TObject *Sender)
{
try
{app=CreateOleObject("Excel.Application");}
catch(EDatabaseError&)
{MessageDlg("Excelga ulanib bo'lmayapti",mtError,TMsgDlgButtons()<<mbOK,0);}
app.OlePropertySet("SheetsInNewWorkbook", 4);
books=app.OlePropertyGet("Workbooks");
books.OleProcedure("Add");
book= books.OlePropertyGet("Item", 1); 
sheets=book.OlePropertyGet("Worksheets"); 
sheet=sheets.OlePropertyGet("Item", 1); 
sheet.OlePropertySet("Name", "Ma'lumotlar bazasi");
cell=sheet.OlePropertyGet("Cells").OlePropertyGet("Item",1,6);
cell.OlePropertySet("Value", "Ma'lumotlar bazasi");
cell.OlePropertyGet("Font").
         OlePropertySet("Bold",true);
cell.OlePropertyGet("Font").
         OlePropertySet("Italic",true);
cell.OlePropertyGet("Font").OlePropertySet("Name","Times New Roman");
cell.OlePropertyGet("Font").OlePropertySet("Color",clBlue);
cell.OlePropertyGet("Font").OlePropertySet("Size",20);
cell=sheet.OlePropertyGet("Range","A1:N1");
cell.OleProcedure("Merge");
cell.OlePropertyGet("Borders",9).
            OlePropertySet("LineStyle",1);
cell.OlePropertyGet("Borders",9).
            OlePropertySet("Weight",2);
cell.OlePropertyGet("Borders",9).
            OlePropertySet("ColorIndex",1);
cell.OlePropertySet("HorizontalAlignment",-4108);
cell.OlePropertySet("VerticalAlignment",-4108);
//---------------------------------------------------------------------------
cell=sheet.OlePropertyGet("Cells").OlePropertyGet("Item",2,1);
cell.OlePropertySet("Value", "T/r");
cell.OlePropertySet("ColumnWidth", 5);
cell.OlePropertyGet("Font").
         OlePropertySet("Bold",true);
cell.OlePropertyGet("Borders",9).
            OlePropertySet("LineStyle",1);
cell.OlePropertyGet("Borders",9).
            OlePropertySet("Weight",2);
cell.OlePropertyGet("Borders",9).
            OlePropertySet("ColorIndex",1);
cell.OlePropertyGet("Borders",10).
            OlePropertySet("LineStyle",1);
cell.OlePropertyGet("Borders",10).
            OlePropertySet("Weight",2);
cell.OlePropertyGet("Borders",10).
            OlePropertySet("ColorIndex",1);
cell.OlePropertySet("HorizontalAlignment",-4108);
cell.OlePropertySet("VerticalAlignment",-4108);
cell.OlePropertyGet("Font").OlePropertySet("Name","Times New Roman");
//----------------------------------------------------------------------------------

izoh qoldirdi 25 dekabr, 18 E-soft (698 bal)
cell=sheet.OlePropertyGet("Cells").OlePropertyGet("Item",2,2);
cell.OlePropertySet("Value", "Familiyasi");
Font(); Setka();
//---------------------------------------------------------------------------
cell=sheet.OlePropertyGet("Cells").OlePropertyGet("Item",2,3);
cell.OlePropertySet("Value", "Ismi");
Font(); Setka();
//---------------------------------------------------------------------------
cell=sheet.OlePropertyGet("Cells").OlePropertyGet("Item",2,4);
cell.OlePropertySet("Value", "Sharfi");
Font(); Setka();
//---------------------------------------------------------------------------
cell=sheet.OlePropertyGet("Cells").OlePropertyGet("Item",2,5);
cell.OlePropertySet("Value", "Sinfi");
Font(); Setka();
//---------------------------------------------------------------------------
cell=sheet.OlePropertyGet("Cells").OlePropertyGet("Item",2,6);
cell.OlePropertySet("Value", "Tug'ilgan yili");
Font(); Setka();
//---------------------------------------------------------------------------
cell=sheet.OlePropertyGet("Cells").OlePropertyGet("Item",2,7);
cell.OlePropertySet("Value", "Jinsi");
Font(); Setka();
//---------------------------------------------------------------------------
cell=sheet.OlePropertyGet("Cells").OlePropertyGet("Item",2,8);
cell.OlePropertySet("Value", "Manzili");
Font(); Setka();
//---------------------------------------------------------------------------
cell=sheet.OlePropertyGet("Cells").OlePropertyGet("Item",2,9);
cell.OlePropertySet("Value", "Otasining FISH");
Font(); Setka();
//---------------------------------------------------------------------------
cell=sheet.OlePropertyGet("Cells").OlePropertyGet("Item",2,10);
cell.OlePropertySet("Value", "Onasining FISH");
Font(); Setka();
//---------------------------------------------------------------------------
cell=sheet.OlePropertyGet("Cells").OlePropertyGet("Item",2,11);
cell.OlePropertySet("Value", "Otasining ish joyi");
Font(); Setka();
//---------------------------------------------------------------------------
cell=sheet.OlePropertyGet("Cells").OlePropertyGet("Item",2,12);
cell.OlePropertySet("Value", "Onasining ish joyi");
Font(); Setka();
//---------------------------------------------------------------------------
cell=sheet.OlePropertyGet("Cells").OlePropertyGet("Item",2,13);
cell.OlePropertySet("Value", "Guvohnoma seriyasi");
Font(); Setka();
//---------------------------------------------------------------------------
cell=sheet.OlePropertyGet("Cells").OlePropertyGet("Item",2,14);
cell.OlePropertySet("Value", "Guvohnoma raqami");
Font(); Setka();
//---------------------------------------------------------------------------
MBazaTable->First();
for(int i=1;i<=MBazaTable->RecordCount;i++)
{cell=sheet.OlePropertyGet("Cells").OlePropertyGet("Item",i+2,1);
Font1(); Setka();
cell.OlePropertySet("Value", MBazaTable->FieldByName("Tr")->AsVariant);
//---------------------------------------------------------------------------
cell=sheet.OlePropertyGet("Cells").OlePropertyGet("Item",i+2,2);
Font1(); Setka();
cell.OlePropertySet("Value", MBazaTable->FieldByName("Familiyasi")->AsVariant);
//---------------------------------------------------------------------------
cell=sheet.OlePropertyGet("Cells").OlePropertyGet("Item",i+2,3);
Font1(); Setka();
cell.OlePropertySet("Value", MBazaTable->FieldByName("Ismi")->AsVariant);
//---------------------------------------------------------------------------
cell=sheet.OlePropertyGet("Cells").OlePropertyGet("Item",i+2,4);
Font1(); Setka();
cell.OlePropertySet("Value", MBazaTable->FieldByName("Sharfi")->AsVariant);
//---------------------------------------------------------------------------
cell=sheet.OlePropertyGet("Cells").OlePropertyGet("Item",i+2,5);
Font1(); Setka();
cell.OlePropertySet("Value", MBazaTable->FieldByName("Sinfi")->AsVariant);
//---------------------------------------------------------------------------
cell=sheet.OlePropertyGet("Cells").OlePropertyGet("Item",i+2,6);
Font1();Setka();
cell.OlePropertySet("Value", MBazaTable->FieldByName("Tug'ilgan yili")->AsVariant);
//---------------------------------------------------------------------------
izoh qoldirdi 25 dekabr, 18 E-soft (698 bal)
tahrirlandi 25 dekabr, 18 E-soft
cell=sheet.OlePropertyGet("Cells").OlePropertyGet("Item",i+2,7);
Font1(); Setka();
cell.OlePropertySet("Value", MBazaTable->FieldByName("Jinsi")->AsVariant);
//---------------------------------------------------------------------------
cell=sheet.OlePropertyGet("Cells").OlePropertyGet("Item",i+2,8);
Font1(); Setka();
cell.OlePropertySet("Value", MBazaTable->FieldByName("Manzili")->AsVariant);
//---------------------------------------------------------------------------
cell=sheet.OlePropertyGet("Cells").OlePropertyGet("Item",i+2,9);
Font1();Setka();
cell.OlePropertySet("Value", MBazaTable->FieldByName("Otasining FISH")->AsVariant);
//---------------------------------------------------------------------------
cell=sheet.OlePropertyGet("Cells").OlePropertyGet("Item",i+2,10);
Font1();Setka();
cell.OlePropertySet("Value", MBazaTable->FieldByName("Onasining FISH")->AsVariant);
//---------------------------------------------------------------------------
cell=sheet.OlePropertyGet("Cells").OlePropertyGet("Item",i+2,11);
Font1();Setka();
cell.OlePropertySet("Value", MBazaTable->FieldByName("Otasining ish joyi")->AsVariant);
//---------------------------------------------------------------------------
cell=sheet.OlePropertyGet("Cells").OlePropertyGet("Item",i+2,12);
Font1(); Setka();
cell.OlePropertySet("Value", MBazaTable->FieldByName("Onasining ish joyi")->AsVariant);
//---------------------------------------------------------------------------
cell=sheet.OlePropertyGet("Cells").OlePropertyGet("Item",i+2,13);
Font1(); Setka();
cell.OlePropertySet("Value", MBazaTable->FieldByName("Guvohnoma seriyasi")->AsVariant);
//---------------------------------------------------------------------------
cell=sheet.OlePropertyGet("Cells").OlePropertyGet("Item",i+2,14);
Font1();Setka();
cell.OlePropertySet("Value", MBazaTable->FieldByName("Guvohnoma raqami")->AsVariant);
//---------------------------------------------------------------------------
MBazaTable->Next();}
app.OlePropertySet("Visible", true);
}
//---------------------------------------------------------------------------
void __fastcall TBaza::Font()
{
cell.OlePropertySet("ColumnWidth", 20);
cell.OlePropertySet("HorizontalAlignment",-4108);
cell.OlePropertySet("VerticalAlignment",-4108);
cell.OlePropertyGet("Font").OlePropertySet("Name","Times New Roman");
cell.OlePropertyGet("Font").
         OlePropertySet("Bold",true);
}
//---------------------------------------------------------------------------
void __fastcall TBaza::Font1()
{
cell.OlePropertyGet("Font").OlePropertySet("Name","Times New Roman");
cell.OlePropertySet("HorizontalAlignment",-4108);
cell.OlePropertySet("VerticalAlignment",-4108);
}
//--------------------------------------------------------------------------
void __fastcall TBaza::Setka()
{
cell.OlePropertyGet("Borders",9).
            OlePropertySet("LineStyle",1);
cell.OlePropertyGet("Borders",9).
            OlePropertySet("Weight",2);
cell.OlePropertyGet("Borders",9).
            OlePropertySet("ColorIndex",1);
cell.OlePropertyGet("Borders",10).
            OlePropertySet("LineStyle",1);
cell.OlePropertyGet("Borders",10).
            OlePropertySet("Weight",2);
cell.OlePropertyGet("Borders",10).
            OlePropertySet("ColorIndex",1);
}
//--------------------------------------------------------------------------

Bularning hammasi C++ builder 6da ishlaydi

Assalomu alaykum, yordam.uz saytimizga xush kelibsiz.

Bu saytda o`zingizni qiziqtirgan savollarga javob olishingiz va o`z sohangiz bo`yicha savollarga javob berishingiz mumkin.

Bizning Oilamizga a'zo bo`lganingiz uchun chuqur Minnatdorchilik bildiramiz !!!

Telegram kanal YordamUzRss

...