0
我有一個Excel的格式如下如何從excel中匹配特定條件的值並將其分配給數組?
Category Name Title
Map Map1 Title Automaition Map1
Topic Topic1 Title Automaition Topic1
Topic Topic2 Title Automaition Topic2
Submap Submap1 Title Automaition Submap1
Sub Topic SubTop1 Title Automaition SubTopic1
我想借此從標題列中的值對所有類別的主題,並存儲在一個數組。我寫了下面的代碼,以從標題列中的值進行分類爲主題
public class DitaExcel {
@Test
public void Test() throws IOException {
{
FileInputStream file = new FileInputStream(new File("C://DitaExchange.xlsx"));
//Create Workbook instance holding reference to .xlsx file
XSSFWorkbook workbook = new XSSFWorkbook(file);
//Get first/desired sheet from the workbook
XSSFSheet sheet = workbook.getSheetAt(0);
for (Row row : sheet) {
for (Cell cell : row) {
CellReference cellRef = new CellReference(row.getRowNum(), cell.getColumnIndex());
switch (cell.getCellType()) {
case Cell.CELL_TYPE_STRING:
if (cell.getRichStringCellValue().getString().equalsIgnoreCase("Topic"))
{
System.out.println(row.getCell(2));
break;
}
break;
}}}}}}
我得到的值作爲 標題Automaition TOPIC1 標題Automaition TOPIC2
但我想裏面捕獲這些值數組。我如何捕獲數組中的這些值。我期待我的輸出是這樣
{標題Automaition TOPIC1,標題Automaition TOPIC2}
是否有人可以幫忙嗎?
感謝
謝謝,我能夠保存在你的代碼的數組值。 – Naseem