使用JAVA打开一个CSV文件(使用JXL库)

我真的是JAVA的绿色angular。 我正在尝试使用JAVA(JXL)来执行以下操作:
1.在位于“C:\ Test”的Excel中打开一个csv文件(我可以把这个文件看作是用JXL打开的excel文件吗?)
2.检查单元格A1
如果A1为空,closures文件并结束例程。 如果A1不为空,请转至步骤3。
3.closurescsv文件并发送一封Outlook电子邮件给3人,说明“正在发生事件”

我假设可能有另一个API库需要与Microsoft Outlook一起工作

我一直在使用Netbeans

我感谢任何帮助!
戴夫

import java.io.File; import java.io.IOException; import jxl.Cell; import jxl.CellType; import jxl.Sheet; import jxl.Workbook; import jxl.read.biff.BiffException; public class ReadExcel { private String inputFile; public void setInputFile(String inputFile) { this.inputFile = inputFile; } public void read() throws IOException { File inputWorkbook = new File(inputFile); Workbook w; try { w = Workbook.getWorkbook(inputWorkbook); // Get the first sheet Sheet sheet = w.getSheet(0); // Loop over first 10 column and lines for (int j = 0; j < sheet.getColumns(); j++) { for (int i = 0; i < sheet.getRows(); i++) { Cell cell = sheet.getCell(j, i); CellType type = cell.getType(); if (type == CellType.LABEL) { System.out.println("I got a label " + cell.getContents()); } if (type == CellType.NUMBER) { System.out.println("I got a number " + cell.getContents()); } } } } catch (BiffException e) { e.printStackTrace(); } } public static void main(String[] args) throws IOException { ReadExcel test = new ReadExcel(); test.setInputFile("c:/temp/lars.xls"); test.read(); } } ` 

这是你应该做的 – 其中inputFile是位置 – C:\ Users \ Bob \ test.csv