Search in sources :

Example 26 with XSSFSheet

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;
}
Also used : XSSFSheet(org.apache.poi.xssf.usermodel.XSSFSheet) HashMap(java.util.HashMap) Row(org.apache.poi.ss.usermodel.Row) Sheet(org.apache.poi.ss.usermodel.Sheet) XSSFSheet(org.apache.poi.xssf.usermodel.XSSFSheet)

Example 27 with XSSFSheet

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();
        }
    }
}
Also used : XSSFSheet(org.apache.poi.xssf.usermodel.XSSFSheet) XSSFRow(org.apache.poi.xssf.usermodel.XSSFRow) XSSFWorkbook(org.apache.poi.xssf.usermodel.XSSFWorkbook) File(java.io.File)

Example 28 with XSSFSheet

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);
    }
}
Also used : XSSFSheet(org.apache.poi.xssf.usermodel.XSSFSheet) AndroidTestInfo(entity.AndroidTestInfo) XSSFWorkbook(org.apache.poi.xssf.usermodel.XSSFWorkbook) File(java.io.File)

Example 29 with XSSFSheet

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;
}
Also used : XSSFSheet(org.apache.poi.xssf.usermodel.XSSFSheet) BscStructTreeObj(com.netsteadfast.greenstep.bsc.model.BscStructTreeObj) FileOutputStream(java.io.FileOutputStream) XSSFWorkbook(org.apache.poi.xssf.usermodel.XSSFWorkbook) VisionVO(com.netsteadfast.greenstep.vo.VisionVO) File(java.io.File)

Example 30 with XSSFSheet

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;
}
Also used : XSSFSheet(org.apache.poi.xssf.usermodel.XSSFSheet) BscStructTreeObj(com.netsteadfast.greenstep.bsc.model.BscStructTreeObj) FileOutputStream(java.io.FileOutputStream) XSSFWorkbook(org.apache.poi.xssf.usermodel.XSSFWorkbook) VisionVO(com.netsteadfast.greenstep.vo.VisionVO) File(java.io.File)

Aggregations

XSSFSheet (org.apache.poi.xssf.usermodel.XSSFSheet)64 XSSFWorkbook (org.apache.poi.xssf.usermodel.XSSFWorkbook)46 FileOutputStream (java.io.FileOutputStream)22 Test (org.junit.Test)22 File (java.io.File)19 XSSFRow (org.apache.poi.xssf.usermodel.XSSFRow)16 XSSFCell (org.apache.poi.xssf.usermodel.XSSFCell)11 Row (org.apache.poi.ss.usermodel.Row)8 XSSFCellStyle (org.apache.poi.xssf.usermodel.XSSFCellStyle)8 IOException (java.io.IOException)6 Sheet (org.apache.poi.ss.usermodel.Sheet)6 CellReference (org.apache.poi.ss.util.CellReference)6 XSSFMap (org.apache.poi.xssf.usermodel.XSSFMap)6 OutputStreamWriter (java.io.OutputStreamWriter)5 Cell (org.apache.poi.ss.usermodel.Cell)5 XlsxWriterHelper (com.cubrid.common.ui.cubrid.table.control.XlsxWriterHelper)4 OutputStream (java.io.OutputStream)4 ArrayList (java.util.ArrayList)4 BscStructTreeObj (com.netsteadfast.greenstep.bsc.model.BscStructTreeObj)3 VisionVO (com.netsteadfast.greenstep.vo.VisionVO)3