this.name = sheetName;
this.sheet = sh;
sheet.setDisplayGridlines(true);
}
public ExcelSheet(String sheetName, HSSFSheet sh,HSSFCellStyle titleStyle) {
this.name = sheetName;
this.sheet = sh;
this.titleStyle=titleStyle;
}
// public ExcelSheet(){
// this(name);
// }
public void addRecord(String[] record) {
if(header!=null){
if(header.length!=record.length){
return;
}
}
fillContent(record,sheet.getLastRowNum()+1,null);
}
public String[] getHeader() {
return this.header;
}
public void setHeader(String[] header) {
this.header=header;
fillContent(header,0,this.titleStyle);
}
private void fillContent(String[] crow, int rowNum, HSSFCellStyle style) {
HSSFRow row = sheet.createRow((short) rowNum);
for (int i = 0; i < crow.length; i++) {
String s = crow[i];
HSSFCell cell = row.createCell((short) i);
if(style!=null){
cell.setCellStyle(style);
}
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue(s);
}
}
public void setValue(int rowNum,int colNum,String value){
HSSFRow row=this.sheet.getRow(rowNum);
HSSFCell cell=row.getCell((short)colNum);
if (cell==null){
cell = row.createCell((short) colNum);
}
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue(value);
}
public String getName() {
// TODO Auto-generated method stub
return this.name;
}
public void addRecord(ArrayList
for (String[] row : arr) {
this.addRecord(row);
}
}
public List
ArrayList
for (int j = 0; j < this.sheet.getLastRowNum(); j++) {
HSSFRow row=this.sheet.getRow(j);
ArrayList
for (short k = 0; k < row.getLastCellNum(); k++) {
HSSFCell cell=row.getCell(k);
if(cell!=null){
cellsStr.add(cell.getStringCellValue());
}
}
System.out.println("row=