本文整理匯總了Java中org.apache.poi.xssf.usermodel.XSSFSheet.getSheetName方法的典型用法代碼示例。如果您正苦於以下問題:Java XSSFSheet.getSheetName方法的具體用法?Java XSSFSheet.getSheetName怎麽用?Java XSSFSheet.getSheetName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.poi.xssf.usermodel.XSSFSheet
的用法示例。
在下文中一共展示了XSSFSheet.getSheetName方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: parseExcel
import org.apache.poi.xssf.usermodel.XSSFSheet; //導入方法依賴的package包/類
@SuppressWarnings("resource")
private List<Map<String,Object>> parseExcel(InputStream stream) throws Exception {
List<Map<String,Object>> mapList=new ArrayList<Map<String,Object>>();
XSSFWorkbook wb = new XSSFWorkbook(stream);
for (int i = 0; i < wb.getNumberOfSheets(); i++) {
XSSFSheet sheet = wb.getSheetAt(i);
if (sheet == null) {
continue;
}
String name = sheet.getSheetName();
Map<String,Object> map=new HashMap<String,Object>();
map.put("name",name);
map.put("data", buildVariables(sheet));
mapList.add(map);
}
return mapList;
}
示例2: export
import org.apache.poi.xssf.usermodel.XSSFSheet; //導入方法依賴的package包/類
/**
* Exports a single sheet to a file
*
* @param sheet
* @throws FactoryConfigurationError
* @throws XMLStreamException
* @throws UnsupportedEncodingException
* @throws FileNotFoundException
*/
private void export(final XSSFSheet sheet, final XMLStreamWriter out)
throws UnsupportedEncodingException, XMLStreamException, FactoryConfigurationError, FileNotFoundException {
boolean isFirst = true;
final Map<String, String> columns = new HashMap<String, String>();
final String sheetName = sheet.getSheetName();
System.out.print(sheetName);
out.writeStartElement("sheet");
out.writeAttribute("name", sheetName);
Iterator<Row> rowIterator = sheet.rowIterator();
while (rowIterator.hasNext()) {
Row row = rowIterator.next();
if (isFirst) {
isFirst = false;
this.writeFirstRow(row, out, columns);
} else {
this.writeRow(row, out, columns);
}
}
out.writeEndElement();
System.out.println("..");
}
示例3: XSLXSource
import org.apache.poi.xssf.usermodel.XSSFSheet; //導入方法依賴的package包/類
public XSLXSource(Resource resource, XSSFWorkbook workbook) {
this.resource = resource;
this.workbook = workbook;
String fragment = resource.getFragment();
XSSFSheet sheet;
if (fragment == null) {
sheet = workbook.getSheetAt(0);
} else {
sheet = workbook.getSheet(fragment);
if (sheet == null) {
throw new IllegalArgumentException("Unable to find Sheet named '" + fragment + "'");
}
}
this.sheet = sheet;
this.rows = this.sheet.iterator();
if (!rows.hasNext()) {
throw new IllegalArgumentException(sheet.getSheetName() + " is empty");
}
XSSFRow row = nextRow();
this.firstColumn = row.getFirstCellNum();
this.headers = readHeaders(row, this.firstColumn);
}
示例4: readPatients
import org.apache.poi.xssf.usermodel.XSSFSheet; //導入方法依賴的package包/類
/**
* Parse the list of patients from the workbook.
*
* @return A list of {@link Patient} objects.
*/
private List<Patient> readPatients() throws DataProviderException {
XSSFSheet sheet = readRequiredSheet("patient");
String sheetName = sheet.getSheetName();
List<Patient> result = new ArrayList<>();
Iterator<Row> rows = sheet.rowIterator();
rows.next(); // skip header row
while (rows.hasNext()) {
Row row = rows.next();
Patient patient = new Patient();
patient.setId(readLongValue(sheetName, row.getCell(0)));
patient.setFirstName(readStringValue(sheetName, row.getCell(1)));
patient.setLastName(readStringValue(sheetName, row.getCell(2)));
patient.setDateOfBirth(readDateValue(sheetName, row.getCell(3)));
patient.setLanguage(readStringValue(sheetName, row.getCell(4)));
patient.setMaritalStatus(readStringValue(sheetName, row.getCell(5)));
patient.setRace(readStringValue(sheetName, row.getCell(6)));
patient.setGender(readStringValue(sheetName, row.getCell(7)));
result.add(patient);
}
return result;
}
示例5: readProviders
import org.apache.poi.xssf.usermodel.XSSFSheet; //導入方法依賴的package包/類
/**
* Parse the list of providers in the workbook.
*
* @return A list of {@link Provider} objects.
*/
private List<Provider> readProviders() throws DataProviderException {
XSSFSheet sheet = readRequiredSheet("provider");
String sheetName = sheet.getSheetName();
List<Provider> result = new ArrayList<>();
Iterator<Row> rows = sheet.rowIterator();
rows.next(); // skip header row
while (rows.hasNext()) {
Row row = rows.next();
Provider provider = new Provider();
provider.setId(readLongValue(sheetName, row.getCell(0)));
provider.setFirstName(readStringValue(sheetName, row.getCell(1)));
provider.setLastName(readStringValue(sheetName, row.getCell(2)));
result.add(provider);
}
return result;
}
示例6: readEncounters
import org.apache.poi.xssf.usermodel.XSSFSheet; //導入方法依賴的package包/類
/**
* Parse the list of encounters in the workbook.
*
* @return A list of {@link Encounter} objects.
*/
private List<Encounter> readEncounters() throws DataProviderException {
XSSFSheet sheet = readRequiredSheet("encounter");
String sheetName = sheet.getSheetName();
List<Encounter> result = new ArrayList<>();
Iterator<Row> rows = sheet.rowIterator();
LOGGER.debug("Encounter iterator: {}", Integer.valueOf(rows.hashCode()));
rows.next(); // skip header row
while (rows.hasNext()) {
Row row = rows.next();
Encounter encounter = new Encounter();
encounter.setId(readLongValue(sheetName, row.getCell(0)));
encounter.setPatientId(readLongValue(sheetName, row.getCell(1)));
encounter.setProviderId(readLongValue(sheetName, row.getCell(2)));
encounter.setStart(readDateValue(sheetName, row.getCell(3)));
encounter.setEnd(readDateValue(sheetName, row.getCell(4)));
encounter.setType(readStringValue(sheetName, row.getCell(5)));
encounter.setDischargeDisposition(readStringValue(sheetName, row.getCell(6)));
result.add(encounter);
}
return result;
}
示例7: readCpts
import org.apache.poi.xssf.usermodel.XSSFSheet; //導入方法依賴的package包/類
/**
* Parse the list of CPT codes in the workbook.
*
* @return A list of {@link CPT} objects.
*/
private List<CPT> readCpts() throws DataProviderException {
XSSFSheet sheet = this.workbook.getSheet("eCPT");
List<CPT> result = new ArrayList<>();
if (sheet != null) {
String sheetName = sheet.getSheetName();
Iterator<Row> rows = sheet.rowIterator();
rows.next(); // skip header row
while (rows.hasNext()) {
Row row = rows.next();
CPT cpt = new CPT();
cpt.setId(readStringValue(sheetName, row.getCell(0)));
cpt.setEncounterId(readLongValue(sheetName, row.getCell(1)));
cpt.setTimestamp(readDateValue(sheetName, row.getCell(2)));
cpt.setEntityId(readStringValue(sheetName, row.getCell(3)));
result.add(cpt);
}
}
return result;
}
示例8: readIcd9Procedures
import org.apache.poi.xssf.usermodel.XSSFSheet; //導入方法依賴的package包/類
/**
* Parse the list of ICD9 Procedure codes present in the workbook.
*
* @return A list of {@link Icd9Procedure} objects.
*/
private List<Icd9Procedure> readIcd9Procedures() throws DataProviderException {
XSSFSheet sheet = this.workbook.getSheet("eICD9P");
List<Icd9Procedure> result = new ArrayList<>();
if (sheet != null) {
String sheetName = sheet.getSheetName();
Iterator<Row> rows = sheet.rowIterator();
rows.next(); // skip header row
while (rows.hasNext()) {
Row row = rows.next();
Icd9Procedure procedure = new Icd9Procedure();
procedure.setId(readStringValue(sheetName, row.getCell(0)));
procedure.setEncounterId(readLongValue(sheetName, row.getCell(1)));
procedure.setTimestamp(readDateValue(sheetName, row
.getCell(2)));
procedure.setEntityId(readStringValue(sheetName, row
.getCell(3)));
result.add(procedure);
}
}
return result;
}
示例9: readMedications
import org.apache.poi.xssf.usermodel.XSSFSheet; //導入方法依賴的package包/類
/**
* Parse the list of medications present in the workbook.
*
* @return A list of {@link Medication} objects.
*/
private List<Medication> readMedications() throws DataProviderException {
XSSFSheet sheet = this.workbook.getSheet("eMEDS");
List<Medication> result = new ArrayList<>();
if (sheet != null) {
String sheetName = sheet.getSheetName();
Iterator<Row> rows = sheet.rowIterator();
rows.next(); // skip header row
while (rows.hasNext()) {
Row row = rows.next();
Medication medication = new Medication();
medication.setId(readStringValue(sheetName, row.getCell(0)));
medication.setEncounterId(readLongValue(sheetName, row
.getCell(1)));
medication.setTimestamp(readDateValue(sheetName, row
.getCell(2)));
medication.setEntityId(readStringValue(sheetName, row
.getCell(3)));
result.add(medication);
}
}
return result;
}
示例10: readLabs
import org.apache.poi.xssf.usermodel.XSSFSheet; //導入方法依賴的package包/類
/**
* Parse the list of labs present in the workbook's "eLABS" worksheet.
*
* @return A list of {@link Lab} objects.
*/
private List<Lab> readLabs() throws DataProviderException {
XSSFSheet sheet = this.workbook.getSheet("eLABS");
List<Lab> result = new ArrayList<>();
if (sheet != null) {
String sheetName = sheet.getSheetName();
Iterator<Row> rows = sheet.rowIterator();
rows.next(); // skip header row
while (rows.hasNext()) {
Row row = rows.next();
Lab lab = new Lab();
lab.setId(readStringValue(sheetName, row.getCell(0)));
lab.setEncounterId(readLongValue(sheetName, row.getCell(1)));
lab.setTimestamp(readDateValue(sheetName, row.getCell(2)));
lab.setEntityId(readStringValue(sheetName, row.getCell(3)));
lab.setResultAsStr(readStringValue(sheetName, row.getCell(4)));
lab.setResultAsNum(readDoubleValue(sheetName, row.getCell(5)));
lab.setUnits(readStringValue(sheetName, row.getCell(6)));
lab.setFlag(readStringValue(sheetName, row.getCell(7)));
result.add(lab);
}
}
return result;
}
示例11: readVitals
import org.apache.poi.xssf.usermodel.XSSFSheet; //導入方法依賴的package包/類
/**
* Parse the list of vitals present in the workbook's "eVITALS" worksheet.
*
* @return A list of {@link Vital} objects.
*/
private List<Vital> readVitals() throws DataProviderException {
XSSFSheet sheet = this.workbook.getSheet("eVITALS");
List<Vital> result = new ArrayList<>();
if (sheet != null) {
String sheetName = sheet.getSheetName();
Iterator<Row> rows = sheet.rowIterator();
rows.next(); // skip header row
while (rows.hasNext()) {
Row row = rows.next();
Vital vital = new Vital();
vital.setId(readStringValue(sheetName, row.getCell(0)));
vital.setEncounterId(readLongValue(sheetName, row.getCell(1)));
vital.setTimestamp(readDateValue(sheetName, row.getCell(2)));
vital.setEntityId(readStringValue(sheetName, row.getCell(3)));
vital.setResultAsStr(readStringValue(sheetName, row.getCell(4)));
vital.setResultAsNum(readDoubleValue(sheetName, row.getCell(5)));
vital.setUnits(readStringValue(sheetName, row.getCell(6)));
vital.setFlag(readStringValue(sheetName, row.getCell(7)));
result.add(vital);
}
}
return result;
}
示例12: getXMLWriter
import org.apache.poi.xssf.usermodel.XSSFSheet; //導入方法依賴的package包/類
private XMLStreamWriter getXMLWriter(XSSFSheet sheet)
throws FileNotFoundException, UnsupportedEncodingException, XMLStreamException {
final String outputSheetName = this.outputFileName + "." + sheet.getSheetName() + OUTPUT_EXTENSION;
final File outFile = new File(outputSheetName);
if (outFile.exists()) {
outFile.delete();
}
OutputStream outputStream = new FileOutputStream(outFile);
return this.getXMLWriter(outputStream);
}
示例13: readSheet
import org.apache.poi.xssf.usermodel.XSSFSheet; //導入方法依賴的package包/類
protected XSSFSheet readSheet(int index, String name) {
XSSFSheet sheet = workbook.getSheetAt(index);
if (!sheet.getSheetName().equals(name)) {
throw new IllegalArgumentException("The sheet (" + sheet.getSheetName() + ") at index (" + index
+ ") is expected to have another name (" + name + ")");
}
return sheet;
}
示例14: readAllSheets
import org.apache.poi.xssf.usermodel.XSSFSheet; //導入方法依賴的package包/類
private void readAllSheets(XSSFWorkbook workbook, ExpowFileLib expowFile) {
//
int sheetCount = workbook.getNumberOfSheets();
for (int index = 0; index < sheetCount; index++) {
XSSFSheet sheet = workbook.getSheetAt(index);
ExpowSheet expowSheet = new ExpowSheetLib(index, sheet.getSheetName());
fillSheet(sheet, expowSheet);
expowFile.addSheet(expowSheet);
}
}
示例15: readSheet
import org.apache.poi.xssf.usermodel.XSSFSheet; //導入方法依賴的package包/類
private void readSheet(XSSFWorkbook workbook, ExpowFileLib expowFile, int sheetIndex) {
//
int sheetCount = workbook.getNumberOfSheets();
for (int index = 0; index < sheetCount; index++) {
if (index != sheetIndex) {
continue;
}
XSSFSheet sheet = workbook.getSheetAt(index);
ExpowSheet expowSheet = new ExpowSheetLib(index, sheet.getSheetName());
fillSheet(sheet, expowSheet);
expowFile.addSheet(expowSheet);
break;
}
}