on 09-08-2008 2:39 PM
Hi,
I have implemented the export to excel functionality in web dynpro java.It is working fine when the output in the table is more than one.
But if there only one output in the table then in the export to excel function,there is no header in the excel sheet for the single row of data.
Could anyone please suggest how to get the header in the downloaded excel sheet even if there is single row data in the table.
Thanks,
Rajani
Hi Rajini,
It would be nice if you could share the procedure to export data to excel sheet step by step.
Regards
Raghu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
May i know whats the code you used to generate excel sheet.
See this sample code to generate a form, like this you can generate headers and all
import java.io.File;
import java.io.IOException;
import jxl.Workbook;
import jxl.format.Alignment;
import jxl.format.Border;
import jxl.format.BorderLineStyle;
import jxl.format.Colour;
import jxl.format.VerticalAlignment;
import jxl.write.Label;
import jxl.write.Number;
import jxl.write.WritableCellFormat;
import jxl.write.WritableFont;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
import jxl.write.WriteException;
import jxl.write.biff.RowsExceededException;
public class WriteExcel {
public static void main(String[] args) {
try {
WritableWorkbook workbook = Workbook.createWorkbook(new File("Vacc.xls"));
WritableSheet sheet = workbook.createSheet("AccSheet", 0);
//Title
WritableFont titlefont = new WritableFont(WritableFont.TIMES, 20,WritableFont.BOLD);
WritableCellFormat titleformat=new WritableCellFormat(titlefont);
titleformat.setAlignment(Alignment.CENTRE);
titleformat.setBorder(Border.ALL,BorderLineStyle.THICK,Colour.GREEN);
titleformat.setVerticalAlignment(VerticalAlignment.CENTRE);
Label title=new Label(1,0,"Vendor Account Form",titleformat);
sheet.setColumnView(1,19);
sheet.setColumnView(2,19);
sheet.mergeCells(1,0,2,2);
sheet.addCell(title);
//fields
WritableFont fieldsfont = new WritableFont(WritableFont.ARIAL, 10,WritableFont.BOLD);
WritableFont valuesfont = new WritableFont(WritableFont.ARIAL, 10);
WritableCellFormat fieldsformat=new WritableCellFormat(fieldsfont);
WritableCellFormat valuessformat=new WritableCellFormat(fieldsfont);
valuessformat.setBorder(Border.ALL,BorderLineStyle.THIN);
String fields[]={"Vendor Id","Vendor Name","Vendor Address","Material Id","Quantity","Amount"};
int j=4;
for(int i=0;i<fields.length;i++){
Label field=new Label(1,j,fields<i>,fieldsformat);
sheet.addCell(field);
if(i<=3){
Label value=new Label(2,j,"",valuessformat);
sheet.addCell(value);
} else{
Number value=new Number(2,j,0,valuessformat);
sheet.addCell(value);
}
j++;
j++;
}
workbook.write();
workbook.close();
} catch (RowsExceededException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (WriteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I am using the the tutorial from the Web dynpro sample applications to do the export to excel.The excel is created on local system.When the user clicks on ""exporttoexcel"" button the excel sheet is created.But when there is only single record in the excel then there is not header in the excel sheet.Please suggest
Thanks,
Rajani
User | Count |
---|---|
87 | |
10 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.