Kirish Asosoiy qisim


C# 1 using Excel = Microsoft.Office.Interop.Excel


Download 0.76 Mb.
bet6/14
Sana28.12.2022
Hajmi0.76 Mb.
#1014407
1   2   3   4   5   6   7   8   9   ...   14
Bog'liq
8888 (Автосохраненный)

C#
1 using Excel = Microsoft.Office.Interop.Excel;
Endi biz Excel ob'ektini e'lon qilishimiz, parametrlarni o'rnatishimiz va ishga kirishishimiz kerak.
C#
1 Arizani e'lon qilish
2 Excel.Application ilovasi = yangi Excel.Application
3 {
4 // Excelni ko'rsatish
5 Visible= true,
6 //Ish kitobidagi varaqlar soni
7 SheetsInNewWorkbook = 2
8 };
9 //Ish kitobini qo'shish
10 Excel.Workbook sheet = app. Workbooks.Add (Type.Missing);
11 //Xabar oynalarini ko'rsatishni o'chirish
12 app.DisplayAlerts =false;
13 //Hujjatning birinchi varag'ini oling (hisoblash 1 dan boshlanadi)
14 Excel.Worksheet = (Excel.Worksheet)app.Worksheets.get_Item(1);
15 // varaq nomi (pastki yorliqlar)
16 sheet.Name = "Ism 32 belgidan oshmasligi kerak";‌‌

Kataklarni to'ldirishga misol:
C#
1 //kataklarni to’ldirishga misollar №1
2 for (int i = 1; i <= 9; i++)
3 {
4 for (int j = 1; j < 9; j++)
5 sheet.Cells[i, j] = String.Format("nookery {0} {1}", i, j);
6 }
7 //Misol №2
8 sheet.Range["A1"].Value = " Misol №2";
9 // Misol №3
10 sheet.get_Range("A2").Value2 = " Misol №3";

Bir qator katakchalarni qo'lga olish:
C#
1 //bir qator katakchalarni yozib olish usuli №1
2 Excel.Range r1 = sheet.Cells[1, 1];
3 Excel.Range r2 = sheet.Cells[9, 9];
4 Excel.Range range1 = sheet.get_Range(r1, r2);
5 // bir qator katakchalarni yozib olish usuli №2
6 Excel.Range range2 = sheet.get_Range("A1","H9" );


Dizayn, shrift, o'lcham, rang, qalinlik.
C#
1 //Diapazon uchun shrift

Download 0.76 Mb.

Do'stlaringiz bilan baham:
1   2   3   4   5   6   7   8   9   ...   14




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling