so what i am trying to accomplish is to write an array of data down each cell of the column for as many array elements that i have. i want i too look like this in excel:
buyer | parts | price| quantity | comments
tom | blah | 546 | 5 | blah
| blah | 56 | 67 |
my file has manyyyyy more columns than this but i wanted to give a brief example. what also creates my problem is that i dont want to print the next column after it on the last row that the writer is on once its done my array data set, so i want it to be on that forst line. i have looked into other libraries for accomplishing this, but there is nothing that i can find that seems to meet my needs. i do understand the nature of CSV file may not allow this to happen, without manually adding in blank cells, but is there any other way to do this?
Enumeration <String> paramNames = request.getParameterNames();
while(paramNames.hasMoreElements())
{
String paramName = (String)paramNames.nextElement();
writer.append(paramName);
writer.append(',');
String[] paramValues = request.getParameterValues(paramName);
if (paramValues.length == 1)
{
String paramValue = paramValues[0];
if (paramValue.length() == 0)
{
writer.append("No Value");
writer.append('\n');
}
else
{
writer.append(paramValue);
writer.append('\n');
}
}
else
{
for(int i = 0; i<paramValues.length; i++)
{
writer.append(paramValues[i]);
writer.append(',');
}
writer.append('\n');
}
previousname = paramName;
}
writer.flush();
writer.close();
}
also to clarify where this data is coming from, a JSP table thats in the middle of the form, so i am reading in arrays of values that are in the table.