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]

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