473,378 Members | 1,543 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,378 software developers and data experts.

XML + XSL + JAVA= Excel Help me to convert please! :D

budigila
Hiya peeps,

Okies, I have been trying to work this out for a while now to no avail... I am a beginner to this whole coding thing but have made great strides in my project. Basically what I am trying to do is to convert an .xml using a .xsl to and using a java script to output it into a readable format within excel. I have been able to successfully use a javascript to combine my .xml and .xsl but cannot figure out how to have it output to excel. Please help if possible!

And if thats easy enough what about fomatting my time and date in (DD/MM/YY HH:mm:ss)

Thanks in advance!

Here are the files I have been working with:

JAVASCRIPT

<%
response.setContentType("application/vnd.ms-excel");
%>


<html>
<body>

<script type="text/javascript">
//Load XML
var xml=new ActiveXObject("Microsoft.XMLDOM")
xml.async=false
xml.load("test.xml")

//Load the XSL
var xsl=new ActiveXObject("Microsoft.XMLDOM")
xsl.async=false
xsl.load("test.xsl")

//Transform
document.write(xml.transformNode(xsl))

</script>

</body>
</html>


XSL FILE

<?xml version="1.0" encoding="ISO-8859-1" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<!-- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -->
<html>

<head>
<link rel="stylesheet" type="text/css" href="C:\test.css" />
</head>

<body>

<div id="container">

<div class="tableContainer">

<table class="report">

<tbody>

<xsl:for-each select="fasting/pickups/pickup">

<tr>

<td class="Passing"><xsl:text/></td>

<td class="Type"><xsl:text/>Pickup</td>

<td class="Object"><xsl:value-of select="@id"/></td>

<td class="Begining"><xsl:value-of select="@begin"/></td>

<td class="Halting"><xsl:value-of select="@halt"/></td>

<td class="Length"><xsl:text/></td>

<td class="Status"><xsl:text/>X</td>

<td class="Begining"><xsl:text/></td>

<td class="Halting"><xsl:text/></td>

<td class="Length"><xsl:text/></td>

<td class="FRP"><xsl:value-of select="@frp"/></td>

<td class="Dome"><xsl:value-of select="load/@dome"/></td>

<td class="Timely"><xsl:value-of select="load/@timely"/></td>

<td class="Pri"><xsl:text/></td>

<td class="Notes"><xsl:text/></td>

</tr>

</xsl:for-each>

<xsl:for-each select="fasting/putdown/airline">

<tr>

<td class="Passing"><xsl:text/></td>

<td class="Type"><xsl:text>Putdown </xsl:text>

<xsl:value-of select="@id"/></td>

<td class="Object"><xsl:value-of select="file/@id"/></td>

<td class="Begining"><xsl:value-of select="@begin"/></td>

<td class="Halting"><xsl:value-of select="@halt"/></td>

<td class="Length"><xsl:text/></td>

<td class="Status"><xsl:text/>X</td>

<td class="Begining"><xsl:text/></td>

<td class="Halting"><xsl:text/></td>

<td class="Length"><xsl:text/></td>

<td class="PRF"><xsl:value-of select="@prf"/></td>

<td class="Dome"><xsl:value-of select="load/@dome"/></td>

<td class="Timely"><xsl:value-of select="load/@timely"/></td>

<td class="Prioroity"><xsl:text/></td>

<td class="Notes"><xsl:text/></td>

</tr>

</xsl:for-each>

</tbody>

</table>
</div>
</div>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

