Hi Tony,
Thanks for the last post.
I have 35 checkboxes on my web page. Based on the selection of the checkboxes the columns are displayed on the ultrawebgrid. Now I want to export these columns to an excel sheet. I am setting the width of each column before creating the excel file. The user may select any number of checkboxes. The problem is that I have to make combinations of what the user selects. For example, there are 3 checkboxes on the page, the user may select only the first checkbox or the second checkbox or the third checkbox or the first and the secodn checkbox ....
If CheckBox1.Checked = True Then
owb.Worksheets.Item(0).Columns(0).Width = 2500
For i As Integer = 0 To UltraWebGrid1.Rows.Count
owb.Worksheets.Item(0).Rows(i).Cells(0).CellFormat.Alignment = HorizontalCellAlignment.Center
Next
End If
If CheckBox1.Checked = True AndAlso CheckBox2.Checked = True Then
owb.Worksheets.Item(0).Columns(0).Width = 2500
For i As Integer = 0 To UltraWebGrid1.Rows.Count
owb.Worksheets.Item(0).Rows(i).Cells(0).CellFormat.Alignment = HorizontalCellAlignment.Center
Next
owb.Worksheets.Item(0).Columns(1).Width = 6000
For i As Integer = 0 To UltraWebGrid1.Rows.Count
owb.Worksheets.Item(0).Rows(i).Cells(1).CellFormat.WrapText = ExcelDefaultableBoolean.True
owb.Worksheets.Item(0).Rows(i).Cells(1).CellFormat.Alignment = HorizontalCellAlignment.Center
Next
End If Is there a better way of solving this problem or I have to create all the combinations. I could not find
owb.Worksheets.Item(0).Columns("mycolumn").Width = 2000 so that I could have set "mycolumn" to some specified width. The columns collection only takes integer.
Thanks,
Junaid.