本文整理匯總了Java中org.apache.poi.hssf.usermodel.HSSFCell.getColumnIndex方法的典型用法代碼示例。如果您正苦於以下問題:Java HSSFCell.getColumnIndex方法的具體用法?Java HSSFCell.getColumnIndex怎麽用?Java HSSFCell.getColumnIndex使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.poi.hssf.usermodel.HSSFCell
的用法示例。
在下文中一共展示了HSSFCell.getColumnIndex方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createColumnTitles
import org.apache.poi.hssf.usermodel.HSSFCell; //導入方法依賴的package包/類
private String[] createColumnTitles(int numberOfColumns, Iterator<Row> rows)
{
String[] columnTitleSet = new String[numberOfColumns];
int i = 0;
HSSFRow row = (HSSFRow) rows.next();
Iterator<Cell> cells = row.cellIterator();
addTitleRow = false;
if (checkCellEntries(row.cellIterator()))
{
while (cells.hasNext())
{
HSSFCell currentCell = (HSSFCell) cells.next();
if (currentCell.getColumnIndex() < numberOfColumns)
{
columnTitleSet[currentCell.getColumnIndex()] = currentCell
.getStringCellValue();
i++;
addTitleRow = false;
}
}
}
else
{
while (cells.hasNext() && i < numberOfColumns)
{
cells.next();
columnTitleSet[i] = "Column" + (i + 1);
i++;
}
addTitleRow = true;
}
return columnTitleSet;
}
示例2: apply
import org.apache.poi.hssf.usermodel.HSSFCell; //導入方法依賴的package包/類
/**
* {@inheritDoc}
*/
public void apply(HSSFCell cell, HSSFCellStyle cellStyle, Map<String, String> style) {
int width = Math.round(CssUtils.getInt(style.get(WIDTH)) * 2048 / 8.43F);
HSSFSheet sheet = cell.getSheet();
int colIndex = cell.getColumnIndex();
if (width > sheet.getColumnWidth(colIndex)) {
if (width > 255 * 256) {
width = 255 * 256;
}
sheet.setColumnWidth(colIndex, width);
}
}
示例3: carregarPlanilha
import org.apache.poi.hssf.usermodel.HSSFCell; //導入方法依賴的package包/類
@SuppressWarnings("resource")
@Transactional
public String carregarPlanilha(final File arquivo) throws Exception {
if (arquivo == null) {
throw new IllegalArgumentException("Planilha n�o foi informada");
}
final List<Ocs> lista = new ArrayList<>();
int x = 0; //this.dao.execute("Ocs.excluir");
Iterator<Row> rows;
rows = new HSSFWorkbook(new POIFSFileSystem(new FileInputStream(arquivo))).getSheetAt(0).rowIterator();
int cont = 0;
inicio:
while(rows.hasNext()) {
cont += 1;
final HSSFRow row = (HSSFRow) rows.next();
if (cont == 1) {
continue inicio;
}
final Ocs ocs = new Ocs();
final Iterator<Cell> cells = row.cellIterator();
while(cells.hasNext()) {
final HSSFCell cell = (HSSFCell) cells.next();
switch (cell.getColumnIndex()) {
case 0:
ocs.setDescricao(cell.getStringCellValue());
break;
case 4:
String cnpj = cell.getStringCellValue();
if (cnpj.isEmpty()){
continue inicio;
}
ocs.setCnpj(cnpj.replace(".", "").replace("/", "").replace("-", ""));
break;
default:
break;
}
}
ocs.setMunicipio("S�o Paulo");
ocs.setUf("SP");
if (this.listarCnpj(ocs.getCnpjf()).size() == 0){
lista.add(this.dao.save(ocs));
}
}
return "Registros: exclu�dos = " + x + ", inclu�dos = " + lista.size();
}
示例4: carregarPlanilhaDth
import org.apache.poi.hssf.usermodel.HSSFCell; //導入方法依賴的package包/類
@SuppressWarnings("resource")
@Transactional
public String carregarPlanilhaDth(final Ocs ocs, final File arquivo) throws Exception {
if (arquivo == null) {
throw new IllegalArgumentException("Planilha n�o foi informada");
}
int cont = 0;
int y = this.dao.execute("Dth.excluirPorOcs", ocs.getId());
Ocs o = this.dao.findById(ocs.getId());
final StringBuilder msg = new StringBuilder("Exclu�dos = ").append(y).append(" - Inclu�dos = ");
try (InputStream file = new FileInputStream(arquivo)) {
final Iterator<Row> rows = new HSSFWorkbook(new POIFSFileSystem(file)).getSheetAt(0).rowIterator();
inicio:
while(rows.hasNext()) {
cont += 1;
final HSSFRow row = (HSSFRow) rows.next();
if (cont == 1) {
continue inicio;
}
final Dth dth = new Dth();
final Iterator<Cell> cells = row.cellIterator();
while(cells.hasNext()) {
final HSSFCell cell = (HSSFCell) cells.next();
switch (cell.getColumnIndex()) {
case 0:
cell.setCellType(1);
final String codigo = cell.getStringCellValue();
if (codigo != null) {
dth.setCodigo(codigo);
} else {
continue inicio;
}
break;
case 1:
cell.setCellType(1);
final String descricao = cell.getStringCellValue();
if (descricao != null) {
dth.setDescricao(descricao.substring(0, descricao.length() > 255 ? 255 : descricao.length()));
} else {
continue inicio;
}
break;
case 2:
cell.setCellType(1);
final String unidade = cell.getStringCellValue();
if (unidade != null) {
dth.setUnidade(unidade);
} else {
continue inicio;
}
break;
case 3:
if (cell.getCellType() != Cell.CELL_TYPE_NUMERIC) {
throw new Exception("Coluna 4 (Valor) deve ser do tipo num�rica");
}
final BigDecimal v = BigDecimal.valueOf(cell.getNumericCellValue());
if (v != null) {
dth.setValor(v);
} else {
continue inicio;
}
break;
default:
break;
}
}
o.addDth(dth);
}
this.dao.save(o);
}
return msg.append(cont).toString();
}
示例5: carregarPlanilha
import org.apache.poi.hssf.usermodel.HSSFCell; //導入方法依賴的package包/類
@SuppressWarnings("resource")
@Transactional
public String carregarPlanilha(final File arquivo) throws Exception {
if (arquivo == null) {
throw new IllegalArgumentException("Planilha n�o foi informada");
}
final List<Profissional> lista = new ArrayList<>();
int x = this.dao.execute("Profissional.excluir");
final Iterator<Row> rows = new HSSFWorkbook(new POIFSFileSystem(new FileInputStream(arquivo))).getSheetAt(0).rowIterator();
int cont = 0;
inicio:
while(rows.hasNext()) {
cont += 1;
final HSSFRow row = (HSSFRow) rows.next();
if (cont == 1) {
continue inicio;
}
final Profissional p = new Profissional();
final Iterator<Cell> cells = row.cellIterator();
while(cells.hasNext()) {
final HSSFCell cell = (HSSFCell) cells.next();
switch (cell.getColumnIndex()) {
case 0:
final String nome = cell.getStringCellValue();
if (nome != null) {
p.setNome(nome);;
} else {
continue inicio;
}
break;
case 1:
final String crm = cell.getStringCellValue();
if (crm != null) {
p.setCrm(crm);
} else {
continue inicio;
}
break;
case 2:
final String uf = cell.getStringCellValue();
if (uf != null) {
p.setCrmUf(uf);
} else {
continue inicio;
}
break;
case 3:
final String espec = cell.getStringCellValue();
if (espec != null) {
final List<Especialidade> e = especDao.findByNamedQuery("Especialidade.findByDesc", espec);
if (e != null && !e.isEmpty()) {
p.setEspecialidade(e.get(0));
}
} else {
continue inicio;
}
break;
case 4:
final String idt = cell.getStringCellValue();
if (idt != null) {
p.setIdt(idt);
} else {
continue inicio;
}
break;
default:
break;
}
}
lista.add(this.dao.save(p));
}
return "Exclu�dos = " + x + " - Inclu�dos = " + lista.size();
}