Åbne excelfil med VS 2008
Jeg har lavet et projekt i C# express 2008 som åbner en Excel fil fra c-drevetImidlertid kan projektet ikke køre på min nye bærbare computer Følgende fejlmeddelse kommer :
[System.Runtime.InteropServices.COMException] = {"Old format or invalid type library. (Exception from HRESULT: 0x80028018 (TYPE_E_INVDATAREAD))"}
Et testprojekt ses nedenfor.
using System;
using System.Text;
using System.Windows.Forms;
using Microsoft.Office.Interop.Excel;
using System.Reflection;
using Excel = Microsoft.Office.Interop.Excel;
namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
Excel.Application oXL = new Excel.Application();
oXL.Visible = true;
string fullName = @"c:\tidsreg_set.xls";
try
{
_Workbook oWB = (Excel._Workbook)(oXL.Workbooks.Open(fullName, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value));
}
catch (Exception Ex)
{
MessageBox.Show(Ex.Message.ToString());
}
}
}
}