緣起
public static void main(String[] args) throws IOException {
File file = new File("E:\\dz.xlsx");
XSSFWorkbook wb = new XSSFWorkbook(new FileInputStream(file));
//讀取第一個sheet
XSSFSheet st = wb.getSheetAt(0);
DecimalFormat decimalFormat = new DecimalFormat("0");
Map<String,String> map = new HashMap<>();
for (int rowIndex = 0; rowIndex <= st.getLastRowNum(); rowIndex++) {
//循環讀取目前sheet的每一行
XSSFRow row = st.getRow(rowIndex);
//getCell(0)代表讀取目前行第一個單元格的值
map.put(decimalFormat.format(row.getCell(0).getNumericCellValue()),row.getCell(1).getStringCellValue());
}
}