LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   xml to xls (https://www.linuxquestions.org/questions/programming-9/xml-to-xls-266713/)

matt1982 12-15-2004 11:43 AM

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...

michux 12-15-2004 03:09 PM

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.

matt1982 12-15-2004 03:47 PM

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.

michux 12-15-2004 04:37 PM

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?

matt1982 12-16-2004 09:55 AM

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-com:office: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?

michux 12-16-2004 11:47 AM

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/


All times are GMT -5. The time now is 04:36 AM.