Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我目前正在做一个需要用 Java 编辑 XLS 的项目。xls 的第一行是具有列名的行。我想使用列名在下面的单元格中插入数据。我希望应用程序使用变量字符串来插入数据,而不是使用 getCell 插入前缀数字。(评论部分是我为自己写的信息;它可能有用)。
我会这样做:
Map
row.getCell (theNameIndexMap.get("A_COLUMN_NAME"))
并且,确保每个列名都是唯一的......
创建一个 Map 来存储 ColumnName 和 Index。
每当您需要将索引传递给单元格时,您都可以使用 objMap.get(columnName)。