|
|
@@ -1,5 +1,6 @@
|
|
|
package cn.hutool.poi.excel;
|
|
|
|
|
|
+import java.awt.Point;
|
|
|
import java.io.BufferedInputStream;
|
|
|
import java.io.File;
|
|
|
import java.io.InputStream;
|
|
|
@@ -9,8 +10,10 @@ import cn.hutool.core.exceptions.DependencyException;
|
|
|
import cn.hutool.core.io.FileUtil;
|
|
|
import cn.hutool.core.io.IoUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
+import cn.hutool.core.util.ReUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import cn.hutool.poi.PoiChecker;
|
|
|
+import cn.hutool.poi.excel.cell.CellLocation;
|
|
|
import cn.hutool.poi.excel.sax.Excel03SaxReader;
|
|
|
import cn.hutool.poi.excel.sax.Excel07SaxReader;
|
|
|
import cn.hutool.poi.excel.sax.handler.RowHandler;
|
|
|
@@ -560,7 +563,7 @@ public class ExcelUtil {
|
|
|
}
|
|
|
int remainder = index % 26;
|
|
|
colName.append((char) (remainder + 'A'));
|
|
|
- index = (int) ((index - remainder) / 26);
|
|
|
+ index = (index - remainder) / 26;
|
|
|
} while (index > 0);
|
|
|
return colName.reverse().toString();
|
|
|
}
|
|
|
@@ -585,4 +588,18 @@ public class ExcelUtil {
|
|
|
}
|
|
|
return index;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 将Excel中地址标识符(例如A11,B5)等转换为行列表示<br>
|
|
|
+ * 例如:A11 -》 x:0,y:10,B5-》x:1,y:4
|
|
|
+ *
|
|
|
+ * @param locationRef 单元格地址标识符
|
|
|
+ * @return 坐标点,x表示行,从0开始,y表示列,从0开始
|
|
|
+ * @since 5.1.4
|
|
|
+ */
|
|
|
+ public static CellLocation toLocation(String locationRef){
|
|
|
+ final int x = colNameToIndex(locationRef);
|
|
|
+ final int y = ReUtil.getFirstNumber(locationRef) -1;
|
|
|
+ return new CellLocation(x, y);
|
|
|
+ }
|
|
|
}
|