hi to all.
i written a action performed method to export table data but it is not working fine.It is creating a excel file but there is no data in it. I am sending the code here. please do favour for me.bye.Have a nice day.
//////////////////////////////////////////////////////////////////////////////////////////////////////
export.addActio nListener(new ActionListener( )
{
public void actionPerformed (ActionEvent e)
{
HSSFWorkbook workbook = new HSSFWorkbook();
FileOutputStrea m fout=null;
try{
fout = new FileOutputStrea m("MyWorkbook.x ls");
workbook.write( fout);}
catch (Exception ee)
{
}
HSSFRow[] row=new HSSFRow[table.getRowCou nt()]; HSSFSheet sheet1 = workbook.create Sheet("Sheet One");
for(int i=0;i<table.get RowCount();i++)
{
row[i] = sheet1.createRo w((short) i);
}
HSSFCell[][] cell=new HSSFCell[table.getRowCou nt()] [table.getColumn Count()];
short col=0;
for(int i=0;i<row.lengt h;i++)
{
for(int j=0;j<table.get ColumnCount();j ++){
cell[i][j]=row[j].createCell(col ++); }
String str;
for(int i=0;i<table.get RowCount();i++)
{
int k=1;
for(int j=0;j<table.get ColumnCount()-1;j++)
{
str=(String)tab le.getValueAt(i ,k);
System.out.prin tln("c["+i+"]["+j+"]="+str);
cell[i][j].setCellValue(s tr);
k++;
}
}
try
{
fout.close();
}
catch(Exception ee)
{
}
}
});
i written a action performed method to export table data but it is not working fine.It is creating a excel file but there is no data in it. I am sending the code here. please do favour for me.bye.Have a nice day.
//////////////////////////////////////////////////////////////////////////////////////////////////////
export.addActio nListener(new ActionListener( )
{
public void actionPerformed (ActionEvent e)
{
HSSFWorkbook workbook = new HSSFWorkbook();
FileOutputStrea m fout=null;
try{
fout = new FileOutputStrea m("MyWorkbook.x ls");
workbook.write( fout);}
catch (Exception ee)
{
}
HSSFRow[] row=new HSSFRow[table.getRowCou nt()]; HSSFSheet sheet1 = workbook.create Sheet("Sheet One");
for(int i=0;i<table.get RowCount();i++)
{
row[i] = sheet1.createRo w((short) i);
}
HSSFCell[][] cell=new HSSFCell[table.getRowCou nt()] [table.getColumn Count()];
short col=0;
for(int i=0;i<row.lengt h;i++)
{
for(int j=0;j<table.get ColumnCount();j ++){
cell[i][j]=row[j].createCell(col ++); }
String str;
for(int i=0;i<table.get RowCount();i++)
{
int k=1;
for(int j=0;j<table.get ColumnCount()-1;j++)
{
str=(String)tab le.getValueAt(i ,k);
System.out.prin tln("c["+i+"]["+j+"]="+str);
cell[i][j].setCellValue(s tr);
k++;
}
}
try
{
fout.close();
}
catch(Exception ee)
{
}
}
});
Comment