473,657 Members | 2,626 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Import XML Excel into dataset

Hi - can you help please?

Please review the following straightforward code which works fine with
ordinary XML files.

----------------------------------------------------------------
Dim originalxmlsour ce As New DataSet
Dim xmlfilename As String = Request.Physica lApplicationPat h _ &
"myfilename.xml "
MyDataGrid.Data Source = originalxmlsour ce
MyDataGrid.Data Bind()
----------------------------------------------------------------

In actuality what I really need to do is import an Excel XML file,
which was originally generated by Office Web Components (Excel 2002).
OWC would only allow me to Export in Excel XML, rather than native
Excel format.

If I try to use the above code using Excel XML I get a "Specified cast
is not valid" error.

So my question is how can I neatly import Excel XML into a dataset?

Many thanks!

Alex

Nov 19 '05 #1
7 5075
Have you looked at the DataSet.ReadXml () method?

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com

"po******@alexs hirley.com" wrote:
Hi - can you help please?

Please review the following straightforward code which works fine with
ordinary XML files.

----------------------------------------------------------------
Dim originalxmlsour ce As New DataSet
Dim xmlfilename As String = Request.Physica lApplicationPat h _ &
"myfilename.xml "
MyDataGrid.Data Source = originalxmlsour ce
MyDataGrid.Data Bind()
----------------------------------------------------------------

In actuality what I really need to do is import an Excel XML file,
which was originally generated by Office Web Components (Excel 2002).
OWC would only allow me to Export in Excel XML, rather than native
Excel format.

If I try to use the above code using Excel XML I get a "Specified cast
is not valid" error.

So my question is how can I neatly import Excel XML into a dataset?

Many thanks!

Alex

Nov 19 '05 #2
Opps sorry I didn't post the code properly (doh!), yes it includes the
readxml method, but it won't read Excel XML.
Revised code here - thanks Alex

----------------------------------------------------------------
Dim originalxmlsour ce As New DataSet
Dim xmlfilename As String = Request.Physica lApplicationPat h _ &
"myfilename.xml "
originalxmlsour ce.ReadXml(xmlf ilename)
MyDataGrid.Data Source = originalxmlsour ce
MyDataGrid.Data Bind()
----------------------------------------------------------------

Nov 19 '05 #3
which line, specifically, is getting the cast error?
Is they XML file a valid XML file?

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com

"po******@alexs hirley.com" wrote:
Opps sorry I didn't post the code properly (doh!), yes it includes the
readxml method, but it won't read Excel XML.
Revised code here - thanks Alex

----------------------------------------------------------------
Dim originalxmlsour ce As New DataSet
Dim xmlfilename As String = Request.Physica lApplicationPat h _ &
"myfilename.xml "
originalxmlsour ce.ReadXml(xmlf ilename)
MyDataGrid.Data Source = originalxmlsour ce
MyDataGrid.Data Bind()
----------------------------------------------------------------

Nov 19 '05 #4
Hi Curt

This line gets "Specified cast is not valid":
originalxmlsour ce.ReadXml(xmlf ilename)

But if only happens if I use an Excel 2002 XML spreadsheet, that's what
I want to import into a dataset.
Plain XML works fine.

Thanks

Alex

Nov 19 '05 #5
You may have to do some manual cleanup on the XML then.. sounds like it's not
validating correctly as proper XML.

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com

"po******@alexs hirley.com" wrote:
Hi Curt

This line gets "Specified cast is not valid":
originalxmlsour ce.ReadXml(xmlf ilename)

But if only happens if I use an Excel 2002 XML spreadsheet, that's what
I want to import into a dataset.
Plain XML works fine.

Thanks

Alex

Nov 19 '05 #6

<po******@alexs hirley.com> wrote in message
news:11******** *************@o 13g2000cwo.goog legroups.com...
Hi - can you help please?

Please review the following straightforward code which works fine with
ordinary XML files.

----------------------------------------------------------------
Dim originalxmlsour ce As New DataSet
Dim xmlfilename As String = Request.Physica lApplicationPat h _ &
"myfilename.xml "
MyDataGrid.Data Source = originalxmlsour ce
MyDataGrid.Data Bind()
----------------------------------------------------------------


I think you may need 2003 version for exporting xml in a readable format as
2002 seems to export all of the excel spreadsheet formats etc. There may be
someone out there that has a customize file output writer to write the
desire xml format. A workaround may be to link you excel spreadsheet to
MSAcess and use the access export for xml (DataOnly). Hope this helps
Nov 19 '05 #7
Thank vMike
I think you may need 2003 version for exporting xml in a readable format as
2002 seems to export all of the excel spreadsheet formats etc.
I was wondering if there was a way of transforming the Excel 2002 XML
file itself (i.e. strip out the garbage) before it got read in....

