Search code examples
vb.netexceldatatabledatasetexport-to-excel

Spreadsheet from DataTable


In my app, I'm downloading a spreadsheet from FTP, moving the data read from the spreadsheet to a DataTable, and, depending on certain conditions, emailing a new spreadsheet (one that contains certain rows from the 1st spreadsheet).

My problem is creating the spreadsheet that will be mailed. I can't seem to work out how to add the row from the DataTable (originally from the spreadsheet that was downloaded) into the spreadsheet that's going to be mailed.

DS.Tables(0).Rows.Add(ObjSheet.Range(workTable.Rows(i)) - 1)

Is what I've got at the moment, but it's not working. workTable is the DataTable where the rows from the spreadsheet were copied to. DS is the DataSet where I'm putting the rows from the specific selection. I'm pretty sure I can simplify the flow of data by eliminating either the DataTable or the DataSet.

To eliminate any confusion, I'm using VB2005 - Wish I could use 2008 for this, LINQ simplifies so much...


Solution

  • SpreadsheetGear for .NET can help you do this.

    See the live ASP.NET (C# & VB) "Excel to Datagrid" samples here. There are more samples - some of which might prove useful - here.

    Disclaimer: I own SpreadsheetGear LLC