WritableWorkbook workbook
=
Workbook.createWorkbook(
new
File(
"
d:/test.xls
"
));
WritableSheet sheet = workbook.createSheet( " test " , 0 );
int col = 0 ;
int line = 0 ;
WritableCellFormat style = new WritableCellFormat( new WritableFont(
WritableFont.ARIAL, 10 , WritableFont.BOLD, false ,
UnderlineStyle.NO_UNDERLINE, Colour.BLACK));
sheet.addCell( new Label(col ++ , line, " usernate " , style));
sheet.addCell( new Label(col ++ , line, " date " , style));
sheet.addCell( new Label(col ++ , line, " Pic Qty " , style));
sheet.addCell( new Label(col ++ , line, " Price (HKD) per picture " , style));
sheet.addCell( new Label(col ++ , line, " Total " , style));
String[] data = ... { "beauty", "2007-10-15", "20", "15.70", "20.50" } ;
for ( int i = 0 ; i < 20 ; i ++ ) ... {
col = 0;
line++;
sheet.addCell(new Label(col++, line, data[0], style));
sheet.addCell(new Label(col++, line, data[1], style));
sheet.addCell(new Label(col++, line, data[2], style));
sheet.addCell(new Label(col++, line, data[3], style));
sheet.addCell(new Label(col++, line, data[4], style));
}
line += 3 ;
sheet.addCell( new Label( 4 , line, " total " , style));
line ++ ;
sheet.addCell( new Label( 4 , line, " 159 " , style));
workbook.write();
workbook.close();
WritableSheet sheet = workbook.createSheet( " test " , 0 );
int col = 0 ;
int line = 0 ;
WritableCellFormat style = new WritableCellFormat( new WritableFont(
WritableFont.ARIAL, 10 , WritableFont.BOLD, false ,
UnderlineStyle.NO_UNDERLINE, Colour.BLACK));
sheet.addCell( new Label(col ++ , line, " usernate " , style));
sheet.addCell( new Label(col ++ , line, " date " , style));
sheet.addCell( new Label(col ++ , line, " Pic Qty " , style));
sheet.addCell( new Label(col ++ , line, " Price (HKD) per picture " , style));
sheet.addCell( new Label(col ++ , line, " Total " , style));
String[] data = ... { "beauty", "2007-10-15", "20", "15.70", "20.50" } ;
for ( int i = 0 ; i < 20 ; i ++ ) ... {
col = 0;
line++;
sheet.addCell(new Label(col++, line, data[0], style));
sheet.addCell(new Label(col++, line, data[1], style));
sheet.addCell(new Label(col++, line, data[2], style));
sheet.addCell(new Label(col++, line, data[3], style));
sheet.addCell(new Label(col++, line, data[4], style));
}
line += 3 ;
sheet.addCell( new Label( 4 , line, " total " , style));
line ++ ;
sheet.addCell( new Label( 4 , line, " 159 " , style));
workbook.write();
workbook.close();