use of org.apache.poi.hssf.usermodel.HSSFRow in project adempiere by adempiere.
the class AbstractExcelExporter method createTableHeader.
private void createTableHeader(HSSFSheet sheet) {
short colnumMax = 0;
HSSFRow row = sheet.createRow(0);
// for all columns
short colnum = 0;
for (int col = 0; col < getColumnCount(); col++) {
if (colnum > colnumMax)
colnumMax = colnum;
//
if (isColumnPrinted(col)) {
HSSFCell cell = row.createCell(colnum);
// header row
HSSFCellStyle style = getHeaderStyle(col);
cell.setCellStyle(style);
String str = fixString(getHeaderName(col));
cell.setCellValue(new HSSFRichTextString(str));
colnum++;
}
// printed
}
// for all columns
// m_workbook.setRepeatingRowsAndColumns(m_sheetCount, 0, 0, 0, 0);
}
use of org.apache.poi.hssf.usermodel.HSSFRow in project poi by apache.
the class Outlines method test1.
public String test1() {
sheet1.groupColumn(4, 7);
for (int row = 0; row < 200; row++) {
HSSFRow r = sheet1.createRow(row);
for (int column = 0; column < 200; column++) {
HSSFCell c = r.createCell(column);
c.setCellValue(column);
}
}
return "Two expanded groups.";
}
use of org.apache.poi.hssf.usermodel.HSSFRow in project poi by apache.
the class ReadWriteWorkbook method main.
public static void main(String[] args) throws IOException {
FileInputStream fileIn = null;
FileOutputStream fileOut = null;
try {
fileIn = new FileInputStream("workbook.xls");
POIFSFileSystem fs = new POIFSFileSystem(fileIn);
HSSFWorkbook wb = new HSSFWorkbook(fs);
HSSFSheet sheet = wb.getSheetAt(0);
HSSFRow row = sheet.getRow(2);
if (row == null)
row = sheet.createRow(2);
HSSFCell cell = row.getCell(3);
if (cell == null)
cell = row.createCell(3);
cell.setCellType(CellType.STRING);
cell.setCellValue("a test");
// Write the output to a file
fileOut = new FileOutputStream("workbookout.xls");
wb.write(fileOut);
} finally {
if (fileOut != null)
fileOut.close();
if (fileIn != null)
fileIn.close();
}
}
use of org.apache.poi.hssf.usermodel.HSSFRow in project poi by apache.
the class CreateCells method main.
public static void main(String[] args) throws IOException {
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet("new sheet");
// Create a row and put some cells in it. Rows are 0 based.
HSSFRow row = sheet.createRow(0);
// Create a cell and put a value in it.
HSSFCell cell = row.createCell(0);
cell.setCellValue(1);
// Or do it on one line.
row.createCell(1).setCellValue(1.2);
row.createCell(2).setCellValue("This is a string");
row.createCell(3).setCellValue(true);
// Write the output to a file
FileOutputStream fileOut = new FileOutputStream("workbook.xls");
wb.write(fileOut);
fileOut.close();
wb.close();
}
use of org.apache.poi.hssf.usermodel.HSSFRow in project poi by apache.
the class CreateDateCells method main.
public static void main(String[] args) throws IOException {
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet("new sheet");
// Create a row and put some cells in it. Rows are 0 based.
HSSFRow row = sheet.createRow(0);
// Create a cell and put a date value in it. The first cell is not styled as a date.
HSSFCell cell = row.createCell(0);
cell.setCellValue(new Date());
// we style the second cell as a date (and time). It is important to create a new cell style from the workbook
// otherwise you can end up modifying the built in style and effecting not only this cell but other cells.
HSSFCellStyle cellStyle = wb.createCellStyle();
cellStyle.setDataFormat(HSSFDataFormat.getBuiltinFormat("m/d/yy h:mm"));
cell = row.createCell(1);
cell.setCellValue(new Date());
cell.setCellStyle(cellStyle);
// Write the output to a file
FileOutputStream fileOut = new FileOutputStream("workbook.xls");
wb.write(fileOut);
fileOut.close();
wb.close();
}
Aggregations