---
title: "getPhysicalNumberOfCells 与 getLastCellNum的区别"
author: "wing123"
date: "2013-09-05T15:45:37Z"
tags: []
categories: ["移动开发"]
slug: "getphysicalnumberofcells-getlastcellnum"
draft: false
lastmod: "2013-09-05T15:45:37Z"
id: 1936924
url: "https://wing123.iteye.com/blog/1936924"
---

用org.apache.poi的包做excel导入，无意间发明若是excel文件中有空列，空列后面的数据全部读不到。查来查去本来是HSSFRow供给两个办法：getPhysicalNumberOfCells和getLastCellNum。 

getPhysicalNumberOfCells 是获取不为空的列个数。 

getLastCellNum 是获取最后一个不为空的列是第几个。 

同样，HSSFSheet获取行也有类似两个办法，若是excel数据中存在空行或空列，必须用getLast\*\*的办法才干完全读取数据。