Hmmm....

Cheers

Alex

vMike wrote: <po******@alexs hirley.com> wrote in message
news:11******** *************@o 13g2000cwo.goog legroups.com...
Hi - can you help please?

Please review the following straightforward code which works fine with
ordinary XML files.

----------------------------------------------------------------
Dim originalxmlsour ce As New DataSet
Dim xmlfilename As String = Request.Physica lApplicationPat h _ &
"myfilename.xml "
MyDataGrid.Data Source = originalxmlsour ce
MyDataGrid.Data Bind()
----------------------------------------------------------------


I think you may need 2003 version for exporting xml in a readable format as
2002 seems to export all of the excel spreadsheet formats etc. There may be
someone out there that has a customize file output writer to write the
desire xml format. A workaround may be to link you excel spreadsheet to
MSAcess and use the access export for xml (DataOnly). Hope this helps


Nov 19 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3850
by: Alex Shirley | last post by:
Hi I'm trying to import some Excel XML into a dataset. If I use the below code on some standard XML it works fine. If I use it on XML created from Excel I will get (will xmlread): Specified cast is not valid. What do I need to do to my code so it can read Excel XML? Many thanks
3
2690
by: Schultz | last post by:
I would like to know if it is possible to import data from MS Excel 2000 to a dataset using asp.net. The excel file would need to be uploaded to the server from a web page first, before the loaded into a dataset. After the data is stored in the dataset, i would need to write the information to an access db. If it is possible to do this, where can I find help on how to import excel data to a dataset? Thanks!
0
1661
by: ramnaresh_t yadav via .NET 247 | last post by:
Hi, I am pasting the code to import data from Text/Excel files into Database(Oracle ) Table... I think some one needs this .. they can use.. it... ======================= Dim dsDB As New DataSet Dim daDB As New OracleDataAdapter Dim cmdDB As OracleCommand = New OracleCommand Dim strRow As String Dim sqlArr() As String 'Array which stores all queries of all records to be executed as a whole to database Dim RetVal As Long = 0
10
11810
by: Niklas | last post by:
Hi Before I start coding I need to be sure that nobody else has not done it yet and that I can use it. I need an import utility which import data from Excel to a database or some object in .NET. The data in Excel is not in structured columns but can exist everywhere in the workbook. For example if I am supposed to import a person and all his/her cars which exist in a workbook I want to be able to create an import protocol and specify...
4
2274
by: jayfeb29 | last post by:
Hi , Any one can guide me in Import the Excel 2002 data into sql server 2000 using ado.net1.1. I have searched all the forums most of the solutions end with a line of suggestion not with any code . here is my code . by using OLEDB JET I got the data from Excel to data set , the data is in the data table OleDbConnection strConn = new OleDbConnection ("Provider=Microsoft.Jet.OLEDB.4.0;data source= c:\\1005.xls;Extended...
2
1250
by: jainarun | last post by:
Hi All, I have to import the data from MSExcel to Ms Sql Server. First i have created OLEDB Adapter in which i have passed select statement and connection string of MS Excel. Then i populated DataSet object with OLEDB adapter. Now i have to import the table in SQLServer Databse which i populated in DataSet from OLEDB Adapter.
7
12060
by: TG | last post by:
hi! I am trying to create a sql server table from an excel sheet. Here is the code I have: 'This procedure the xlsx file and dumps it to a table in SQL Server
1
7106
by: orked | last post by:
i tried to import excel file into gridview but the code made this exception (Failed to map this path''xmlTest.xml") i don't know why my code: public void fillGrid() { DataSet ds = new DataSet(); ds.ReadXml(Server.MapPath("../xmlTest.xml")); GridView1.DataSource = ds; GridView1.DataBind(); } protected void Page_Load(object sender, EventArgs e)
4
2815
by: orked | last post by:
i want to import excel file to gridview but there was error(Failed to map this path "/xmltest.xml") and i couldn't handle it my code: public void fillGrid() { DataSet ds = new DataSet(); ds.ReadXml(Server.MapPath("../xmltest.xml")); GridView1.DataSource = ds; GridView1.DataBind(); } protected void Page_Load(object sender, EventArgs e) {
0
8385
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8303
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8821
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8723
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8502
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6162
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4150
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
1941
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1601
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.