how to saving data in csv file

I have problem with saving data in csv file. I would like save my data look

like this example :

excel preview :

ABC

1 101112

2 131415

As we see all values are in separate cell A1=10, B1=11, C1=12 ...

so I try :

PrintWriter wy = new PrintWriter(new FileWriter("test.csv"));

values[0][0]="10";

values[0][1]="11";

values[0][2]="12";

values[1][0]="13";

values[1][1]="14";

values[1][2]="15";

for (String[] row : values){

for (String col : row) {

wy.print(col + "\t");

}

}

but csv file look like :

A1=10 11 12

A2=13 14 15

but B1-B2 and C1-C2 is empty

the second steep is use Ostermiller library :

OutputStream out;

out = new FileOutputStream("temp.csv");

CSVPrinter csvp = new CSVPrinter(out);

String[][] values = new String[2][3];

csvp.changeDelimiter('\t');

values[0][0]="10";

values[0][1]="11";

values[0][2]="12";

values[1][0]="13";

values[1][1]="14";

values[1][2]="15";

csvp.println(values);

but the result is also this same, is anyone do how to resolve this problem

?

[1205 byte] By [tomassa] at [2007-11-27 3:44:52]
# 1
In the first example, when you write the values to file, you're separating them by a tab, not a comma. For the second example, read the api for the CSVPrinter class to see how it handles printing an array.
hunter9000a at 2007-7-12 8:48:33 > top of Java-index,Java Essentials,Java Programming...
# 2
but iI don`t want to seperate with comma.... value I want to seperate each value to seperate cell
tomassa at 2007-7-12 8:48:33 > top of Java-index,Java Essentials,Java Programming...
# 3
From the wikipedia article on csv:CSV is a delimited data format that has fields/columns separated by the comma character and records/rows separated by newlines. http://en.wikipedia.org/wiki/Comma-separated_values
hunter9000a at 2007-7-12 8:48:33 > top of Java-index,Java Essentials,Java Programming...
# 4

> but iI don`t want to seperate with comma.... value I

> want to seperate each value to seperate cell

Try this: Create a CSV file. Like this example:I,do,not,know,what,I

am,talking,aboutNow use Excel to open it. Notice how the things that are separated by commas go into separate cells?

DrClapa at 2007-7-12 8:48:33 > top of Java-index,Java Essentials,Java Programming...
# 5
> but iI don`t want to seperate with comma.... value I> want to seperate each value to seperate cellWhen you save the file, separate w/ commaWhen excel loads it, it will automagicariffically put it in it's own cell.
xiarcela at 2007-7-12 8:48:33 > top of Java-index,Java Essentials,Java Programming...
# 6
I know this is no standart of csv file... but a I must do this...
tomassa at 2007-7-12 8:48:33 > top of Java-index,Java Essentials,Java Programming...
# 7

> > but iI don`t want to seperate with comma.... value

> I

> > want to seperate each value to seperate cell

>

> When you save the file, separate w/ comma

> When excel loads it, it will automagicariffically put

> it in it's own cell.

what it is "w/ " ? when I separate my data with comma excel don`t put value to spererate cells

tomassa at 2007-7-12 8:48:33 > top of Java-index,Java Essentials,Java Programming...
# 8

> > > but iI don`t want to seperate with comma....

> value

> > I

> > > want to seperate each value to seperate cell

> >

> > When you save the file, separate w/ comma

> > When excel loads it, it will automagicariffically

> put

> > it in it's own cell.

>

> what it is "w/ " ? when I separate my data with

> comma excel don`t put value to spererate cells

"w/" is an abbreviation of "with". Post the code that doesn't work, along with the results you get. If it's not working with commas, you must be doing something else wrong.

hunter9000a at 2007-7-12 8:48:33 > top of Java-index,Java Essentials,Java Programming...