當前位置: 首頁>>代碼示例>>Java>>正文


Java HSSFSheet.iterator方法代碼示例

本文整理匯總了Java中org.apache.poi.hssf.usermodel.HSSFSheet.iterator方法的典型用法代碼示例。如果您正苦於以下問題:Java HSSFSheet.iterator方法的具體用法?Java HSSFSheet.iterator怎麽用?Java HSSFSheet.iterator使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.poi.hssf.usermodel.HSSFSheet的用法示例。


在下文中一共展示了HSSFSheet.iterator方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: parse

import org.apache.poi.hssf.usermodel.HSSFSheet; //導入方法依賴的package包/類
public Map<String, BoundaryPoint> parse(InputStream is) throws IOException {
    Map<String, BoundaryPoint> boundaryPoints = new HashMap<>();
    HSSFWorkbook workbook = new HSSFWorkbook(is);
    HSSFSheet sheet = workbook.getSheetAt(0);
    Iterator<Row> rowIterator = sheet.iterator();
    rowIterator.next();
    rowIterator.next();
    while (rowIterator.hasNext()) {
        Row row = rowIterator.next();
        Cell boundaryPointNameCell = row.getCell(13);
        Cell borderFromCell = row.getCell(14);
        Cell borderToCell = row.getCell(15);
        String boundaryPointName = boundaryPointNameCell.getStringCellValue();
        if (boundaryPointName.equals("-")) {
            continue;
        }
        Country borderFrom = toCountry(borderFromCell.getStringCellValue());
        Country borderTo = toCountry(borderToCell.getStringCellValue());
        boundaryPoints.put(boundaryPointName, new BoundaryPoint(boundaryPointName, borderFrom, borderTo));
    }
    return boundaryPoints;
}
 
開發者ID:powsybl,項目名稱:powsybl-core,代碼行數:23,代碼來源:BoundaryPointXlsParser.java

示例2: convert

import org.apache.poi.hssf.usermodel.HSSFSheet; //導入方法依賴的package包/類
@Override
public ByteArrayOutputStream convert(InputStream stream) {
    ByteArrayOutputStream outStream;
    try {
        outStream = new ByteArrayOutputStream();
        // Read workbook into HSSFWorkbook
        HSSFWorkbook my_xls_workbook = new HSSFWorkbook(stream);
        // Read worksheet into HSSFSheet
        HSSFSheet my_worksheet = my_xls_workbook.getSheetAt(0);
        // To iterate over the rows
        Iterator<Row> rowIterator = my_worksheet.iterator();
        // We will create output PDF document objects at this point
        Document pdf = new Document();
        PdfWriter.getInstance(pdf, outStream);
        pdf.open();
        // we have two columns in the Excel sheet, so we create a PDF table
        // with two columns
        // Note: There are ways to make this dynamic in nature, if you want
        // to.
        PdfPTable my_table = new PdfPTable(2);
        // We will use the object below to dynamically add new data to the
        // table
        PdfPCell table_cell;
        // Loop through rows.
        printPdf(rowIterator, my_table);
        // Finally add the table to PDF document
        pdf.add(my_table);
        pdf.close();
        // we created our pdf file..
        stream.close(); // close xls
        return outStream;
    } catch (Exception ex) {
        ex.printStackTrace();
    }
    return null;
}
 
開發者ID:geetools,項目名稱:geeCommerce-Java-Shop-Software-and-PIM,代碼行數:37,代碼來源:XslToPdfConverter.java


注:本文中的org.apache.poi.hssf.usermodel.HSSFSheet.iterator方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。