use of org.apache.poi.hssf.usermodel.HSSFRow in project financial by greatkendy123.
the class ExportTGExcel method setWaizhaiData.
/**
* 设置外债的Excel数据
* @time 2018年3月20日
* @param workbook
* @param excelModel
*/
private void setWaizhaiData(HSSFWorkbook workbook, TGExcelModel excelModel) {
HSSFSheet sheet = workbook.createSheet(excelModel.getSheetName());
Map<String, List<Object[]>> waizhaiMap = excelModel.getWaizhaiMap();
// 获取列头样式对象
HSSFCellStyle columnTopStyle = this.getColumnTopStyle(workbook);
// 单元格样式对象
HSSFCellStyle style = this.getStyle(workbook);
// 第几个表
int index = 1;
for (Map.Entry<String, List<Object[]>> entry : waizhaiMap.entrySet()) {
HSSFRow r = sheet.getRow(1);
if (r == null)
r = sheet.createRow(1);
int start = (index - 1) * 3;
int end = (index - 1) * 3 + 1;
// 标题
String teamString = entry.getKey();
HSSFCell cellName = r.createCell((index - 1) * 3);
cellName.setCellType(HSSFCell.CELL_TYPE_STRING);
HSSFRichTextString text = new HSSFRichTextString(teamString.split("#")[0]);
cellName.setCellValue(text);
cellName.setCellStyle(columnTopStyle);
cellName = r.createCell((index - 1) * 3 + 1);
cellName.setCellType(HSSFCell.CELL_TYPE_STRING);
text = new HSSFRichTextString(teamString.split("#")[1]);
cellName.setCellValue(text);
cellName.setCellStyle(columnTopStyle);
// 外债明细
int i = 1;
List<Object[]> waizhaiList = entry.getValue();
for (Object[] obj : waizhaiList) {
HSSFRow row = sheet.getRow(i + 1);
if (row == null) {
row = sheet.createRow(i + 1);
row.setHeight((short) 400);
}
HSSFCell type = row.createCell(start, HSSFCell.CELL_TYPE_STRING);
type.setCellStyle(style);
type.setCellValue(obj[0].toString());
HSSFCell sum = row.createCell(start + 1, HSSFCell.CELL_TYPE_STRING);
sum.setCellStyle(style);
sum.setCellValue(obj[1].toString());
sheet.setColumnWidth((i - 1) * 3, 3500);
sheet.setColumnWidth((i - 1) * 3 + 1, 3500);
i += 1;
}
index += 1;
}
}
use of org.apache.poi.hssf.usermodel.HSSFRow in project bitcampSCOpen2017 by ryuyj.
the class MemberListXlsView method createColumnLabel.
private void createColumnLabel(HSSFSheet sheet) {
HSSFRow firstRow = sheet.createRow(0);
HSSFCell cell = firstRow.createCell(0);
cell.setCellValue("회원번호");
cell = firstRow.createCell(1);
cell.setCellValue("이메일");
cell = firstRow.createCell(2);
cell.setCellValue("이름");
cell = firstRow.createCell(3);
cell.setCellValue("가입일");
}
use of org.apache.poi.hssf.usermodel.HSSFRow in project bitcampSCOpen2017 by ryuyj.
the class MemberListXlsView method createColumnLabel.
private void createColumnLabel(HSSFSheet sheet) {
HSSFRow firstRow = sheet.createRow(0);
HSSFCell cell = firstRow.createCell(0);
cell.setCellValue("회원번호");
cell = firstRow.createCell(1);
cell.setCellValue("이름");
cell = firstRow.createCell(2);
cell.setCellValue("아이디");
cell = firstRow.createCell(3);
cell.setCellValue("가입일");
}
use of org.apache.poi.hssf.usermodel.HSSFRow in project rxlib by RockyLOMO.
the class Helper method readExcel.
public static List<Object[]> readExcel(String filePath, boolean skipColumn) throws IOException {
List<Object[]> result = new ArrayList<>();
HSSFWorkbook workbook = new HSSFWorkbook(new FileInputStream(filePath));
for (int sheetIndex = 0; sheetIndex < workbook.getNumberOfSheets(); sheetIndex++) {
HSSFSheet sheet = workbook.getSheetAt(sheetIndex);
for (int rowIndex = skipColumn ? 1 : sheet.getFirstRowNum(); rowIndex < sheet.getLastRowNum(); rowIndex++) {
HSSFRow row = sheet.getRow(rowIndex);
List<Object> cellValues = new ArrayList<>();
for (int i = row.getFirstCellNum(); i < row.getLastCellNum(); i++) {
HSSFCell cell = row.getCell(i);
if (cell == null) {
cellValues.add(null);
continue;
}
Object value;
switch(cell.getCellTypeEnum()) {
case NUMERIC:
value = cell.getNumericCellValue();
break;
case BOOLEAN:
value = cell.getBooleanCellValue();
break;
default:
value = cell.getStringCellValue();
break;
}
cellValues.add(value);
}
if (cellValues.contains(null)) {
Logger.debug(String.format("current=%s offset=%s count=%s -> %s/%s", toJsonString(cellValues), row.getFirstCellNum(), row.getLastCellNum(), rowIndex, sheetIndex));
}
result.add(cellValues.toArray());
}
}
return result;
}
use of org.apache.poi.hssf.usermodel.HSSFRow in project selenium_java by sergueik.
the class ExcelUtils method createTitle.
/**
* 设置表头
*
* @param sheet
*/
private void createTitle(HSSFSheet sheet) {
if (currentRow > 0) {
return;
}
HSSFRow row = sheet.createRow(currentRow++);
int column = 0;
for (String key : headerMap.keySet()) {
HSSFCell cell = row.createCell(column++);
cell.setCellValue(key);
}
}
Aggregations