Mehmet Fatih

Mehmet Fatih

  • 858
  • 939
  • 41.1k

Open Excel File

Jun 10 2023 10:41 AM

I added Microsoft.Office.Interop.Excel reference to my project. My codes are working in other project very well. But the same codes are not working in the new project. It opens an empty excel file. What is the reason in your opinion?

using System;
using System.ComponentModel;
using System.Data;
using System.Data.OleDb;
using System.IO;
using System.Threading;
using System.Windows.Forms;
using Excel = Microsoft.Office.Interop.Excel;
private void Button1_Click(object sender, EventArgs e)
        {
            var mySheet = Path.Combine(Directory.GetCurrentDirectory(), "Excel/Personelaktar.xlsx");
            Excel.Application xlApp = new Excel.Application()
            {
                Visible = true
            };
            if (xlApp == null)
            {
                MessageBox.Show("Excel dosyasi yüklenmemis!");
                return;
            }
        }

 


Answers (3)