none
Shouldn't the column start with special characters? RRS feed

  • Question

  • I'm working with Excelsheet of .xls format and writing data into it.The problem is that whenever the data doesn't start with alphabets it is prompting me different errors.

    For ex:When my column data started with =?us-ascii?Q?Google Keywords?= it throwed me an exception

    Exception from HRESULT: 0x800A03EC

    and when my data is like -------- Original Message --------Subject:.the error was

    Not enough storage is available to complete this operation. (Exception from HRESULT: 0x8007000E (E_OUTOFMEMORY))

    This is how I'm writing data to excel

    foreach (AllCasesReplies infoList in allCasesReplies)
      {
          n = 0;
          mWorkSheet.Cells[l + m, ++n] = infoList.id;
          mWorkSheet.Cells[l + m, ++n] = infoList.replies;
          m++;
       }

    This is how I clean my objects

    private static void SaveAndCollecttheGarbage(Microsoft.Office.Interop.Excel.Application excelApp, string path, Microsoft.Office.Interop.Excel.Sheets sheet)
    {
            excelApp.Columns.AutoFit();
            mWorkBook.SaveAs(path, Microsoft.Office.Interop.Excel.XlFileFormat.xlWorkbookNormal,
            Missing.Value, Missing.Value, Missing.Value, Missing.Value, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlExclusive,
            Missing.Value, Missing.Value, Missing.Value,
            Missing.Value, Missing.Value);
            mWorkBook.Close(true, Missing.Value, Missing.Value);
            sheet = null;
            mWorkBook = null;
            excelApplication.Quit();
            GC.WaitForPendingFinalizers();
            GC.Collect();
            GC.WaitForPendingFinalizers();
            GC.Collect();
    }

    So I have tried omitting these data and they are working great My question is that any rules are there that the column has to start with specific characters.If so what all comes under illegal characters

    Wednesday, June 3, 2015 11:42 AM

Answers

  • Hi,

    I am trying to reproduce this issue however failed. Can you reproduce the issue using code below:

    Application excelApp = new Application();
                excelApp.Visible = true;
                Workbook workbook=excelApp.Workbooks.Open(@"C:\book.xlsx");
                            workbook.Worksheets["Sheet1"].Cells[1, 1] = "-------- Original Message --------Subject:";
                
                workbook.Close(true);
                excelApp.Quit();

    And based on the error message, the issue shouldn't be relative to the text you were writing. I also find a KB for this error.

    To resolve this problem, use one of the following methods:
    • Split objects between multiple   processes.
    • Reduce the number of interfaces that are called between one   process and another.

    Is the suggestion helpful to fix this issue? Here is the link for your reference:
    https://support.microsoft.com/en-us/kb/890425

    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by L.HlModerator Friday, July 10, 2015 9:29 AM
    Thursday, June 4, 2015 9:26 AM
    Moderator