C# Excel’e Aktarma ( Excel Kurulu Olmadan )
SanalData’yı Google’da tercih edilen kaynak olarak ekleyinHerkese merhabalar,
Bugünki yazımızda bilgisayarınızda Excel kurulu olmadan Excel’e aktarma ve Excel oluşturmayı anlatıcam. Öncelikle burada OpenOffice (Epplus ) dll indiriyoruz.
1.Adım kütüphanemizi yüklüyoruz.
|
1 2 |
using OfficeOpenXml; using System.IO; |
2.Adım daha sonra herhangi event’a aşağıdaki kodları yazmanız yeterlidir.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
using (ExcelPackage excelPackage = new ExcelPackage()) { //Set some properties of the Excel document excelPackage.Workbook.Properties.Author = "VDWWD"; excelPackage.Workbook.Properties.Title = "Title of Document"; excelPackage.Workbook.Properties.Subject = "EPPlus demo export data"; excelPackage.Workbook.Properties.Created = DateTime.Now; //Create the WorkSheet ExcelWorksheet worksheet = excelPackage.Workbook.Worksheets.Add("Sheet 1"); //Add some text to cell A1 worksheet.Cells["A1"].Value = "My first EPPlus spreadsheet!"; worksheet.Column(1).Style.WrapText = true; //You could also use [line, column] notation: worksheet.Cells[1, 2].Value = "This is cell B1!"; //Save your file FileInfo fi = new FileInfo(@"File.xlsx"); excelPackage.SaveAs(fi); } |
Satır rengini değiştirmek için
|
1 |
worksheet.Row(4).Style.Font.Color.SetColor(Color.Red); |
Sütun genişliğini değiştirmek için
|
1 |
worksheet.Column(1).Width = 12; |
Satır arkaplanını değiştirme için
|
1 2 |
sheet.Cells["A2:G2"].Style.Fill.PatternType = ExcelFillStyle.Solid; sheet.Cells["A2:G2"].Style.Fill.BackgroundColor.SetColor(Color.Red); |
Eğer dosyayı direk download etmek isterseniz aşağıdaki kodu kullanabilirsiniz.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
using (ExcelPackage excelPackage = new ExcelPackage()) { //Set some properties of the Excel document excelPackage.Workbook.Properties.Author = "VDWWD"; excelPackage.Workbook.Properties.Title = "Title of Document"; excelPackage.Workbook.Properties.Subject = "EPPlus demo export data"; excelPackage.Workbook.Properties.Created = DateTime.Now; //Create the WorkSheet ExcelWorksheet worksheet = excelPackage.Workbook.Worksheets.Add("Sheet 1"); //Add some text to cell A1 worksheet.Cells["A1"].Value = "My first EPPlus spreadsheet!"; worksheet.Column(1).Style.WrapText = true; //You could also use [line, column] notation: worksheet.Cells[1, 2].Value = "This is cell B1!"; using (var memoryStream = new MemoryStream()) { Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; Response.AddHeader("content-disposition", "attachment; filename=dosya.xlsx"); excelPackage.SaveAs(memoryStream); memoryStream.WriteTo(Response.OutputStream); Response.Flush(); Response.End(); } } |
Günün zaman çizelgesi
Haber eklenme saatine göre sıralanır.
- Bugün
- Apple’ın metin bildirimli akıllı ev kamerası iddiası
- Apple, iPhone Duo için yeni Shot on iPhone kampanyasını başlattı
- Apple, Brüksel’de teknoloji lobisinin en aktif şirketlerinden
- Apple gündeminde iPhone Duo, AirPods 5 ve mesajla sipariş
- Armadin, yapay zekâ güvenliği için 255,5 milyon dolar topladı
- Lyft, sürücü sınıflandırması davasında 272,5 milyon dolar ödeyecek
- GrayKey, iPhone’un 72 saatlik güvenlik kilidini aşabilir
- Grok’un Maduro operasyonunu Trump’a önerdiği iddia edildi
- GTA 6’nın hava sistemi yerel yağış ve kasırgalar sunacak
- Apple Arcade kataloğuna beş yeni oyun eklendi
- Dün
- Audible, yapay zekâ destekli interaktif hikâyeleri duyurdu
- Kena: Scars of Kosmora’nın çıkışı 2027’ye ertelendi
- Google Gemini Live, küçük yazıları okuyabilecek
- Android Central ekibi işten çıkarıldı, yayınlar sürecek