1 通过行列获取区域
/** * 获取区域 Region * @param sheet * @param row * @param column * @return */ public static int getMergedRegionIndex(Sheet sheet, int row, int column) { int sheetMergeCount = sheet.getNumMergedRegions(); for (int i = 0; i < sheetMergeCount; i++) { CellRangeAddress ca = sheet.getMergedRegion(i); int firstColumn = ca.getFirstColumn(); int lastColumn = ca.getLastColumn(); int firstRow = ca.getFirstRow(); int lastRow = ca.getLastRow(); if (row >= firstRow && row <= lastRow) { if (column >= firstColumn && column <= lastColumn) { return i; } } } return 0; }
2 删除区域
sheet.removeMergedRegion(getMergedRegionIndex(sheet, 1, 1));
3 清除行
sheet.removeRow(sheet.getRow(0));
4 删除行(注意:删除行前,须删除区域Region)
// 第1个参数 开始行 // 第2个参数 结束行 // 第3个参数 覆盖行数 // 第4个参数 是否带原格式copyRowHeight // 第5个参数 是否重设区域resetOriginalRowHeight sheet.shiftRows(8, 8, -3, true, true);
try { InputStream is = null; Workbook book = null; is = new FileInputStream("D:\\test.xls"); book = new HSSFWorkbook(is); Sheet sheet = book.getSheetAt(0); sheet.shiftRows(1, 1, -1); File f = new File("d:\\1.xls"); FileOutputStream out = new FileOutputStream(f); book.write(out); out.close(); is.close(); } catch (IOException e) { return; }
5 获取操作系统
public static void getProperties() { Properties prop = System.getProperties(); String os = prop.getProperty("os.name"); System.out.println(os); }
6 classLoader顺序
public static void getClassLoader() { System.out.println(ClassLoader.getSystemClassLoader()); System.out.println(ClassLoader.getSystemClassLoader().getParent()); System.out.println(ClassLoader.getSystemClassLoader().getParent().getParent()); }
7 汉字排序
public static void sortMap() { List list = new ArrayList(); ProductPos p = new ProductPos(); p.setPosId("2"); list.add(p); p = new ProductPos(); p.setPosId("张三"); list.add(p); p = new ProductPos(); p.setPosId("王武"); list.add(p); System.out.println(list); Collections.sort(list, new Comparator<ProductPos>() { public int compare(ProductPos arg0, ProductPos arg1) { return arg0.getPosId().compareTo(arg1.getPosId()); } }); System.out.println(list); //Collections.sort(list, (RuleBasedCollator )Collator.getInstance(Locale.CHINA)); Collections.sort(list, new Comparator<Date>() { public int compare(Date arg0, Date arg1) { return Collator.getInstance(Locale.CHINA).compare(arg0.getTime(), arg0.getTime()); } }); System.out.println(list); }
8 文件拷贝
public static void fileUpload(File file, String filename) { try { file.renameTo(new File(filename)); } catch (Exception e) { e.printStackTrace(); } }
相关推荐
poi获取exccel有合并单元格的数据,存入List
POI 删除excel列,可以设置多列,POI里怎么没有删除列的API呢
应用POI组件操作Excel
#encoding = utf-8 #本程序精致禁止用于商业活动仅供技术交流 #程序中**----**中的内容需要替换为自己...#程序可以获得信息,指定区域内,指定经营类型,终端门店信息 #程序可以循环运行,需要提供准确的对角经纬度坐标
poi3.0.1操作excel,包括新增,修改excel的操作
POI 经典 操作 java操作Excel第三方插件
poi读取excel不能直接获取行中的图片,可以通过图片中心所在行获取所在行图片
本资源《初始版本》是精简版,《PPT模板生成PPT》是实际项目中的例子,具体就是使用poi去操作PPT,替换PPT中特定的文本,用${key}这种标识在PPT中存放,java代码使用value去替换PPT中的${key},从而生成新的PPT供大家...
最近在学习POI POI的API没有真正的获取填写数据的行数 我在网上找到了 与其分享
java使用POI获取sheet、行数、列数
由于POI本身在处理docx文档上不完善,比如删除空白页等操作。这里,分享一个Demo项目,动态生成文档,并巧妙删除空白页。代码中含docx4j的可去除,其分页效果差,至于使用BlockPage对象需导一个Plutext-Enterprise的...
poi操作ppt图表史上最完整示例演示.zip 示例包含圆饼图、柱状图、线性图、面积图
python-to-amap 基于Python3实现高德地图POI检索数据获取,并写入json与exce文件。
poi操作excel2007
为更方便的使用POI的API来操作Excel(2003)文件,对POI中针对Excel文件的读写进行了简单封装。此类中包含以下功能: 1.根据模板创建Excel文件 2.获取及更新Excel文件内容 3.创建、复制Sheet 4.设置Sheet名称 ... ...
POI操作excel表格 讲的很详细,很有用
Apache POI Excel操作 需要的文档,.介绍,相关jar包,maven中的配置等,比较全面
poi获取图片位置,输出到指定位置
POI数据获取POI是“Point of Information”的缩写,中文可以翻译为“信息点”。在地理信息系统中,一个POI可以是一栋房子、一个商铺、一个邮筒、一个公交站等。
使用POI读写Word doc文件 Apache poi的hwpf模块是专门用来对word doc文件进行读写操作的。在hwpf里面我们使用HWPFDocument来表示一个word doc文档