Let me preface this with the fact that I'm a SQL DBA and not a programmer, so my code may not be the most efficient.
With that said, I'm moving away from Interop.Excel for many reasons but it seems I'm having problems converting some of my scripts to use ClosedXML.
My issue is not having my query results in the spreadsheet. I pass the results into the script in a variable but don't get the expected result. Before I could simply do the following.
With that said, I'm moving away from Interop.Excel for many reasons but it seems I'm having problems converting some of my scripts to use ClosedXML.
My issue is not having my query results in the spreadsheet. I pass the results into the script in a variable but don't get the expected result. Before I could simply do the following.
objWorkBook = objExcel.Workbooks.Open(strReportFileLocation & strReportFileName)
myRecordset = Dts.Variables("gvRecordSet").Value
objWorkSheet = objWorkBook.Worksheets("SomeCharges")
__objWorkSheet.Cells(3, 1).CopyFromRecordset(myRecordset)__
Now with ClosedXML I'm using the following code. I do not receive any errors but I have no data on my spreadsheet either. Public Sub Main()
Dim FilePath As String
Dim Filename As String
Dim Recordset As Object
Dim filespec As String
FilePath = Dts.Variables("gvReportFileLocation").Value.ToString
Filename = Dts.Variables("gvReportFileName").Value.ToString
Recordset = CType(Dts.Variables("gvRecordSet").Value, String)
filespec = (FilePath & Filename)
Dim Workbook As New XLWorkbook(filespec)
Dim Worksheet As IXLWorksheet
Worksheet = Workbook.Worksheet("SomeFees")
Dim CellForNewData As IXLCell
CellForNewData = Worksheet.Cell(3, 1)
CellForNewData.InsertData(Recordset)
Thanks in advance for any help.