how to solve this error "Exception from HRESULT: 0x800A03EC"?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • varunkumarid
    New Member
    • Aug 2008
    • 40

    #1

    how to solve this error "Exception from HRESULT: 0x800A03EC"?

    The Error on line 99 when i execute this code
    Code:
     [STAThread]
    
           protected void Generate_Click(object sender, EventArgs e)
            {
                int io = 0;
                System.Data.DataTable workTable = new System.Data.DataTable();
                workTable.TableName = "VendorList";
                workTable.Columns.Add("ITEM_NAME");
                workTable.Columns.Add("ITEM_QUANTITY");
                workTable.Columns.Add("ITEM_UOM");
                workTable.Columns.Add("ITEM_RATE");
                workTable.Columns.Add("CURRENCY_CODE");
                workTable.Columns.Add("REMARKS");
                workTable.Columns.Add("VENDOR_NAME");
                System.Data.DataRow workRow;
                objDAOUploadEnquiry.ActionType = SRCMAction.FETCH.ToString();
                objBLLUploadEnquiry.SelectCommonMasterUom(objDAOUploadEnquiry);
                object dropDownValues = "";
                for (int y = 0; y <= 9; y++)
                {
                    workRow = workTable.NewRow();
                    //workRow[0] = "Cust" + y.ToString();// y;
                    //workRow[1] = "Cust" + y.ToString();
                    if (io == 0)
                    {
                        for (int kl = 0; kl < objDAOUploadEnquiry.UploadEnquriyList.Rows.Count; kl++)
                        {
                            dropDownValues += objDAOUploadEnquiry.UploadEnquriyList.Rows[kl]["TEXT_VALUE"].ToString() + ",";
                        }
                        io = 1;
                    }
                    workTable.Rows.Add(workRow);
                }
    
                string data = null;
                int i = 0;
                int j = 0;
                int rowsCount = workTable.Rows.Count + 1;
    
                Excel.Application xlApp;
    
                Excel.Workbook xlWorkBook;
    
                Excel.Worksheet xlWorkSheet;
    
                object misValue = System.Reflection.Missing.Value;
                object pwd = "pwd";
                Excel.Application xl = null;
    
                Excel._Workbook wb = null;
    
                Excel._Worksheet sheet = null;
    
                object Missing = System.Reflection.Missing.Value;
    
                try
                {
    
                    xlApp = new Excel.ApplicationClass();
                    xl = new Excel.Application();
    
                    xlWorkBook = xlApp.Workbooks.Add(misValue);
                    xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
                    wb = (Excel._Workbook)(xl.Workbooks.Add(Missing));
                    wb.Sheets.Add(Missing, Missing, Missing, Missing);
                    sheet = (Excel._Worksheet)(wb.Sheets[1]);
                    xlWorkSheet.Name = "IncludeVendorList";
                    Excel.Range m_range = sheet.get_Range("A1", "A10");
    
    
                    // m_range.Validation.Add(Excel.XlDVType.xlValidateList, Excel.XlDVAlertStyle.xlValidAlertStop, Excel.XlFormatConditionOperator.xlBetween, dropDownValues, Type.Missing);
    
    
    
                    for (j = 0; j <= workTable.Columns.Count - 1; j++)
                    {
                        data = workTable.Columns[j].ToString();
                        xlWorkSheet.Cells[1, j + 1] = data;
                    }
    
    
                    for (i = 0; i <= workTable.Rows.Count - 1; i++)
                    {
                        for (j = 0; j <= workTable.Columns.Count - 1; j++)
                        {
    
                            data = workTable.Rows[i].ItemArray[j].ToString();
                            xlWorkSheet.Cells[i + 2, j + 1] = data;
    
                            //sheet.get_Range(i + 2, j + 1).Value2 = m_list;
                            //  m_range.Validation.Add(Excel.XlDVType.xlValidateList, Excel.XlDVAlertStyle.xlValidAlertStop, Missing, m_list, Missing);
    
    
                        }
                    }
    
                    Excel.Range _nValidationRange = xlApp.get_Range("C2", "C10");
    
                    _nValidationRange.Validation.Add(Excel.XlDVType.xlValidateList, Excel.XlDVAlertStyle.xlValidAlertStop, Excel.XlFormatConditionOperator.xlBetween, dropDownValues, Type.Missing);
                    xlWorkBook.SaveAs(("G:\\dhinakr.xls"), Excel.XlFileFormat.xlWorkbookNormal, misValue, misValue, misValue, misValue, Excel.XlSaveAsAccessMode.xlExclusive, misValue, misValue, misValue, misValue, misValue);
    
    
    
    
                    //sheet.Range["A1"].NumberFormat = "dd/mm/yyyy";
    
    
    
                    //sheet.get_Range("A2", "A11").Value2 = m_list;
                    // m_range.Validation.Add(Excel.XlDVType.xlValidateList, Excel.XlDVAlertStyle.xlValidAlertStop, Missing, m_list, Missing);
                    // m_range.Validation.InCellDropdown = true;
                    // m_range.Validation.IgnoreBlank = true;      
    
    
    
    
                    xlWorkBook.Save();
                    xlApp.Quit();
                    xlApp.Application.Quit();
                    string filepath = "G:\\dhinakr.xls";
                    FileInfo myfile = new FileInfo(filepath);
                    if (myfile.Exists)
                    {
                        Response.ClearContent();
                        Response.ContentType = "application/vnd.ms-excel";
                        Response.AppendHeader("Content-Disposition", "attachment; filename=" + myfile.Name);
                        Response.AddHeader("Content-Length", myfile.Length.ToString());
                        Response.TransmitFile(myfile.FullName);
    
                        Response.End();
                    }
                }
                catch (COMException Ex)
                {
                    GC.Collect();
                    throw new Exception(Ex.Message);
                }
            }
    Last edited by varunkumarid; Jul 6 '10, 06:54 AM. Reason: To Improve the Question
  • GaryTexmo
    Recognized Expert Top Contributor
    • Jul 2009
    • 1501

    #2
    I tried googling your exception text and got the following...



    In the future, please try one of the following when you have problems of this kind...

    1) Google the exception text. Usually other people will have encountered the exception in the past and you can usually find some good information via a search to help you out.

    2) If that doesn't pan out, when you post a question here please try to include a little more information than just the exception and the code. For example, a description of what your code does and the line the exception is being thrown on help a lot! For the most part, volunteers here won't know the immediate answer to your problem, but will instead try to understand it and help you work towards a solution. To that end, more information is always helpful!

    Anyway, take a look at the link... or checking out some of the other ones on google. If they don't help you, post back here and give us a bit more information about the problem.

    Thanks!

    Comment

    Working...