stav0815
2008-04-28, 14:06:07
Ich hab mal wieder ein Problem in C#. Ich will eine Excel Datei öffnen, habe dazu die Microsoft Office InterOp Assemblies installiert.
Leider gibt er mir immernoch den Fehler:
using Microsoft.Office.Core;
using Microsoft.Office.Interop.Excel;
gibt er mir den Fehler, dass dieser Assembly Verweis fehlt.
hier die komplette Klasse:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Reflection;
using System.Runtime.InteropServices;
using Microsoft.Office.Core;
using Microsoft.Office.Interop.Excel;
namespace DiagrammMapper
{
class datenquelle
{
private string path;
public string pfad()
{
OpenFileDialog file = new OpenFileDialog();
file.Filter = "Excel Dateien *.xls | *.xls";
if (file.ShowDialog() == DialogResult.OK)
{
path = file.FileName;
Excel.Application excel1 = new Excel.ApplicationClass();
excel1.Visible = true;
excel1.Workbook workbook = Excel.WorkbookOpen(path);
}
else
{
MessageBox.Show("Bitte Datei wählen!");
}
return path;
}
public string getpath()
{
return path;
}
}
}
Leider gibt er mir immernoch den Fehler:
using Microsoft.Office.Core;
using Microsoft.Office.Interop.Excel;
gibt er mir den Fehler, dass dieser Assembly Verweis fehlt.
hier die komplette Klasse:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Reflection;
using System.Runtime.InteropServices;
using Microsoft.Office.Core;
using Microsoft.Office.Interop.Excel;
namespace DiagrammMapper
{
class datenquelle
{
private string path;
public string pfad()
{
OpenFileDialog file = new OpenFileDialog();
file.Filter = "Excel Dateien *.xls | *.xls";
if (file.ShowDialog() == DialogResult.OK)
{
path = file.FileName;
Excel.Application excel1 = new Excel.ApplicationClass();
excel1.Visible = true;
excel1.Workbook workbook = Excel.WorkbookOpen(path);
}
else
{
MessageBox.Show("Bitte Datei wählen!");
}
return path;
}
public string getpath()
{
return path;
}
}
}