LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-15-2004, 11:43 AM   #1
matt1982
Member
 
Registered: Nov 2004
Location: ontario, canada
Distribution: debian
Posts: 52

Rep: Reputation: 15
Unhappy xml to xls


ok i'm here again, bugging you guys, but i really need help, yesterday i was trying to figure out how to get the values off of the url and save it to a file, done, got it, saved it as an xml structured file, fine got that too...

BUT now i'm trying and this is the last thing, i have to save it as an excel file .xls.... i know that excel will open the xml file but i need it structured as an xls,

HOW can i do this, what are the headers, <ROW>... things like that... i don't know where to begin on this one, I take the info from the url have it in a variable but how can i structure it so that anyone can open it with excel as an xls sturtured file,

can anyone hlep me...
 
Old 12-15-2004, 03:09 PM   #2
michux
Member
 
Registered: Nov 2004
Location: Warsaw, Poland
Distribution: Ubuntu
Posts: 76

Rep: Reputation: 15
You can just change the mime type of the page from something like "text/html; charset=ISO-8859-1" to "application/vnd.ms-excel".
That should open the file in browser using Excel or OpenOffice Calc and display the items correctly in rows and cols.
 
Old 12-15-2004, 03:47 PM   #3
matt1982
Member
 
Registered: Nov 2004
Location: ontario, canada
Distribution: debian
Posts: 52

Original Poster
Rep: Reputation: 15
hmm, i kinda know what you mean but not really sure how to apply it to what i'm trying to do, gotta remember that i'm new at this. :P...

is there something, links, examples i could check out on this matter, google isn't helping much,

because in my head xml and xls isn't much different xls has <ROW>... and so on, but i created an excel document and saved it as an xml and the overhead is what gets me, i can't store it the same way? or can i, i'm really not clear on how to proceed on storing log files such that they can be opened as excel files,

application/vnd.ms-excel... hmm i'm not even sure how to implement this...

maybe i'm a hopeless cause but i appreciate any help i receive.
 
Old 12-15-2004, 04:37 PM   #4
michux
Member
 
Registered: Nov 2004
Location: Warsaw, Poland
Distribution: Ubuntu
Posts: 76

Rep: Reputation: 15
Well I'm not sure what you're trying to do. If you have a XML file it has to have some syntax, every XML file is different so there is no way you can just view it in excel, in rows and cols, somehow automagically.
You can use XSLT transformations to generate a HTML file out of it and then apply what I said with the mime info.
But first tell us what does your XML file look like, where did you get it/ generate it from and what exactly you need to to - how would you like it to look in excel and how does it look now?
 
Old 12-16-2004, 09:55 AM   #5
matt1982
Member
 
Registered: Nov 2004
Location: ontario, canada
Distribution: debian
Posts: 52

Original Poster
Rep: Reputation: 15
ok, the way it is right now, i have 3 compnents the contactid, date, and the file they downloaded,
<?xml version='1.0'?>
<CONTACTS>
<CONTACT>
<Id>1233</Id>
<Date_Submitted>2004-12-13 16:56:26</Date_Submitted>
<File_Downloaded>1233</File_Downloaded>
</CONTACT>

well that's the output that's created by my program,

$output = $output."<CONTACT>\n";
$output = $output."<Id>".$cid."</Id>\n";
$output = $output."<Date_Submitted>".date("Y-m-d H:i:s")."</Date_Submitted>\n";
$output = $output."<File_Downloaded>".$cid."</File_Downloaded>\n";
$output = $output."</CONTACT>\n";
$output = $output."</CONTACTS>";
...............................................................................
now what i'm trying to do is of instead of having it save to my file like this, the xml structured way, now what i'm trying to figure out is how to save it or "structure" it so that it's like an excel file with the .xls extention by definine the rows, columns, things like that. WHAT i have done is that i created an .xls file and saved it as xml and this is the output
......
<Alignment ss:Vertical="Bottom"/>
<Borders/>
<Font/>
<Interior/>
<NumberFormat/>
<Protection/>
</Style>
</Styles>
<Worksheet ss:Name="Sheet1">
<Table ss:ExpandedColumnCount="3" ss:ExpandedRowCount="2" x:FullColumns="1"
x:FullRows="1">
<Row>
<Cell><Data ss:Type="String">hello</Data></Cell>
<Cell><Data ss:Type="String">oh</Data></Cell>
<Cell><Data ss:Type="String">wonderful</Data></Cell>
</Row>
<Row>
<Cell><Data ss:Type="String">world.</Data></Cell>
</Row>
</Table>
<WorksheetOptions xmlns="urn:schemas-microsoft-comffice:excel">
<Selected/>
<Panes>
......
well that's part of it, it's to big for this, but this is what i wanna know, because this excel file is then going to be used to track who click on what, you know?.... by tracking there id's when, and what they click/downloaded.

does this help?
 
Old 12-16-2004, 11:47 AM   #6
michux
Member
 
Registered: Nov 2004
Location: Warsaw, Poland
Distribution: Ubuntu
Posts: 76

Rep: Reputation: 15
Well there can be a few solutions, one being create a native Excel file using tools available in PHP (cuz this is the language you're using, right?).
Another way would be the one I wrote of before.
Use XSLT transformations to generate a file you need basing on the XML you generate. XSL can produce many formats, like HTML (understandable by Excel), PDF, and many more. You'l have to read a lot though. Good source of information on XSLT is http://www.zvon.org/xxl/XSLTreference/Output/
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
checking for XML::Parser... configure: error: XML::Parser perl module is required for kornerr Linux - General 11 11-16-2008 07:24 AM
database or xls doc? mifan Programming 6 09-05-2005 04:22 PM
sql to xls j.vilon Linux - Newbie 20 11-04-2004 12:08 PM
.doc, .xls & .jpg became 0kb paeng16 General 1 07-30-2004 08:21 AM
export .xls into a mysql table anyone? h/w Programming 1 03-17-2004 10:36 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:16 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration