Hi we've just started using the Excel component and its working fine up until we come to start amending a cells properties.
We are trying to make the cell bold but when we do so it is causing an exception of 'Object reference not set to an instance of an object'
Can you tell me what we are doing wrong?
(Using winforms Infragistics.Documents.Excel.v11.2 (11.2.20112.1010)
Code below:
Private Function createWorkBook(ByVal thisfile As String) As Boolean Try Dim nextRow As Integer = 0 Windows.Forms.Cursor.Current = Cursors.WaitCursor Dim thisWorkBook As New Excel.Workbook Dim thisWorkSheet As Excel.Worksheet = thisWorkBook.Worksheets.Add("Sheet1") With thisWorkSheet .Rows.Item(nextRow).Cells.Item(0).Value = "Report Name" .Rows.Item(nextRow).Cells.Item(1).Value = p_ReportsList.srlRptShortDescription .Rows.Item(nextRow).Cells.Item(1).CellFormat.Font.Bold = Excel.ExcelDefaultableBoolean.True '<<<<< this causes the exception nextRow += 1 .Rows.Item(nextRow).Cells.Item(0).Value = "Report Parameters" .Rows.Item(nextRow).Cells.Item(0).CellFormat.Font.Bold = Excel.ExcelDefaultableBoolean.True Dim s() As String = p_RepControl.ParamGetValue("Criteria").Split(CChar(vbNewLine)) For Each p As String In s .Rows.Item(nextRow).Cells.Item(1).Value = p nextRow += 1 Next tableToExcel(thisWorkSheet, nextRow) End With thisWorkBook.Save(thisfile) Windows.Forms.Cursor.Current = Cursors.Arrow Return True Catch ex As Exception MessageError( "Report Extract failure", "Extract failed with error:" & ex.Message) Return False End Try End Function
Hello,
It seems that you are referring to a cell that does not exist in this moment or the item maybe does not exist. It is not so easy to tell exactly the reason for this exception, so a sample project which reproduces it would tell me more about it and would help me assisting you. You could attach a sample when writing/editing your post from the 'Options' tab above -> 'Add/Update' as a zip file.
Please feel free to let me know if meanwhile a question about our toolset comes up on your mind.
That's for the quick reply
Weirdly everything has started working this morning after I rebooted my machine.
I was writing an bit of example code to illustrate the problem, then had to reboot (for a different matter). As soon as I went back in the code then working perfectly.
I'm working on a 64bit machine but have to debug in 32bit mode (limitation of VS 2008).
I'm wondering if this is causing the issue, as I then started to use the cell Font.Height property and started having the same issue with that command.
I then tried it in release mode (64bit) and then command then worked and when I went back into debug mode it carried on working perfectly so there seems to be some odd behaviour going on
I shall call the issue solved for the present but if I can replicate the problem at will I'll raise an issue for it.
Thank you for your feedback. I will be glad to help you in the future if you could replicate the problem.
Please do not hesitate to contact me if you need any additional assistance.