Solved

Convert client Excel File to Xml File for DataSet VB.NET

Posted on 2004-10-20
3
528 Views
Last Modified: 2008-02-01
Hi,

I have a Windows App that converts a DataSet into an XML (WriteXml) file and then converts the XML file into a CSV file (XSLT) and then converts this to an Excel File.

I now want to do this in reverse, and let the client choose an Excel file to convert and import into the App to be viewed as a DataSet. The question has three parts:

1. I am stubbornly using XML as an intermediate so that I can learn to build more flexible applications. Is this a good idea, or should I just connect directly to the Client's Excel file to save myself some trouble?

2. What kind of connection works for reading Excel files into DataSets and will this work on any client's machine?

3. Does anyone know code that will let the user specify the Excel file to be converted, and then convert it to CSV so that I can transform it to XML?

Thanks.

0
Comment
Question by:nathanpz
  • 2
3 Comments
 
LVL 10

Accepted Solution

by:
123654789987 earned 500 total points
ID: 12366997
1. It is a good idea to use XML as a intermediary. Since u are porting the information to a client computer Xml is a interoperable solution for such application. If u directly try to port a excel file there might be issues depending on the version of  Excel.

2 U can use System.Data.OleDbClient  connection
 Follow this link
http://codeproject.com/dotnet/ExportExcelData.asp


3. To convert a Excel to CSV u can use the following

 Public Function ConvertCSVToXLS(ByVal strCSVFile As String, ByVal strXLSFile As String)
  Dim oExcel As Excel.Application
  Set oExcel = New Excel.Application
 
  Dim oBook As Workbook
  Set oBook = oExcel.Workbooks.Open(strCSVFile)
    oBook.SaveAs strXLSFile, xlExcel9795
  Set oBook = Nothing
 
  oExcel.Quit
  Set oExcel = Nothing
End Function

Here u are basically saving the excel as CSV.

For futhur information about using Excel in a application u can follow this link
http://www.c-sharpcorner.com/winforms/ExcelReadMG.asp 
0
 

Author Comment

by:nathanpz
ID: 12367181
Thanks 123...

That looks great. I'll try a few of the things out and have a verdict in the next day or so.

Thanks again.
Nathan.
0
 

Author Comment

by:nathanpz
ID: 12375962
Points are yours 123...

I'm not familiar with C# but I'm still getting somewhere now so thanks.
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SQL LINE CONTINUATION ISSUE 12 38
MailAddress in vb 4 29
Visual studio 2015 1 22
DataMember property 'tablename' cannot be found on the DataSource. 4 26
Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question