vb project data exported to excel

C

confused

Hello;
Can someone please tell me how to write the code I need to use word
wrap.
I have a vb 2005 app that exports the data into excel and I want the
data in each row to use word wrap for every text columm. The code
below only sets the column heading, I thought it would set all column
per row
(example cloumn a1 is name so all rows for a1 should be set with word
wrap)

SetColumnsFormat(oExcel)

Private Function SetColumnsFormat(ByVal oExcel As Object) As Boolean

For i As Integer = 0 To lstColumnsSelected.Items.Count - 1
Application.DoEvents()

Dim myExcel As Excel_ = oExcel

Dim col As dcColumn
col = lstColumnsSelected.Items.Item(i)
Dim nmLwr As String = col.Name.ToLower()

Select Case col.Type
Case 1
' Text Type R,Col Width
myExcel.WrapText(1, i + 1, True)
Continue For

Case 2 ' Date Type
myExcel.FormatWidth(1, i + 1, col.Width)
Continue For

Case 3 ' Hours Col Format
myExcel.FormatNum(i + 1, "###0")
myExcel.FormatWidth(1, i + 1, col.Width)
Continue For

Case 4 ' Money
myExcel.FormatNum(i + 1, "###,##0.00")
myExcel.FormatWidth(1, i + 1, col.Width)
Continue For

Case 5 ' Months
myExcel.FormatNum(i + 1, "##0.0")
myExcel.FormatWidth(1, i + 1, col.Width)
Continue For

Case Else
myExcel.FormatWidth(1, i + 1, col.Width)

End Select

Next i
End Function

What am I doing wrong?
 
C

confused

Hello;
Can someone please tell me how to write the code I need to use word
wrap.
I have avb2005 app that exports the data into excel and I want the
data in each row to use word wrap for every text columm.  The code
below only sets the column heading, I thought it would set all column
per row
(example cloumn a1 is name so all rows for a1 should be set with word
wrap)

SetColumnsFormat(oExcel)

Private Function SetColumnsFormat(ByVal oExcel As Object) As Boolean

        For i As Integer = 0 To lstColumnsSelected.Items.Count -1
            Application.DoEvents()

            Dim myExcel As Excel_ = oExcel

            Dim col As dcColumn
            col = lstColumnsSelected.Items.Item(i)
            Dim nmLwr As String = col.Name.ToLower()

            Select Case col.Type
                Case 1
                      ' Text Type R,Col   Width
                    myExcel.WrapText(1, i + 1, True)
                    Continue For

                Case 2   '  Date Type
                    myExcel.FormatWidth(1, i + 1, col.Width)
                    Continue For

                Case 3   '  Hours  Col    Format
                    myExcel.FormatNum(i + 1, "###0")
                    myExcel.FormatWidth(1, i + 1, col.Width)
                    Continue For

                Case 4   '  Money
                    myExcel.FormatNum(i + 1, "###,##0.00")
                    myExcel.FormatWidth(1, i + 1, col.Width)
                    Continue For

                Case 5   '  Months
                    myExcel.FormatNum(i + 1, "##0.0")
                    myExcel.FormatWidth(1, i + 1, col.Width)
                    Continue For

                Case Else
                    myExcel.FormatWidth(1, i + 1, col.Width)

            End Select

        Next i
    End Function

What am I doing wrong?

Found my answer, doesn't seem to be much help on this group. Don't
know how to close this topic, if I could , I would
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top