Hi,
I am a newbie to POI.
I am trying to create a new excel from an existing Excel used as template
(has graphs derived out of the data). We know what is the template because
we will tell the customer to create the template.
I will be replacing data in the new sheet and graphs get auto generated too
(using dynamic excel).
After going through lot of things in the POI forum, I tried something very
simple :
Workbook myWorkBook = new XSSFWorkbook(new FileInputStream("Book4.xlsx"));
Sheet s = myWorkBook.getSheetAt(0); // I know this is the data sheet
Row r = s.createRow(6); // Adding row
Cell c = r.createCell(0); // Adding col - I know the number of columns
c.setCellValue("june");
....
FileOutputStream bos = new FileOutputStream("Book6.xlsx");
myWorkBook.write(bos);
bos.close();
I have 2 questions :
1. I want to make sure if the way I am doing is ok to do since I am able to
generate new excel with new data and graphs updated.
2. I want to set the timestamp format of a particular column. I am able to
get the cellstyle from known data column from template and set the same to
all the same columns like :
//Getting the style from existing cell
if (r.getCell(cellnum) != null) {
c = r.getCell(cellnum);
stylesMap.put(cellnum, c.getCellStyle());
}
//Setting the cellstyle to a new cell
if (stylesMap.get(cellnum) != null) {
c.setCellStyle(stylesMap.get(cellnum));
}
Is this ok to do or do I have to clone the style ? Or since I already know
the date/time format , set it newly from the code?
Thanks for any help.
--
View this message in context:
http://apache-poi.1045710.n5.nabble.com/Creating-a-new-Excel-file-from-a-template-copying-the-cellstyle-tp5711530.html
Sent from the POI - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]