1

I am tring to implement the below tutorial to create an excel document

http://www.codeproject.com/Articles/20228/Using-C-to-Create-an-Excel-Document

However I recieved the below error

CS1748: Cannot find the interop type that matches the embedded interop type 'Microsoft.Office.Interop.Excel.Application'. Are you missing an assembly reference?

After that I tried to set Embed interop types to false,

This time I recieve below error

CS0234: The type or namespace name 'Office' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)

However Microsoft.Office.Core reference is already added.

2 Answers 2

3

If I may suggest you something, now that you are using c#, try to use this libraries instead, it is the newest format and much easier to work with:

http://www.microsoft.com/en-us/download/details.aspx?id=5124

let me know if it helps,

Sign up to request clarification or add additional context in comments.

1 Comment

Jorge brings up a great option. Using the OOXML SDK will allow you to generate .xlsx files instead of .xls files. However if you are open to using a library then I would suggest OfficeWriter officewriter.com it supports both .xls and .xlsx file formats, its written in .NET so you can easy use it in C# with and managed code, and best of all it doesn’t require Microsoft Office at all to generate the files so you do not have to worry about having the correct interop assemblies on your machine. – Disclaimer I am one of the developers on this product.
1

Did you add the reference as explained in the tutorial ? I remember using the same tutorial but I think what I added had a different name, basically I added the one thing that said Microsoft and Excel in it.. (it's probably not the one you mentioned)

And another thing they don't tell you (because they didn't have that problem at that time I guess) is a couple of lines to fix some errors.. Add this before you start making the excel table

System.Globalization.CultureInfo Oldci = System.Threading.Thread.CurrentThread.CurrentCulture;
System.Threading.Thread.CurrentThread.CurrentCulture = new CultureInfo("en-us");

and this line after you have finished working with the table.

System.Threading.Thread.CurrentThread.CurrentCulture = Oldci;

This saved me when I needed to create excel files.. and I had a bunch of problems with the tutorials online.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.