0

Good morning, I'm trying to create Excel file in C#, I looked to the way to do it, and I found a tutorial, here is the code I tried:

        Microsoft.Office.Interop.Excel.Application excel;  
        Microsoft.Office.Interop.Excel.Workbook worKbooK;
        Microsoft.Office.Interop.Excel.Worksheet worksheet;  
        Microsoft.Office.Interop.Excel.Range celLrangE;

        excel = new Microsoft.Office.Interop.Excel.Application();
        excel.Visible = false;
        excel.DisplayAlerts = false;  

Well, I have this error on initializing the variable excel

COM object with CLSID '{00020819-0000-0000-C000-000000000046}' cannot be created due to the following error: Class not registered .

I searched for this error, what I found is solution to problems in cases, but none has the problem in Excel operations, so ... ?

PS: I'm creating an application for Windows Mobile 6.5, but I think it's supposed to work on it, if it works of course.

For the vote down hungers, well ... unleash yourselves, I can't stop you :) but believe me, I tried a lot, there's so many ways to create Excel files, but whatever I try, the same error is summoning, I think it's not the problem of library, or code, but something else I can't find.

Thanks in advance !

8
  • Just curious, but what "bit-ness" of Microsoft Office do you have installed? 32-bit or 64-bit? Also, I feel a bit silly for asking, but have you tried running Excel on the computer? Does it work? Commented Apr 4, 2017 at 14:11
  • Is that matters? because I use the application on the phone, when I press button (which has the press event, the code above), the error comes on the line of excel = .... , I'm using a Windows 7 64 bits with MS Visual Studio 2008, the phone is on Windows Mobile 6.5 Commented Apr 4, 2017 at 14:16
  • So, your code is attempting to interop with Microsoft Excel. Unless Microsoft Excel is installed and working on your device, how will your program inter-operate with it? Commented Apr 4, 2017 at 14:17
  • Possible duplicate of Class not registered error when creating Excel workbook in C# Commented Apr 4, 2017 at 14:19
  • Ah, you mean on the device? of course excel is installed on it, and works very well Commented Apr 4, 2017 at 14:19

1 Answer 1

0

Maybe use another Library: https://code.google.com/archive/p/excellibrary/

Found in this question: Create Excel (.XLS and .XLSX) file from C#

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

1 Comment

Thanks for the answer, this code works, but the file can't be opened, I tried the "open and repair", but it doesn't work too, I'm using Office 2013, But when I tried to open it with Office 2007 "Want you to read the file anyway" and it was opened, is there a way to create a normal correct file format? Anyway, thank you

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.