Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
60
Cannot set font properties in a cell
posted

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

 

 

Parents Reply Children
No Data