Hi, I should use a CsvReader opensource library.
See the example: http://www.csvreader.com/java_csv_samples.php <http://www.csvreader.com/java_csv_samples.php>Best Regards, On Tue, Jan 12, 2010 at 11:55 PM, piyushn <piyushn...@gmail.com> wrote: > what you can do is .. > create CSV file (Comma Seprated Value) file that is similar to excel > file . csv file opens in ms excel only > > i give you hint how you can do it. > create value you want to write > ex. {"hello","how","are","you"} > this way.. > > if are facing problems tell me.. > > > regards, > Piyush Patel > > On Jan 12, 6:36 am, udeshika <perera....@gmail.com> wrote: > > Hi, > > > > Anyone knows how to create a MS Excel file using java,i was tring to > create > > a file but it gives a exception when i run the programe.I'm using Apache > PIO > > API in eclips, for the my program.please help me to over come this > problem. > > > > Thanxx > > > > Code > > > ************************************************************************************************************************ > > import java.io.FileOutputStream; > > import java.io.IOException; > > > > import org.apache.poi.hssf.usermodel.HSSFCell; > > import org.apache.poi.hssf.usermodel.HSSFCellStyle; > > import org.apache.poi.hssf.usermodel.HSSFFont; > > 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.HSSFColor; > > import org.apache.poi.hssf.util.Region; > > //import org.apache.poi.hssf.uti.*; > > public class xxxxxx { > > > > private static HSSFRow columnHeaderRow; > > private static HSSFCell totalValue; > > > > @SuppressWarnings("deprecation") > > public static void main(String []args){ > > HSSFWorkbook workBook=new HSSFWorkbook(); > > HSSFSheet sheet = workBook.createSheet(); > > HSSFRow headerRow = sheet.createRow((short) 0); > > sheet.addMergedRegion(new Region(0, (short) 0, 2,(short) > 10)); > > HSSFCell headerCell = headerRow.createCell((short) 0); > > headerCell.setCellValue("The Bowling Score"); > > HSSFCellStyle headerStyle =workBook.createCellStyle(); > > headerStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER); > > headerCell.setCellStyle(headerStyle); > > HSSFCellStyle columnHeaderStyle =workBook.createCellStyle(); > > > > columnHeaderStyle.setFillBackgroundColor(HSSFColor.BLUE_GREY.index); > > > > columnHeaderStyle.setFillForegroundColor(HSSFColor.BLUE_GREY.index); > > HSSFFont font = workBook.createFont(); > > font.setColor(HSSFFont.COLOR_RED); > > columnHeaderStyle.setFont(font); > > HSSFCell colHeading1 = columnHeaderRow.createCell((short) > 0); > > HSSFCell colHeading2 =columnHeaderRow.createCell((short) > 4); > > colHeading1.setCellStyle(columnHeaderStyle); > > colHeading2.setCellStyle(columnHeaderStyle); > > HSSFRow row1 = sheet.createRow((short) 5); > > HSSFRow row2 = sheet.createRow((short) 6); > > HSSFRow row3 = sheet.createRow((short) 7); > > HSSFRow row4 = sheet.createRow((short) 8); > > HSSFRow row5 = sheet.createRow((short) 9); > > > > // create the 2 cells for each row > > HSSFCell c11 = row1.createCell((short) 0); > > HSSFCell c12 = row1.createCell((short) 4); > > HSSFCell c21 = row2.createCell((short) 0); > > HSSFCell c22 = row2.createCell((short) 4); > > HSSFCell c31 = row3.createCell((short) 0); > > HSSFCell c32 = row3.createCell((short) 4); > > HSSFCell c41 = row4.createCell((short) 0); > > HSSFCell c42 = row4.createCell((short) 4); > > > > // writing data to the cells > > c11.setCellValue("Sam"); > > c12.setCellValue(100); > > > > c21.setCellValue("John"); > > c22.setCellValue(50); > > > > c31.setCellValue("Paul"); > > c32.setCellValue(25); > > > > c41.setCellValue("Richard"); > > c42.setCellValue(20); > > totalValue.setCellType(HSSFCell.CELL_TYPE_FORMULA); > > totalValue.setCellFormula("SUM(E6:E9)"); > > FileOutputStream stream; > > try { > > stream = new FileOutputStream("Book1.xls"); > > workBook.write(stream); > > } catch (IOException e) { > > // TODO Auto-generated catch block > > e.printStackTrace(); > > } > > } > > } > > > ******************************************************************************************* > > This is the Excception > > ************************************ > > org.apache.poi.hssf.dev.BiffViewer$CommandParseException: Biff viewer > needs > > a filename > > at > > org.apache.poi.hssf.dev.BiffViewer$CommandArgs.parse(BiffViewer.java:321) > > at org.apache.poi.hssf.dev.BiffViewer.main(BiffViewer.java:370) > > > > Regards , > > Udeshika Perera. > > -- > You received this message because you are subscribed to the Google > Groups "Java EE (J2EE) Programming with Passion!" group. > To post to this group, send email to > java-ee-j2ee-programming-with-passion@googlegroups.com > To unsubscribe from this group, send email to > java-ee-j2ee-programming-with-passion+unsubscr...@googlegroups.com<java-ee-j2ee-programming-with-passion%2bunsubscr...@googlegroups.com> > For more options, visit this group at > > http://groups.google.com/group/java-ee-j2ee-programming-with-passion?hl=en?hl=en > -- Truong Hong Thai
-- You received this message because you are subscribed to the Google Groups "Java EE (J2EE) Programming with Passion!" group. To post to this group, send email to java-ee-j2ee-programming-with-passion@googlegroups.com To unsubscribe from this group, send email to java-ee-j2ee-programming-with-passion+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/java-ee-j2ee-programming-with-passion?hl=en?hl=en