Help needed regarding Excel Interop

Hi all,

I'm working on an Excel Interop application using C#.

I'm facing 2 problems as described below:

1.Am using OleDbCommand and INSERT INTO query
to insert data from a .Net datatable into an excel sheet.
Am getting the following error during the same:
"The field is too small to accept the amount of data you attempted to add.
Try inserting or pasting less data."
Any idea,how to fix this

2.I'm trying to delete a worksheet from an existing excel file using the following C# code.But, the worksheet is not getting deleted...

Am doing something wrong... Is there any other approach...

foreach(Excel.Worksheet ws in wkBook.Sheets)

{

if (ws.Name.ToString().Trim().ToUpper() == viewName.ToUpper())

{

ws.Delete();

break;

}

}

//Save changes to Excel file

wkBook.Save();


wkBook.Close(true, excelFilePath, Type.Missing);

Thanks in advance...!

Cheers,



Answer this question

Help needed regarding Excel Interop

  • Lalit Mohan

    1. Check the data, and try to insert one row, then more, and find the row or column that makes you problems.
    2. Execute ws.Select(true); method before delete. I'm just guessing this.

  • Help needed regarding Excel Interop