Greetings all,
I have the following bit of code that I have used in the past to export a DataSet generated from the Stored Procedure 'HISTORICAL_COSTS' to Excel.
Dim c As Long = 1
For Each dc As DataColumn In Me.WOCostDataSet. & _
HISTORICAL_COSTS.Columns
.Cells(1, c).Value = dc.ColumnName.ToString
.Cells(1, c).Font.Bold = True
c += 1
Next
Dim i As Long = 2
For Each dr As DataRow In Me.WOCostDataSet.HISTORICAL_COSTS.Rows
c = 1
For Each dc As DataColumn In Me.WOCostDataSet. & _
HISTORICAL_COSTS.Columns
.Cells(i, c).Value = dr.Item(dc.ColumnName).ToString
c += 1
Next
i += 1
Next
I am trying to re-use this code an different but similar application, but, I am running into an issue. The previous use of this code was used on a static table in our dBase generated by the Stored Procedure. And while this basically remains the same for the new application, the requirements now require the stored procedure to have an input parameter to be entered by the user (through VB.net) prior to execution. For a little back-story, you can follow that completed process here - Injecting a Parameter into Stored Procedure.
The application itself does in fact return a fully populated dataset, and I'd like our users to have the ability to export that generated dataset to Excel. So, I set up your prototypical 'EXPORT ME' button to do start the dirty work.
Upon raising the event; Excel opens and only my column names are being reiterated throughout the sheet. But, and here is the problem, the cells representing the row data - are blank.
I have come to the conclusion (I do admit that I may be wrong in this assumption) that the rows are not being populated due to the fact that the Stored Procedure needs an input parameter to do it's thing, and without that parameter there isn't any data to return for each row. Basically meaning that my code just won't work for what I am trying to do.
If I am right in my assumptions, any ideas as to how I might get that parameter into my code above so that the rows will be properly generated.
If I am wrong, well, any input on what be wrong with my logic or the code itself would be greatly appreciated.
Thanks,
Jasoomian