Can someone please help me to convert this typically Microst excel code over to do the same thing with Aspose.cells?
What is does: Opens a workbook, looks at sheet called “2024”, goes thru every row checking column B for a specific date…if it finds that date,then it copies that entire row entire another sheet called “Copied”…then the file looks at all rows in “Copied” and enters them into a database…any help would be appreciated as Aspose.Cells is completely new to me. Thank you.
Dim xlApp As New Microsoft.Office.Interop.Excel.Application
Dim xlWorkBook As Microsoft.Office.Interop.Excel.Workbook
Dim xlWorkSheet, xlWorksheet2 As Microsoft.Office.Interop.Excel.Worksheet
Try
Dim SavePath As String = System.Windows.Forms.Application.StartupPath & "\temp\myfile.xlsx"
If File.Exists(SavePath) Then
File.Delete(SavePath)
End If
If Not File.Exists(SavePath) Then
File.Copy("C:\Users\PC\EXCEL SHEETS\EXCEL SHEETS DONT ADD ANYTHING EXCEPT EXCEL FILES\MyFile.xlsx", SavePath, True)
End If
If File.Exists(SavePath) Then
xlWorkBook = xlApp.Workbooks.Open(SavePath)
'MsgBox("File opened.")
xlWorkSheet = xlWorkBook.Worksheets("2024")
xlWorksheet2 = xlWorkBook.Worksheets("Copied")
'Dim dte As Date = Date.Now.AddDays(-1).ToShortDateString
form.dtp.DateTimePattern = Syncfusion.WinForms.Input.Enums.DateTimePattern.ShortDate
Dim dte As Date = form.dtp.Value
'MsgBox(dte.ToString)
Dim LastRow As Long
Dim i As Long, j As Long
Dim count As Integer = 0
'Find the last used row in a Column: column B in this example
With xlWorkSheet
LastRow = .Cells(.Rows.Count, "B").End(Microsoft.Office.Interop.Excel.XlDirection.xlUp).Row
End With
'MsgBox(LastRow)
'first row number where you need to paste values in Sheet1
With xlWorksheet2
j = .Cells(.Rows.Count, "A").End(Microsoft.Office.Interop.Excel.XlDirection.xlUp).Row
End With
'With xlWorkSheet
' For i = 1 To LastRow
' If .Cells(i, 2).ToString <> dte.ToShortDateString() Then
' MsgBox("No test records found for this date.", MsgBoxStyle.Exclamation, "No Records Found!")
' Exit Sub
' End If
' Next
'End With
With xlWorkSheet
For i = 1 To LastRow
If .Cells(i, 2).text = dte.ToShortDateString() Then
'MsgBox("Records found")
end if