Excel Sheeds in einem Fenster wiedergeben
Verfasst: Mi Jun 11, 2014 11:29 am
Hallo bin neu hier und hab momentan ein kleines Problem. Muss für meine Uni ein Programm schreiben, dass die Sheeds (Tabellen) einer Excel in einem Fenster ausgibt. Ich habe zwar geschafft, dass mir die Sheeds in der Konsole angezeigt werden, aber ich weiß jetzt nicht, wie ich es in ein neues Fenster weitergeben soll.
Code: Alles auswählen
import java.io.FileInputStream;
import java.io.IOException;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
// The following example code demonstrates how to get the Sheet
// names in an Excel spreadsheet file
public class GetExcelSheetNames {
public static void main(String[] args) {
FileInputStream fileInputStream = null;
try {
fileInputStream = new FileInputStream("C:/Users/test.xls");
HSSFWorkbook workbook = new HSSFWorkbook(fileInputStream);
// for each sheet in the workbook
for (int i = 0; i < workbook.getNumberOfSheets(); i++) {
System.out.println("Sheet name: " + workbook.getSheetName(i));
}
} catch (IOException e) {
e.printStackTrace();
} finally {
if (fileInputStream != null) {
try {
fileInputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}