2

My original code:

    Excel.Application xlErrorApp;
    Excel.Workbook xlErrorWorkBook;
    Excel.Worksheet xlErrorWorkSheet;
    object misValue = System.Reflection.Missing.Value;
    xlErrorApp = new Excel.Application();
    xlErrorWorkBook = xlErrorApp.Workbooks.Add(); // -> error
    xlErrorWorkSheet = (Excel.Worksheet)xlErrorWorkBook.Worksheets.get_Item(1);

A get error in line 6.

Error Message:

Application Microsoft Excel can not open or save documents due to insufficient memory or disk space.

2
  • 3
    What is the error? Please be more specific. Commented Jan 9, 2013 at 9:51
  • 2
    I just tested your code and it runs fine (it needs tidied up though), what version of C# are you using, and could it be that you actually are low on RAM/disk space? Commented Jan 9, 2013 at 10:17

4 Answers 4

2

Which library are you using ?

I already said it but actually Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment.

I recommend you to look for a free library like Open Office XML or a not free library like Aspose.

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

1 Comment

It's impossible because users use only excel files on local machines.
1

Workbooks.Add() method from MSDN;

Parameters
Template
Type: System.Object

Optional Object. Determines how the new workbook is created. If this argument is a string specifying the name of an existing Microsoft Excel file, the new workbook is created with the specified file as a template. If this argument is a constant, the new workbook contains a single sheet of the specified type. Can be one of the following XlWBATemplate constants: xlWBATChart, xlWBATExcel4IntlMacroSheet, xlWBATExcel4MacroSheet, or xlWBATWorksheet. If this argument is omitted, Microsoft Excel creates a new workbook with a number of blank sheets (the number of sheets is set by the SheetsInNewWorkbook property).

If you try to create new workbook, try like this;

Workbook newWorkbook = this.Application.Workbooks.Add(missing);

1 Comment

Yes. At first i did like you wrote. It's not important in that case.
1

how about this:

Microsoft.Office.Interop.Excel.ApplicationClass excel = new Microsoft.Office.Interop.Excel.ApplicationClass();
Microsoft.Office.Interop.Excel.Workbook workbook = excel.Workbooks.Open(fileName, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
                Type.Missing, Type.Missing, Type.Missing, Type.Missing,
                Type.Missing, Type.Missing, Type.Missing, Type.Missing,
                Type.Missing, Type.Missing);

Comments

1

I'm sorry I could not find the link earlier. I used EPPlus supports. http://epplus.codeplex.com

Thanks for trying to help!

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.