简体   繁体   中英

How can I add values to a specific column of an excel file

I have a List of Maps like:

[
{Er_NO=123, ER_Name=ABC, ER_Code=A01}, 
{Er_NO=789, ER_Name=GHI, ER_Code=C01}, 
{Er_NO=456, ER_Name=DEF, ER_Code=B01}
]

Now I need to insert these values in a new Excel file based on a specific column. Lets say, the mapping is something like:

Er_NO : C
ER_Name : E
ER_Code : G

where C, E and G are the columns in the excel file.

I know how to add the values row-wise by creating new rows and keep adding the values using POI but I am not sure how to add the values in specific columns. Can somebody plz help?

specified the column using column id

XSSFCell cell = sheet.getRow(0).getCell(0); // 0 = id of the 1th row, 0 = id of the 1st (A) column

specified the column using column name

XSSFCell cell = sheet.getRow(0).getCell(CellReference.convertColStringToIndex("A"));

then add value into the desired cell

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM