473,396 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Import XML Excel into dataset

Hi - can you help please?

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

----------------------------------------------------------------
Dim originalxmlsource As New DataSet
Dim xmlfilename As String = Request.PhysicalApplicationPath _ &
"myfilename.xml"
MyDataGrid.DataSource = originalxmlsource
MyDataGrid.DataBind()
----------------------------------------------------------------

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 5063
Have you looked at the DataSet.ReadXml() method?

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

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

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

----------------------------------------------------------------
Dim originalxmlsource As New DataSet
Dim xmlfilename As String = Request.PhysicalApplicationPath _ &
"myfilename.xml"
MyDataGrid.DataSource = originalxmlsource
MyDataGrid.DataBind()
----------------------------------------------------------------

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 originalxmlsource As New DataSet
Dim xmlfilename As String = Request.PhysicalApplicationPath _ &
"myfilename.xml"
originalxmlsource.ReadXml(xmlfilename)
MyDataGrid.DataSource = originalxmlsource
MyDataGrid.DataBind()
----------------------------------------------------------------

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******@alexshirley.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 originalxmlsource As New DataSet
Dim xmlfilename As String = Request.PhysicalApplicationPath _ &
"myfilename.xml"
originalxmlsource.ReadXml(xmlfilename)
MyDataGrid.DataSource = originalxmlsource
MyDataGrid.DataBind()
----------------------------------------------------------------

Nov 19 '05 #4
Hi Curt

This line gets "Specified cast is not valid":
originalxmlsource.ReadXml(xmlfilename)

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******@alexshirley.com" wrote:
Hi Curt

This line gets "Specified cast is not valid":
originalxmlsource.ReadXml(xmlfilename)

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******@alexshirley.com> wrote in message
news:11*********************@o13g2000cwo.googlegro ups.com...
Hi - can you help please?

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

----------------------------------------------------------------
Dim originalxmlsource As New DataSet
Dim xmlfilename As String = Request.PhysicalApplicationPath _ &
"myfilename.xml"
MyDataGrid.DataSource = originalxmlsource
MyDataGrid.DataBind()
----------------------------------------------------------------


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******@alexshirley.com> wrote in message
news:11*********************@o13g2000cwo.googlegro ups.com...
Hi - can you help please?

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

----------------------------------------------------------------
Dim originalxmlsource As New DataSet
Dim xmlfilename As String = Request.PhysicalApplicationPath _ &
"myfilename.xml"
MyDataGrid.DataSource = originalxmlsource
MyDataGrid.DataBind()
----------------------------------------------------------------


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
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...
3
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...
0
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...
10
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...
4
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...
2
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...
7
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
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 =...
4
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.