We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

NullReferenceException on InsertRow

Thread ID:

Created:

Updated:

Platform:

Replies:

58534 Mar 24,2007 12:52 PM Mar 26,2007 12:53 AM Windows Forms 3
loading
Tags: XlsIO
Administrator [Syncfusion]
Asked On March 24, 2007 12:52 PM

Hi,
I have a pre-existing Excel file on my hard drive that has a sheet called "Trades".
If I try to call InsertRow on this sheet, I get a NullReferenceException, here is the code:

ExcelEngine engine = new ExcelEngine();
IApplication excelApplication = engine.Excel;
IWorkbook workbook = excelApplication.Workbooks.Open(templateFile);
IWorksheet tradesSheet = workbook.Worksheets["Trades"];
tradesSheet.InsertRow(row,1,ExcelInsertOptions.FormatAsAfter); //throws a NullReferenceException

Am I doing something wrong?

Thanks in advance
:)
Adrian

Administrator [Syncfusion]
Replied On March 24, 2007 12:58 PM

p.s. the variable "row" on the last line is an int wih value 6

Administrator [Syncfusion]
Replied On March 24, 2007 01:10 PM

Here is the whole Exception with the relevent stack segment (see the attached image of the error snapshot in visual studio):
Object reference not set to an instance of an object.
at Syncfusion.XlsIO.Implementation.Collections.WorkbookNamesCollection.InsertRemoveRowColumn(String strSheetName, Int32 index, Boolean bIsRemove, Boolean bIsRow, Int32 iCount)
at Syncfusion.XlsIO.Implementation.Collections.WorkbookNamesCollection.InsertRow(Int32 iRowIndex, Int32 iRowCount, String strSheetName)
at Syncfusion.XlsIO.Implementation.WorksheetImpl.InsertRow(Int32 iRowIndex, Int32 iRowCount, ExcelInsertOptions insertOptions)

SyncfusionError4.zip

Melba Winshia [Syncfusion]
Replied On March 26, 2007 12:53 AM

Hi Adrian,

Thanks for your interest in Essential XlsIO.

Could you please send us the specific Excel file, which has a sheet called "Trades" that you are seeing the problem with? This would help us in investigating further on this issue.

You can also open a Direct-Trac incident so that the file remains confidential.

Thanks,
Melba

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;