本文整理汇总了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;
}
示例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;
}