use of org.apache.poi.xssf.usermodel.XSSFSheet in project chilo-producer by cccties.
the class SettingReader method readVolSheets.
protected Map<Integer, Book> readVolSheets() throws FileNotFoundException, IOException, Epub3MakerException {
Map<Integer, Book> books = new HashMap<>();
Iterator<XSSFSheet> sheetsIte = workBook.iterator();
while (sheetsIte.hasNext()) {
Sheet sheet = sheetsIte.next();
String sheetName = sheet.getSheetName();
if (!sheetName.startsWith(BOOK_SHEETS_PREFIX)) {
continue;
}
//
// search bookInfo
//
Map<String, String> bookInfo = null;
for (Map<String, String> b : bookList) {
String volStr = b.get(Series.KEY_BOOKLIST_VOL);
if (volStr != null && volStr.equals(sheetName)) {
bookInfo = b;
break;
}
}
if (bookInfo == null) {
continue;
}
//
// create cover page
//
int vol = Integer.parseInt(sheetName.substring(BOOK_SHEETS_PREFIX.length()));
int page = Process.VOLUME_COVER_PAGE;
String bookCover = bookInfo.get(Series.KEY_BOOKLIST_BOOK_COVER);
String bookId = bookInfo.get(Series.KEY_BOOKLIST_ID);
PageSetting coverSetting = null;
if (bookCover != null && bookCover.length() != 0) {
log.debug("Found cover in BookList: " + bookCover + " for " + sheetName);
coverSetting = createBookCoverPage(vol, page, bookCover, bookId);
}
Book book = new Book(vol, bookInfo);
books.put(vol, book);
if (coverSetting != null) {
book.addPageSetting(coverSetting);
}
page = Process.DOCUMENT_START_PAGE;
String curSection = null;
int lastrow = sheet.getLastRowNum();
for (int rownum = 1; rownum <= lastrow; rownum++) {
//
// skip first row
//
PageSetting insideCover = null;
Row row = sheet.getRow(rownum);
if (row == null) {
log.debug("readVolSheets done, because empty Row found !!!");
break;
}
PageSetting setting = readPageSetting(row, vol, page);
if (setting == null) {
break;
}
if (!Util.isValueValid(setting.getPageType())) {
log.debug("readVolSheets done, because empty page-type found.");
break;
}
String section = setting.getSection();
if (section == null) {
log.info("readVolSheets done, section-title is required.");
break;
}
//
if ((curSection == null || !section.equals(curSection)) && !setting.getPageType().equals(PageSetting.VALUE_KEY_PAGE_TYPE_TEST)) {
insideCover = createInsideCover(vol, page, section);
}
curSection = section;
//
if (insideCover != null) {
book.addPageSetting(insideCover);
setting.setPage(++page);
}
book.addPageSetting(setting);
page++;
}
}
return books;
}
use of org.apache.poi.xssf.usermodel.XSSFSheet in project CodeUtils by boredream.
the class OfficeUtils method main.
public static void main(String[] args) {
File file = new File("temp" + File.separator + "office" + File.separator + "maidian.xlsx");
XSSFWorkbook xssfWorkbook = openXlsx(file);
XSSFSheet xssfSheet = xssfWorkbook.getSheetAt(0);
int totalRows = xssfSheet.getPhysicalNumberOfRows();
for (int rowNum = 2; rowNum < totalRows; rowNum++) {
XSSFRow row = xssfSheet.getRow(rowNum);
int cellNum = row.getLastCellNum();
if (cellNum == 6) {
String name = getCellString(row.getCell(4));
String eventid = getCellString(row.getCell(5));
// /**
// * aa
// */
// public static final String a = "a";
System.out.println("/**");
System.out.println(" * " + name);
System.out.println(" */");
System.out.println("public static final String " + eventid.toUpperCase() + " = \"" + eventid + "\"");
System.out.println();
}
}
}
use of org.apache.poi.xssf.usermodel.XSSFSheet in project CodeUtils by boredream.
the class Main method main.
public static void main(String[] args) throws Exception {
File file = new File("temp" + File.separator + "androidtest" + File.separator + "test.xlsx");
XSSFWorkbook xssfSheets = OfficeUtils.openXlsx(file);
if (xssfSheets != null) {
XSSFSheet sheet1 = xssfSheets.getSheetAt(0);
List<AndroidTestInfo> testInfos = parseAllTestInfo(sheet1);
String s = generateTestCode(testInfos);
System.out.println(s);
}
}
use of org.apache.poi.xssf.usermodel.XSSFSheet in project bamboobsc by billchen198318.
the class OrganizationReportExcelCommand method createExcel.
private String createExcel(Context context) throws Exception {
String visionOid = (String) context.get("visionOid");
VisionVO vision = null;
BscStructTreeObj treeObj = (BscStructTreeObj) this.getResult(context);
for (VisionVO visionObj : treeObj.getVisions()) {
if (visionObj.getOid().equals(visionOid)) {
vision = visionObj;
}
}
BscReportPropertyUtils.loadData();
String fileName = SimpleUtils.getUUIDStr() + ".xlsx";
String fileFullPath = Constants.getWorkTmpDir() + "/" + fileName;
int row = 0;
XSSFWorkbook wb = new XSSFWorkbook();
XSSFSheet sh = wb.createSheet();
row += this.createHead(wb, sh, row, vision, context);
row = this.createMainBody(wb, sh, row, vision);
this.putSignature(wb, sh, row + 1, context);
FileOutputStream out = new FileOutputStream(fileFullPath);
wb.write(out);
out.close();
wb = null;
File file = new File(fileFullPath);
String oid = UploadSupportUtils.create(Constants.getSystem(), UploadTypes.IS_TEMP, false, file, "department-report.xlsx");
file = null;
return oid;
}
use of org.apache.poi.xssf.usermodel.XSSFSheet in project bamboobsc by billchen198318.
the class PersonalReportExcelCommand method createExcel.
private String createExcel(Context context) throws Exception {
String visionOid = (String) context.get("visionOid");
VisionVO vision = null;
BscStructTreeObj treeObj = (BscStructTreeObj) this.getResult(context);
for (VisionVO visionObj : treeObj.getVisions()) {
if (visionObj.getOid().equals(visionOid)) {
vision = visionObj;
}
}
BscReportPropertyUtils.loadData();
String fileName = SimpleUtils.getUUIDStr() + ".xlsx";
String fileFullPath = Constants.getWorkTmpDir() + "/" + fileName;
int row = 0;
XSSFWorkbook wb = new XSSFWorkbook();
XSSFSheet sh = wb.createSheet();
row += this.createHead(wb, sh, row, vision, context);
row = this.createMainBody(wb, sh, row, vision, context);
this.createFoot(wb, sh, row, vision, context);
this.putSignature(wb, sh, row + 2, context);
FileOutputStream out = new FileOutputStream(fileFullPath);
wb.write(out);
out.close();
wb = null;
File file = new File(fileFullPath);
String oid = UploadSupportUtils.create(Constants.getSystem(), UploadTypes.IS_TEMP, false, file, "personal-report.xlsx");
file = null;
return oid;
}
Aggregations