XML FILE

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="C:\Test.xsl" ?>
<fasting begin="09 27 2007 15:46:59" halt="09 28 2007 15:37:43">
<pickups>
<pickup id="data4321093" begin="09 27 2007 10:46:59" halt="09 27 2007 10:47:05" frp="false">
<load id="X" dome="005" timely="BB"></load>
</pickup>
<pickup id="data123411" begin="09 27 2007 11:43:16" halt="09 27 2007 11:55:49" frp="false">
<load id="Y" dome="003" timely="BB"></load>
</pickup>
<pickup id="data432113" begin="09 27 2007 12:26:34" halt="09 27 2007 12:26:40" frp="false">
<load id="X" dome="001" timely="BB"></load>
</pickup>
<pickup id="data1234111" begin="09 27 2007 13:35:30" halt="09 27 2007 13:44:54" frp="false">
<load id="Y" dome="002" timely="BB"></load>
</pickup>
<pickup id="data4321121" begin="09 27 2007 14:03:54" halt="09 27 2007 14:11:19" frp="false">
<load id="X" dome="102" timely="BB"></load>
</pickup>
<pickup id="data1234131" begin="09 27 2007 20:43:41" halt="09 27 2007 21:01:18" frp="false">
<load id="Y" dome="001" timely="BB"></load>
</pickup>
<pickup id="data1234141" begin="09 27 2007 22:37:54" halt="09 27 2007 22:41:10" frp="false">
<load id="Y" dome="004" timely="BB"></load>
</pickup>
<pickup id="data1234011" begin="09 28 2007 01:59:33" halt="09 28 2007 02:09:02" frp="false">
<load id="Y" dome="002" timely="BB"></load>
</pickup>
<pickup id="data4321013" begin="09 28 2007 03:45:57" halt="09 28 2007 03:46:03" frp="false">
<load id="X" dome="004" timely="BB"></load>
</pickup>
<pickup id="data4321021" begin="09 28 2007 04:40:54" halt="09 28 2007 04:48:49" frp="false">
<load id="X" dome="102" timely="BB"></load>
</pickup>
<pickup id="data4321023" begin="09 28 2007 05:31:04" halt="09 28 2007 05:31:10" frp="false">
<load id="X" dome="001" timely="BB"></load>
</pickup>

<pickup id="data1234081" begin="09 28 2007 14:15:45" halt="09 28 2007 14:19:01" frp="false">
<load id="Y" dome="004" timely="BB"></load>
</pickup>
<pickup id="data4321083" begin="09 28 2007 14:57:57" halt="09 28 2007 14:58:03" frp="false">
<load id="X" dome="001" timely="BB"></load>
</pickup>
<pickup id="data4321091" begin="09 28 2007 15:06:32" halt="09 28 2007 15:06:38" frp="false">
<load id="X" dome="101" timely="BB"></load>
</pickup>
<pickup id="data4321093" begin="09 28 2007 15:37:37" halt="09 28 2007 15:37:43" frp="false">
<load id="X" dome="001" timely="BB"></load>
</pickup>
</pickups>
<putdown>
<airline id="R" begin="09 27 2007 16:11:37" halt="09 27 2007 16:26:37">
<file id="data4321093" last="true"></file>
</airline>
<airline id="R" begin="09 28 2007 00:42:55" halt="09 28 2007 00:57:55"></airline>
<airline id="R" begin="09 28 2007 01:26:30" halt="09 28 2007 01:38:34">
<file id="data1234011" last="true"></file>
</airline>
<airline id="R" begin="09 28 2007 02:25:10" halt="09 28 2007 02:40:10">
<file id="data4321013" last="true"></file>
</airline>
<airline id="R" begin="09 28 2007 03:08:45" halt="09 28 2007 03:19:53">
<file id="data4321021"></file>
</airline>
<airline id="R" begin="09 28 2007 04:07:26" halt="09 28 2007 04:22:26">
<file id="data4321021" last="true"></file>
<file id="data4321023" last="true"></file>
</airline>
<airline id="R" begin="09 28 2007 04:51:01" halt="09 28 2007 05:02:26">
<file id="data4321032" last="true"></file>
</airline>
<airline id="R" begin="09 28 2007 05:49:42" halt="09 28 2007 06:04:42">
<file id="data4321033" last="true"></file>
</airline>
<airline id="R" begin="09 28 2007 06:33:16" halt="09 28 2007 06:48:00">
<file id="data1234041" last="true"></file>
</airline>
<airline id="R" begin="09 28 2007 07:31:57" halt="09 28 2007 07:46:57">
<file id="data4321042" last="true"></file>
</airline>
<airline id="R" begin="09 28 2007 08:16:00" halt="09 28 2007 08:30:42"></airline>
<airline id="R" begin="09 28 2007 09:57:48" halt="09 28 2007 10:10:09">
<file id="data4321052" last="true"></file>
<file id="A807" last="true"></file>
</airline>
<airline id="R" begin="09 28 2007 10:56:28" halt="09 28 2007 11:11:28">
<file id="data4321061" last="true"></file>
</airline>
<airline id="R" begin="09 28 2007 11:40:03" halt="09 28 2007 11:51:18"></airline>
<airline id="R" begin="09 28 2007 12:38:44" halt="09 28 2007 12:53:44">
<file id="data1234071" last="true"></file>
</airline>
<airline id="R" begin="09 28 2007 14:20:59" halt="09 28 2007 14:35:59">
<file id="data1234081" last="true"></file>
<file id="data4321083" last="true"></file>
</airline>
<airline id="R" begin="09 28 2007 15:04:34" halt="09 28 2007 15:19:25"></airline>
</putdown>
</fasting>
Oct 9 '07 #1
2 5170
MarkoKlacar
296 Expert 100+
Hi,

