I think its something like this but the top line does not work and the bottom line gives me runtime error so I think I have to Dim an excel cell and do something similar excelWorksheet.Cells(rowCount, i + 1).Locked = TrueĮxcelWorksheet.Cells(rowCount, i + 1).AllowEdit = False So using the code above as a guide is there a way that I can create that last column (please see comment in code sample for location) as a read-only field or another option would be create some hidden field? 'I put the old ProductID here to identify the rowĮxcelWorksheet.Cells(rowCount, i + 1) = dr.Item(0).ToString Protected Sub DataTableToExcel(ByVal dtTable As DataTable)ĭim excelBook As Excel.Workbook = ĭim excelWorksheet As Excel.Worksheet = CType(excelBook.Worksheets(1), Excel.Worksheet)įor i As Integer = 1 To ĮxcelWorksheet.Cells(1, i) = dtTable.Columns(i - 1).ColumnName.ToUpperĮxcelWorksheet.Cells(rowCount, i) = dr.Item(i - 1).ToString I have to do this so I can be certain which record I am referring to since the user can change other values and do sorting and I am converting datatable to excel document using the code below and I need to convert the last excel column value to read only.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |