﻿<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>StrataFrame Forum » .NET Forums » General .NET Discussion  » Working with Excel file for importing the data with VB.NET</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Tue, 09 Jun 2026 00:02:57 GMT</lastBuildDate><ttl>20</ttl><item><title>Working with Excel file for importing the data with VB.NET</title><link>http://forum.strataframe.net/FindPost23744.aspx</link><description>Hi guys,&lt;br&gt;
&lt;br&gt;
I have some Excel or CSV files which I need to import data from, all these files have over 5 columns and I only care from 2 of them, so I am looking for a way to remove all the extra columns or just select the ones I care for and create another file so I can import the data.  These file can have over 120,000 rows so the need to remove unwanted columns and just import the needed ones.&lt;br&gt;
&lt;br&gt;
I am using the import class library from [url=]http://www.filehelpers.com[/url] which is incredibly easy to use for importing data and manipulate this data via strong type BOs, but unfortunately they have not way to pre-select just the columns I need from the imported file.&lt;br&gt;
&lt;br&gt;
So I would appreciate if anybody have any link or sample code on how to manipulate an Excel file to remove some specific columns and create a new file to be ready to import using the FileHelpers classes.&lt;br&gt;
&lt;br&gt;
Thanks!</description><pubDate>Tue, 07 Jul 2009 11:45:30 GMT</pubDate><dc:creator>Edhy Rijo</dc:creator></item><item><title>RE: Working with Excel file for importing the data with VB.NET</title><link>http://forum.strataframe.net/FindPost23763.aspx</link><description>Hi Edhy&lt;/P&gt;&lt;P&gt;I was trying to do what you are working now (import from Excel to a BO) but I'not succedd. I´m pretty sure you will solve this, if is possible please put some sample of the solution, I think than more than one will be found very usefull.&lt;/P&gt;&lt;P&gt;Actuallly as I use SQL Server 2008 express, the managment console let me import from Excel to the database; in 2005 express edition did not had this option. Of course it will be better if people don't have to deal with this tools.&lt;/P&gt;&lt;P&gt;Regards</description><pubDate>Tue, 07 Jul 2009 11:45:30 GMT</pubDate><dc:creator>Juan Carlos Pazos</dc:creator></item><item><title>RE: Working with Excel file for importing the data with VB.NET</title><link>http://forum.strataframe.net/FindPost23746.aspx</link><description>Thanks Keith, let me give it a try.</description><pubDate>Mon, 06 Jul 2009 11:31:21 GMT</pubDate><dc:creator>Edhy Rijo</dc:creator></item><item><title>RE: Working with Excel file for importing the data with VB.NET</title><link>http://forum.strataframe.net/FindPost23745.aspx</link><description>I think you should just be able to select the columns you want from the Excel file once you have an OLEDB connection to it.&lt;FONT size=2&gt;&lt;P&gt;[quote]&lt;FONT size=2&gt;&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;Dim&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; sheetname &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;String&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;String&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;.Empty&lt;/P&gt;&lt;P&gt;sheetname = GetExcelSheetNames(fullfilename)&lt;/P&gt;&lt;P&gt;sConnectionString = &lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;&lt;FONT color=#a31515 size=2&gt;"Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; _&lt;/P&gt;&lt;P&gt;&amp;amp; fullfilename &amp;amp; &lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;&lt;FONT color=#a31515 size=2&gt;";Extended Properties=""Excel 8.0;HDR=No;"";"&lt;/P&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;P&gt;objConn.ConnectionString = sConnectionString&lt;/P&gt;&lt;P&gt;objConn.Open()&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;Dim&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; objCmdSelect &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;New&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; OleDbCommand(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;&lt;FONT color=#a31515 size=2&gt;"SELECT&amp;nbsp;COL1,COL2,COL3 FROM ["&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &amp;amp; sheetname &amp;amp; &lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;&lt;FONT color=#a31515 size=2&gt;"]"&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;, objConn)&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;Dim&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; objAdapter1 &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;New&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; OleDbDataAdapter()&lt;/P&gt;&lt;P&gt;objAdapter1.SelectCommand = objCmdSelect&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;Dim&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; objDataset1 &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;New&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; DataSet&lt;/P&gt;&lt;P&gt;objAdapter1.Fill(objDataset1, &lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;&lt;FONT color=#a31515 size=2&gt;"tablename"&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;)&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;Dim&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; atable &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt; DataTable = objDataset1.Tables(&lt;/FONT&gt;&lt;FONT color=#a31515 size=2&gt;&lt;FONT color=#a31515 size=2&gt;"tablename"&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;)&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;[/quote]&lt;/FONT&gt;</description><pubDate>Mon, 06 Jul 2009 11:26:27 GMT</pubDate><dc:creator>Keith Chisarik</dc:creator></item></channel></rss>