Come on, if I understand correctly you want to pick a date and increment 1 day each time you pass the loop, ex:
10/02/2012
11/02/2012
12/02/2012
For that you can use the Classe
Calendar to add days in a date, ex:
calendar.add(Calendar.DAY_OF_MONTH, 1);
In your case you need that number of days to be incremented according to your tie. You can create a method to do the date conversion and assign the days:
public String stringToCalendar(String date, int i) throws ParseException {
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
Calendar calendar = Calendar.getInstance();
calendar.setTime(sdf.parse(date));
calendar.add(Calendar.DAY_OF_MONTH, i);
return sdf.format(calendar.getTime());
}
This method takes two parameters, the first is the date you want to pass which in the case is "10/02/2012"
and the next will be the rowIndex
to increase it on date.
Your Lasso would look that way:
for (int rowIndex = 0; rowIndex <= 10; rowIndex++) {
//Chama o método que converte uma String pra Calendar e incrementa o rowIndex na data
String date = stringToCalendar("10/02/2012", rowIndex);
Row rowsx = sheet1.createRow(rowIndex);
HSSFRow rowx = sheet1.getRow(rowIndex);
Cell data = rowx.createCell(0);
//Passa a string que foi retornada para a celula
data.setCellValue(date);
}
Exit:
You can put what you’ve done?
– DiegoAugusto
added code, in case each lop of for it has to auto increment that date set initially, equal in execel with the fill serie option.
– Fernando josé
Beauty, you want to add date in series? ex: 10/02/2012, 11/02/2012.. ?
– DiegoAugusto
Yeah, that’s right
– Fernando josé