|
-
March 6th, 2007, 04:15 PM
#1
Using Excel Online
Hi there,
I've created a web using visual studio and c#. What i'm trying to do is read in values from an excel file. I'm using the following code with no problem when i'm running it off the server on my laptop ie. my local host.
Code:
Excel.Application excelApp = new Excel.ApplicationClass();
Excel.Workbook newWorkbook = excelApp.Workbooks.Add(XlWBATemplate.xlWBATWorksheet);
string workbookPath = fuExcel.PostedFile.FileName;
Excel.Workbook excelWorkbook = excelApp.Workbooks.Open(workbookPath, 0, true, 5, "", "", true, Excel.XlPlatform.xlWindows, "", false, false, 0, true, false, false);
Excel.Sheets excelSheets = excelWorkbook.Worksheets;
string currentSheet = "Contacts";
Excel.Worksheet excelWorksheet = (Excel.Worksheet)excelSheets.get_Item(currentSheet);
int rows;
rows = excelWorksheet.UsedRange.Rows.Count;
Excel.Range excelCell = (Excel.Range)excelWorksheet.get_Range("A1", "CN" + rows);
object[,] cells = (object[,])excelCell.Value2;
However once it's hosted i'm getting the following error:
Code:
Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80040154.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Runtime.InteropServices.COMException: Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80040154.
Source Error:
Line 54: {
Line 55: //sets up an excel class called excelApp
Line 56: Excel.Application excelApp = new Excel.ApplicationClass();
Line 57: Excel.Workbook newWorkbook = excelApp.Workbooks.Add(XlWBATemplate.xlWBATWorksheet);
Line 58:
Is it at all possible to use this code on a hosted server? Could i maybe install excel on my hosted server?
Thanks,
Adrian.
-
March 6th, 2007, 05:38 PM
#2
Re: Using Excel Online
See whether the information in this link helps
-
March 6th, 2007, 07:49 PM
#3
Re: Using Excel Online
No i think that is a different problem.
Any other ideas would be greatly appreciated.
thanks,
Adrian.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|