Viewing XML in Excel oddity

dgorka

Well-known member
Joined
Dec 27, 2006
Messages
88
Programming Experience
5-10
I'm creating reports for an application that are viewable in a datagridview. Then if the user presses a button, it will allow them to open a report in Excel for them to print. Now, the way I'm doing this is to pass my dataset into an XML file, then open the XML in excel. I have all that working fine, the problem is this:

When I look at the Excel spreadsheet, my columns are out of order, and one is listed twice. I thought at first that maybe it had something to do with the way I was opening the XML into Excel through code, so I opened Excel and manually opened the XML file that way. I got the same results.

Has anyone else had this problem? Or know of a way to fix it? I can't figure it out for the life of me, and my co-workers are stumped as well. If anyone could try and help me, it would be much appreciated.

Thank you.

P.S. I know that it would be easier to do a crystal report, however, I haven't worked with them very much and due to time constraints, don't have the time to learn and implement it. Eventually thats what I'm going to switch it to, but with my deadline for the alpha version quickly approaching I don't have time right now. Thank you.
 
Is this using the DataSetXML-to-ExcelXML transform that I gave you? I'd be keen to know if it was somehow broken, so I
a) dont hit the same issue with my reporting
b) dont give bad advice to others..

Thanks!
 
No, what I'm doing is declaring a filestream, then doing dataset.WriteXML(FileStream). Here's the code I'm using:
dsReports is my dataset

'create the file name to write to
Dim XMLFileName As String = "Report.xml"

'create the Filestream to write with
Dim XMLStream As New FileStream(XMLFileName, FileMode.Create)

'write to the XML file with the WriteXml Methode
dsReports.WriteXml(XMLStream)

XMLStream.Close()
I've found a quick solution in programming in the object model to reorder the columns and drop the copied one, which is an easy way to do it i guess.
 
Back
Top