How to Create a Document and Save it from a WinForm

F

Franco Vitali

I developed a WinForm application wich takes some
information from a database and I want to write some data
to an .XLS document. When I execute the code it throws an
exception:

An unhandled exception of
type 'System.Runtime.InteropServices.COMException'
occurred in Excel Test 01.exe

Additional information: Old format or invalid type
library.

My Code:

Microsoft.Office.Interop.Excel.Application ap = new
Microsoft.Office.Interop.Excel.ApplicationClass();

Microsoft.Office.Interop.Excel.Workbook wb =
ap.Workbooks.Add(Type.Missing);

ap.Workbooks.Close();

I need to know how can I start the Application class
properly. Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top