I think you should look at how an Excel file is constructed "inside" so to speak. What you'll probably do after this is create a new XSL transformation that makes it format the way Excel likes it.

Hope this helped
Oct 9 '07 #2
jkmyoung
2,057 Expert 2GB
A minimalist Excel sheet in xml form looks like the following:
Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0"?>
  2. <?mso-application progid="Excel.Sheet"?>
  3. <Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
  4.  xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet">
  5.  <Worksheet ss:Name="Sheet1">
  6.   <Table>
  7.    <Row>
  8.     <Cell><Data ss:Type="String">a</Data></Cell>
  9.     <Cell><Data ss:Type="String">b</Data></Cell>
  10.    </Row>
  11.    <Row>
  12.     <Cell><Data ss:Type="String">c</Data></Cell>
  13.     <Cell><Data ss:Type="String">d</Data></Cell>
  14.    </Row>
  15.   </Table>
  16.  </Worksheet>
  17. </Workbook>
  18.  
Use this as your shell in your main template.
Then in your stylesheet, do several replaces.

Replace:
<tr> with <Row>
</tr> with </Row>
<td> with <Cell><Data ss:Type="String"> (or pick a different datatype if you want).
</td> with </Data></Cell>

Hope this gives you a good starting point.
Note, if you open this file in excel and resave, it will add more information. The layout provided is minimal.
Oct 9 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: Dr. Mercury | last post by:
Greetings to all - Someone suggested that Java might be the answer for a little conversion program I need. It's pretty simple, really. Just take a column of numbers: 139 259 433 637
11
by: DrUg13 | last post by:
In java, this seems so easy. You need a new object Object test = new Object() gives me exactly what I want. could someone please help me understand the different ways to do the same thing in...
4
by: Krishna | last post by:
Hi all, I have a Java wrapper program which I need to access in Visual Basic / VBA. I am trying to read some objects and methods and get data from the java and genenerate an Excel file for the...
1
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course tutors are going to be teaching us JAVA wth bluej...
3
by: Bharathi | last post by:
Hi, I got strucked with reading date value from excel file using C#.NET. For Jan-2000 the value I am getting is 36526.0. For all other dates also I am getting some double value like this. ...
0
by: saaprasad2002 | last post by:
i opened an excel application using follwing code to load test data to run mstest cases Public Class ExcelMatrixReader Public oXL As Excel.Application Public oWB As Excel.Workbook ...
0
by: Anish G | last post by:
Hi All, I am getting the below given error while running my application in live server. In my local machine, its working fine. Please help me as it is very urgent for me. Exception from...
0
by: ilamittal | last post by:
My problem is ,i have one repeater control.In that the data is binding at BtnGo click. In that if there are two same vehicle no but they service payments are different ,so after completing the data...
0
by: Raymond Chiu | last post by:
Dear all, In my vb.net program, I am using excel object to create excel file and stored in a folder. How can it be converted to be pdf file automatically using dotnet coding or others? Actually...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.