本文整理汇总了Java中org.apache.poi.hssf.util.CellRangeAddress类的典型用法代码示例。如果您正苦于以下问题:Java CellRangeAddress类的具体用法?Java CellRangeAddress怎么用?Java CellRangeAddress使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CellRangeAddress类属于org.apache.poi.hssf.util包,在下文中一共展示了CellRangeAddress类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createMergedRegionIfNotPresent
import org.apache.poi.hssf.util.CellRangeAddress; //导入依赖的package包/类
@SuppressWarnings("deprecation")
>>>>>>> fe2012a7f8558d8df36b789847bdc41c788d6eaf
public static void createMergedRegionIfNotPresent(XSSFSheet sheet,int firstRow, int lastRow, int firstCol, int lastCol){
String message="XSSFSheet must not be null!";
Objects.requireNonNull(sheet, () -> message);
sheet.addMergedRegion(new CellRangeAddress(firstRow, lastRow, firstCol, lastCol));
}
示例2: rowSpan
import org.apache.poi.hssf.util.CellRangeAddress; //导入依赖的package包/类
/**
* 合并单元格(行合并),合并规则:内容相同则合并
*
* @param sheet 合并的sheet
* @param colindex 合并列索引
* @return
*/
@SuppressWarnings("deprecation")
public static HSSFSheet rowSpan(HSSFSheet sheet, int colindex, int contentBeginIndex) {
// 总行数
int rowNum = sheet.getLastRowNum();
HSSFRow row = sheet.getRow(1);
// 正文内容应该从第二行开始,第一行为表头的标题
int startRow = contentBeginIndex;
String startValue = "";
for (int i = contentBeginIndex; i <= rowNum; i++) {
row = sheet.getRow(i);
String value = row.getCell(colindex).getRichStringCellValue().getString();
if (i == contentBeginIndex) {
startValue = value;
continue;
}
if (StrUtil.isNotBlank(startValue) && StrUtil.isNotBlank(value) && startValue.equals(value)) {
if (i == rowNum)
sheet.addMergedRegion(new CellRangeAddress(startRow, i , colindex, colindex));
else
continue;
} else {
if((i-1)>startRow)
sheet.addMergedRegion(new CellRangeAddress(startRow, i - 1, colindex, colindex));
startRow = i;
}
startValue=value;
}
return sheet;
}
示例3: createMergedRegionIfNotPresent
import org.apache.poi.hssf.util.CellRangeAddress; //导入依赖的package包/类
@SuppressWarnings("deprecation")
public static void createMergedRegionIfNotPresent(XSSFSheet sheet,int firstRow, int lastRow, int firstCol, int lastCol){
String message="XSSFSheet must not be null!";
Objects.requireNonNull(sheet, () -> message);
sheet.addMergedRegion(new CellRangeAddress(firstRow, lastRow, firstCol, lastCol));
}