?
Solved

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

Posted on 2004-10-20
3
Medium Priority
?
541 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 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses
Course of the Month15 days, 12 hours left to enroll

850 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