PrintStream+xls

Hi,

I want to save the output of a java method in .xls file. First, I opend a stream, and then read the results to the file. The code is below:

PrintStream p =new PrintStream("D:\\MATLAB7\\work\\output22.xls");

:

:

(some functions to calculate the output

:

:

String str = String.valueOf(arrival);

String strI = String.valueOf(i);

p.append(str);

//p.append('\t');

p.append(strI);

p.println();

:

The stream prints the results in .xls files.

The file:

0.081621006

0.094000893

0.155322868

0.262710551

1.046466029

1.320833321

1.336691494

1.386425201

1.649759643

1.830757861

1.859104125

1.980647487

2.565540707

2.565540707

The strange thing is that the xls file is not recognized when I call it in MatLab. My question is: is there any hidden bytes that are printed in the .xls file when using PrintStream. This because I tried cpoying the same data (the above) in a new xls file (without using java), and the MatLab recognized it. What is going on? Can anybody help me?

[1249 byte] By [MoonSpotLighta] at [2007-11-27 2:41:49]
# 1

The Excel .xls format is a proprietary binary format. The file you produced has the right extension, but the wrong format.

I recommend you use a simple text format such as tab delimited, if Matlab supports that.

If you must write true Excel files, you'll need to use one of the libraries that support this, like POI

armalcolma at 2007-7-12 3:06:01 > top of Java-index,Java Essentials,Java Programming...