![]() |
| ||
| opening Excel 2003 file by c# Hello everyone First ,My name is Hashem I'm a beginner in c#, I'm trying to open Excel file(2003) but I get error at Open Function in the below code : (Old Format Or Invalid Library Of kinds (Exception from HRESULT: 0x80028018 (TYPE_E_INVDATAREAD)) Is there anybody can help me? where I use the following code that i have collected from many reference. The replies are valuable. public static Excel.Application ExlApp; public static Excel.Workbook ExlWrkBook; public static Excel.Worksheet ExlWrkSheet; Excel.Application ExcApp = new Excel.Application(); ExcApp.Visible = true; Excel.Workbook excelWorkbook = ExcApp.Workbooks.Open("D:\\Salary Calc.xls", 0, false, 5, "", "", true,Excel.XlPlatform.xlWindows, "\t", true, false, 0, false, true, true); Excel.Sheets ExcSheet = excelWorkbook.Worksheets; string currentSheet = "Sheet1"; Excel.Worksheet excelWorksheet = (Excel.Worksheet)ExcSheet.get_Item(currentSheet); Excel.Range excelCell = (Excel.Range)excelWorksheet.get_Range("A1", "A1"); |
| ||
| Re: opening Excel 2003 file by c# What's your Office SDK version? |
| ||
| Re: opening Excel 2003 file by c# And, more to the point, which version of excel did you add as a reference? |
| ||
| Re: opening Excel 2003 file by c# Hi I'm using Microsoft.Office.Interop |
| ||
| Re: opening Excel 2003 file by c# Hy, I did something like what you want in VC++ .NET Framework language. Just use the same classes in C# and it should work (there are some peaces of code that are usefull in my application but do no refer to Excell handling - just not care of). Please note that you have to install Excel 2003 and Windows XP or higher in the system where the application runs. private: System::Void button7_Click(System::Object^ sender, System::EventArgs^ e) { String^ XlsFile = String::Format("Z:\\Documenti\\Lavoro\\Fatture\\2009\\Fattura_02_AEM_marzo_09.xls"); String^ XlsSheet = String::Format("Milano, {0}/{1}/{2}", dateTimePicker1->Value.Day.ToString(), dateTimePicker1->Value.Month.ToString(), dateTimePicker1->Value.Year.ToString()); Excel::Application^ oXLApp; Excel::Workbook^ oXLWBook; //Excel::Sheets^ oXLSheet; //Excel::Worksheet^ oXLWSheet; Excel::Range^ rng; //starts Excel application oXLApp = (gcnew Excel::Application()); oXLApp->Visible = true; //opens the workbook of the file "XlsFile" oXLWBook = oXLApp->Workbooks->Open(XlsFile, 0, false, 5, "", "", true,Excel::XlPlatform::xlWindows, "\t", true, false, 0, false, true, true); //updates the range of sheet1, cell D4 rng = oXLApp->Range::get("D4","D4"); rng->Value2 = XlsSheet; } |
| ||
| Re: opening Excel 2003 file by c# Hi! Hope this code will resolve your problem. using System.Collections; |
| ||
| Re: opening Excel 2003 file by c# i did the same thing using javascript..may be that helps you.. here is the javascript code: <html> |
| ||
| Re: opening Excel 2003 file by c# Quote:
Nice code. You should post this one on Web forum. |
| ||
| Re: opening Excel 2003 file by c# i hope it helped you,if it did then mark it as solved... :) |
| All times are GMT -4. The time now is 1:16 am. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC