
how to connect client to server using Sockets

/* author K.santhosh kumar-> ksankumar@gmail.com*/
import java.io.FileOutputStream;
import org.apache.poi.hssf.usermodel.HSSFRow; import org.apache.poi.hssf.usermodel.HSSFSheet; import org.apache.poi.hssf.usermodel.HSSFWorkbook;
public class ExrelWriter{ public static void main(String[]args){ try{ String filename="c:/hello.xls" ; String rw[][]={{"1","san","kumar","ksankumar","ksankumar@gmail.com","india"}, {"2","palani","kumar","palanikumar","palani_tweet@gmail.com","india"}, {"3","raja","pandiyan","rajapandiyan","raja_pandiya@gmail.com","US"}}; HSSFWorkbook hwb=new HSSFWorkbook(); HSSFSheet sheet = hwb.createSheet("new sheet");
HSSFRow rowhead= sheet.createRow((short)0); rowhead.createCell((short) 0).setCellValue("SNo");
rowhead.createCell((short) 1).setCellValue("First Name");
rowhead.createCell((short) 2).setCellValue("Last Name");
rowhead.createCell((short) 3).setCellValue("Username");
rowhead.createCell((short) 4).setCellValue("E-mail");
rowhead.createCell((short) 5).setCellValue("Country");
for(int i=1;i<3;i++)
for(int j=0;j<6;j++){
HSSFRow row= sheet.createRow((short)i);
row.createCell((short) j).setCellValue(rw[i-1][j]);
}
FileOutputStream fileOut = new FileOutputStream(filename); hwb.write(fileOut); fileOut.close(); System.out.println("Your excel file has been generated!");
} catch ( Exception ex ) { System.out.println(ex);
} } }
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.