Discussion:
Excel templates (Old format or invalid type library.)
(too old to reply)
Filip De Backer
2005-09-06 10:26:10 UTC
Permalink
Raw Message
Hi everybody,

Microsoft.Office.Interop.Excel.Workbook ExcelWorkbook =
ExcelWorkbooks.Add(Microsoft.Office.Interop.Excel.XlWBATemplate.xlWBATWorksheet);

this gives me the following error:
Old format or invalid type library. (Exception from HRESULT: 0x80028018
(TYPE_E_INVDATAREAD))

I've reinstalled my PC with Windows XP, Office XP and VS.net 2005 beta 2.
Even with the VS.NET 2003, it doens't work

The code worked with my Windows 2000 installation and VS.net 2003.

What is the problem here?

thanks!!

Filip
Vis
2005-09-07 09:29:05 UTC
Permalink
Raw Message
Try this:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odc_vsto2003_ta/html/odc_VSTMultCR.asp
Post by Filip De Backer
Hi everybody,
Microsoft.Office.Interop.Excel.Workbook ExcelWorkbook =
ExcelWorkbooks.Add(Microsoft.Office.Interop.Excel.XlWBATemplate.xlWBATWorksheet);
Old format or invalid type library. (Exception from HRESULT: 0x80028018
(TYPE_E_INVDATAREAD))
I've reinstalled my PC with Windows XP, Office XP and VS.net 2005 beta 2.
Even with the VS.NET 2003, it doens't work
The code worked with my Windows 2000 installation and VS.net 2003.
What is the problem here?
thanks!!
Filip
Marwa
2008-02-21 09:21:51 UTC
Permalink
Raw Message
I have a similar problem

Dear all
I build a new application using c#.net2005 to read excel file I write the following code but it gives me a run time error
((Old format or invalid type library. (Exception from HRESULT: 0x80028018 (TYPE_E_INVDATAREAD))

can any one help me

using System;
using System.Reflection; // For Missing.Value and BindingFlags
using System.Runtime.InteropServices;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Resources;
using Microsoft.Office.Core;
using System.IO;
using System.Configuration;
using System.Data.SqlClient;
using Excel;

namespace ReadExcelFiletest
{
public partial class Form1 : Form
{
private Excel.Application ExcelObj = null;
private string strConn = "";
private string[,] myArray = new string[5000, 2];
private int myarrayindex;
public Form1()
{
InitializeComponent();
}

private void btnBrowse_Click(object sender, EventArgs e)
{
openFileDialog1.ShowDialog();
this.txtLocation.Text = openFileDialog1.FileName;
}

private void btnUpdate_Click(object sender, EventArgs e)
{
// string Path = @"c:\test.xls";
string MyPath = this.txtLocation.Text.Trim().ToString();

// initialize the Excel Application class
Excel.ApplicationClass app = new ApplicationClass();
// create the workbook object by opening the excel file.
Excel.Workbook workBook = app.Workbooks.OpenMyPath , 0, true, 5, "", "", true, Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
// get the active worksheet using sheet name or active sheet
Excel.Worksheet workSheet = (Excel.Worksheet)workBook.ActiveSheet;
int index = 0;
// This row,column index should be changed as per your need.
// i.e. which cell in the excel you are interesting to read.
object rowIndex = 1;
object colIndex1 = 1;
object colIndex2 = 2;
object colIndex3 = 3;
myarrayindex = 0;

try
{
while (((Excel.Range)workSheet.Cells[rowIndex, colIndex1]).Value2 != null)
{

rowIndex = index + 1;
string PartNO = ((Excel.Range)workSheet.Cells[rowIndex, colIndex1]).Value2.ToString();
string Price = ((Excel.Range)workSheet.Cells[rowIndex, colIndex2]).Value2.ToString();

myArray[myarrayindex, 0] = PartNO;
myArray[myarrayindex, 1] = Price;
ListViewItem lvi = new ListViewItem();
lvi.Text = Convert.ToString(index + 1);
lvi.SubItems.Add(PartNO);
lvi.SubItems.Add(Price);
this.listView1.Items.Add(lvi);


myarrayindex++;
index++;

}
}
catch (Exception ex)
{
app.Quit();

}
}
}


From http://www.developmentnow.com/g/21_2005_9_0_0_592882/Excel-templates-Old-format-or-invalid-type-library-.ht

Posted via DevelopmentNow.com Group
http://www.developmentnow.com
ivan
2009-12-04 00:15:45 UTC
Permalink
Raw Message
Hi all,
nice to have an old post here, because I have a similar problem with Marwa.

I build a new application using c#.net2005 to read excel file I write the following code but it gives me a run time error
((Old format or invalid type library. (Exception from HRESULT: 0x80028018 (TYPE_E_INVDATAREAD))

can any one help me?

Suggestion from Vis to try this:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odc_...

really help me out from this problem. thank you Vis.

I find out that the problem is around the formatting issue:

If your code calls Microsoft Office Excel using a CultureInfo for which no matching MUI Packs are installed on an end user's computer, the code does not work as expected; run-time errors are generated, but Excel does not show them to the user. You must explicitly write code to handle the errors, using an exception-handling technique appropriate for your code language.

If the locale selected in an end user's regional settings does not match the installed language of Office, Excel attempts to locate the correct MUI Pack. If it does not find it, the following errors might be raised when the code calls certain methods and properties:

Exception from HRESULT: 0x800A03EC.
-or-

Old format or invalid type library.
To correct this problem for users that do not have the MUI Pack available to them, you can change the CultureInfo for the thread in your managed code extension to English, United States (en-US), and then change it back to the original CultureInfo when the COM call is completed.

follow the guidance provided by microsoft above.

thanks for all, cheers.

- Hide quoted text

From http://www.developmentnow.com/g/21_2005_9_0_0_592882/Excel-templates-Old-format-or-invalid-type-library-.ht

Posted via DevelopmentNow.com Group
http://www.developmentnow.com/g/

Loading...