mathieu_cupryk
asked on
Public member 'Minimum' on type 'Worksheet' not found.
Public Function LoadExcelSheet(ByVal dt As DataTable)
Try
Dim oApp As New Excel.Application
Dim xlWorkBook As Excel.Workbook = oApp.Workbooks.Add()
Dim xlWorkSheet As Excel.Worksheet = CType(xlWorkBook.Worksheet s(1), Excel.Worksheet)
xlWorkSheet = xlWorkBook.ActiveSheet
xlWorkSheet.Visible = True
xlWorkSheet.Minimum = 1
xlWorkSheet.Maximum = dt.Rows.Count + 1
xlWorkSheet.Value = 1
' This is to access the first work sheet of your application
xlWorkSheet = CType(xlWorkBook.Worksheet s(1), Excel.Worksheet)
xlWorkSheet.Name = "SampleExcel"
For i As Integer = 1 To dt.Rows.Count
For j As Integer = 1 To dt.Columns.Count
' This is to add the Data which retrieved from
' the database into your Excel Sheet.
CType(xlWorkSheet.Cells(i, j), Excel.Range).Value2() = dt.Rows(i - 1).ItemArray(j - 1).ToString()
'dt.Rows[i-1].ItemArray[j- 1].ToStrin g()--> This will retrieve
' data from your datatable's
'(i-1)th rows (j-1)st column
Next
xlWorkSheet.Value = xlWorkSheet.Value + 1
Next
' MessageBox.Show("Your Process Completed Successfully")
xlWorkSheet.Visible = False
Catch e1 As Exception
' MessageBox.Show(e1.Message )
End Try
End Function
Try
Dim oApp As New Excel.Application
Dim xlWorkBook As Excel.Workbook = oApp.Workbooks.Add()
Dim xlWorkSheet As Excel.Worksheet = CType(xlWorkBook.Worksheet
xlWorkSheet = xlWorkBook.ActiveSheet
xlWorkSheet.Visible = True
xlWorkSheet.Minimum = 1
xlWorkSheet.Maximum = dt.Rows.Count + 1
xlWorkSheet.Value = 1
' This is to access the first work sheet of your application
xlWorkSheet = CType(xlWorkBook.Worksheet
xlWorkSheet.Name = "SampleExcel"
For i As Integer = 1 To dt.Rows.Count
For j As Integer = 1 To dt.Columns.Count
' This is to add the Data which retrieved from
' the database into your Excel Sheet.
CType(xlWorkSheet.Cells(i,
'dt.Rows[i-1].ItemArray[j-
' data from your datatable's
'(i-1)th rows (j-1)st column
Next
xlWorkSheet.Value = xlWorkSheet.Value + 1
Next
' MessageBox.Show("Your Process Completed Successfully")
xlWorkSheet.Visible = False
Catch e1 As Exception
' MessageBox.Show(e1.Message
End Try
End Function
Where exactly does the error occur? Try removing your Try..Catch blocks so you can see the exact line
ASKER
xlWorkSheet.Minimum = 1
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.