Click here to Skip to main content
15,914,111 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
HI

I want to creat excel chart in run time but when I was run my project show this Exception :
[System.Runtime.InteropServices.COMException] = {"Old format or invalid type library. (Exception from HRESULT: 0x80028018 (TYPE_E_INVDATAREAD))"}

My Code is:
C#
    Excel.Application m_objExcel = null;

    Excel._Workbook m_objBook = null;

    Excel._Chart m_objChart = null;

    Excel.ChartGroup m_objChartGroup = null;

    Excel.Series m_objSeries = null;

    object m_objOpt = System.Reflection.Missing.Value;

    try
    {

        m_objExcel = new Excel.Application();

        m_objBook =

m_objExcel.Workbooks.Open

(@"c:\\ExcelDemo", m_objOpt, m_objOpt, m_objOpt, m_objOpt, m_objOpt,

m_objOpt, m_objOpt, m_objOpt, m_objOpt, m_objOpt, m_objOpt, m_objOpt, m_objOpt, m_objOpt);

        m_objChart = (Excel._Chart)m_objExcel.Charts.get_Item(1);

        m_objChart.BarShape = Excel.XlBarShape.xlCylinder;

        m_objChartGroup = (Excel.ChartGroup)m_objChart.ChartGroups(1);

        m_objSeries = (Excel.Series)m_objChartGroup.SeriesCollection(1);

        m_objSeries.Values = 456;

        m_objExcel.DisplayAlerts = false;

        m_objBook.SaveAs(@"c:\\ExcelDemo", m_objOpt, m_objOpt,

       m_objOpt, m_objOpt, m_objOpt, Excel.XlSaveAsAccessMode.xlNoChange,

                                m_objOpt, m_objOpt, m_objOpt, m_objOpt, m_objOpt);

    }

    catch (Exception ex)
    {

        MessageBox.Show(ex.Message);

    }

    finally
    {

        m_objBook.Close(m_objOpt, m_objOpt, m_objOpt);

        m_objExcel.Workbooks.Close();

        m_objExcel.Quit();

        System.Runtime.InteropServices.Marshal.ReleaseComObject(m_objBook);

        System.Runtime.InteropServices.Marshal.ReleaseComObject(m_objExcel);

        m_objBook = null;

        m_objExcel = null;

        GC.Collect();

        this.Close();

    }

}

Plze Help Me soon........... plze
Posted
Updated 28-Apr-12 20:21pm
v2

1 solution

Have a look at this thread: Similar discussion...[^]

Looks like related to some 'regional language of OS other than "en-US"'
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900