on 02-08-2009 5:49 AM
How we can Export Table data into Excel sheets or pdf files? Can you give the code for that?
Hi,
Use JExcel API for excel..
/people/subramanian.venkateswaran2/blog/2006/08/16/exporting-table-data-to-ms-excel-sheetenhanced-web-dynpro-binary-cache
You may also try iText.jar for pfd..
/people/prakash.singh4/blog/2005/04/05/create-a-pdf-file-using-java
Read this comprehensive document for exporting webdynpro data to different formats:
Regards,
Anagha
Edited by: Anagha Jawalekar on Feb 8, 2009 3:27 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
closed
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Below is the method for writing into excel file. In this i have taken all the data which i need to insert in the xls to arrayList and passed the same in the Write() Method.
Below are the imports you need to provide.and for these you require to use import org.apache.poi.jar file.
which is a open source and can be easily available on internet.
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.util.Region;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
public void write(ArrayList getList){
try{
// create a new workbook
HSSFWorkbook workBook = new HSSFWorkbook();
//create a new worksheet
HSSFSheet sheet = workBook.createSheet();
// ***************header data******************//
//create a header row
HSSFRow headerRow = sheet.createRow((short) 0);
// define the area for the header data(row1->row3, col1-->col10)
sheet.addMergedRegion(new Region(0, (short) 0, 2,
(short) 10));
// After creating the caption region, create a cell to contain the caption value.
//create the header data cell
HSSFCell headerCell =
headerRow.createCell((short) 0);
//add the date to the header cell
headerCell.setCellValue("The Bowling Score");
// create a style for the header cell
HSSFCellStyle headerStyle =
workBook.createCellStyle();
headerStyle.setAlignment(
HSSFCellStyle.ALIGN_CENTER);
headerCell.setCellStyle(headerStyle);
System.out.println("Success full"+ getList.size());
//**************report data rows and cols*********//
// create 5 rows of data
for (int i=0;i<getList.size();i++){
System.out.println("Success full"+ getList.get(i));
HSSFRow row = sheet.createRow( i+4);
HSSFCell c11 = row.createCell((short)1);
c11.setCellValue(getList.get(i).toString());
}
FileOutputStream stream = new
FileOutputStream("D:\\New Folder\\Book1.xls");
workBook.write(stream);
Regards
Narendra
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
To Export to excel sheet you can use this code.
for (int i=0;i<nodetable.length;i++)
{
ITableElement ele =wdContext.nodeTable().getTableElementAt(i);
String str1=ele.getEmpId();
String str2=ele.getEmpId();
String str3=ele.getEmpName();
String str4=ele.getEmpStartDate();
String str5=ele.getEmpEndDate();
String str6=ele.getEmpNoOfdays();
String resourcePath;
String path;
java.util.Date date=new java.util.Date();
String str10=String.valueOf(date.getHours());
String str11=String.valueOf(date.getMinutes());
String str7=String.valueOf(date.getDay());
String str8=String.valueOf(date.getMonth());
String str9=String.valueOf(date.getYear());
String str6=str10+str11+str7+str8+str9+".xls";
File file=new File(str6);
FileOutputStream out; // declare a file output object
PrintStream p; // declare a print stream object
try
{
// Create a new file output stream
// connected to "myfile.txt"
out = new FileOutputStream(file);// keep the myfile.text in .../server0/
// Connect print stream to the output stream
p = new PrintStream(out);
p.println ("Leave form");
p.println("Employe id is-------- "+str1+"\n");
p.println("Employe name is------ "+Str2+"\n");
p.println("Start date----------- "+Str3+"\n");
p.println("End date------------- "+Str4+"\n");
p.println("No of working days--- "+Str5+"\n");
resourcePath =
WDURLGenerator.getResourcePath(
wdComponentAPI.getDeployableObjectPart(),
str6);
path = file.getAbsolutePath();
p.close();
}
catch (Exception e)
{
wdComponentAPI.getMessageManager().reportException("Error writing to file",false);
}
try{
resourcePath = WDURLGenerator.getResourcePath(
wdComponentAPI.getDeployableObjectPart(),
str6);
path = file.getAbsolutePath();
wdContext.currentContextElement().setFilename(str6);
}catch(Exception e)
{
e.printStackTrace();
}
}
Try this code.
For Pdf U need to install Adobe Life cycle Designer.
Regards,
H.V.Swathi
Edited by: H.V Swathi on Feb 9, 2009 6:50 AM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
May be of use for you
Regards
Ayyapparaj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
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.